Re: [PATCH] C undefined behavior fix

From: Tom Rini (trini@kernel.crashing.org)
Date: Wed Jan 02 2002 - 18:12:43 EST


On Wed, Jan 02, 2002 at 11:23:21PM +0100, jtv wrote:
> On Wed, Jan 02, 2002 at 03:05:48PM -0700, Tom Rini wrote:
> >
> > Well, the problem is that we aren't running where the compiler thinks we
> > are yet. So what would the right fix be for this?
>
> Obviously -ffreestanding isn't, because this problem could crop up pretty
> much anywhere. The involvement of standard library functions is almost
> coincidence and so -ffreestanding would only fix the current symptom.

After thinking about this a bit more, why wouldn't this be the fix? The
problem is that gcc is assuming that this is a 'normal' program (or in
this case, part of a program) and that it, and that the standard rules
apply, so it optimizes the strcpy into a memcpy. But in this small bit
of the kernel, it's not. It's not even using the 'standard library
functions', but what the kernel provides. This problem can only crop up
in the time before we finish moving ourself around.

-- 
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 21:00:18 EST