Re: [PATCH] C undefined behavior fix

Tom Rini
2002-01-02T23:14:04Z

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)