Re: [2.6 patch] Use -ffreestanding? (fwd)

From: Adrian Bunk
Date: Mon Nov 22 2004 - 07:48:44 EST


On Sun, Nov 21, 2004 at 10:10:28PM -0800, Linus Torvalds wrote:
>
>
> On Mon, 22 Nov 2004, Adrian Bunk wrote:
> >
> > for the kernel, it would be logical to use -ffreestanding. The kernel is
> > not a hosted environment with a standard C library.
> >
> > Linus agreed that it would make sense.
>
> Note that while I agree that it sounds sensible, it would be good to have
> somebody specify exactly what changes from the use of "-ffreestanding".
>
> I _assume_ that all the things that gcc takes for granted are things that
> Linux already has its own definitions for, and that -ffreestanding doesn't
> actually change anything for at least the regular architectures. But if
> there is any object code changes, can you check those out and explain
> them?

Andi Kleen reported:
Newer gcc rewrites sprintf(buf,"%s",str) to strcpy(buf,str) transparently.

This is only true with unit-at-a-time (disabled on i386 but enabled
on x86_64). The Linux kernel doesn't offer a standard C library, and
such transparent replacements of kernel functions with builtins are
quite fragile.

Even with -ffreestanding, it's still possilble to explicitely use a gcc
builtin if desired.

> Linus

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/