Re: const __init

Ingo Oeser
2001-05-20T22:20:15Z

On Sun, May 20, 2001 at 05:34:48PM -0400, Jeff Garzik wrote:
> This might be a very valid point...
>
> (let me know if the following test is flawed)

It is imho.

> > [jgarzik@rum tmp]$ cat > sectest.c
> > #include <linux/module.h>
> > #include <linux/init.h>
> > static const char version[] __initdata = "foo";
static char version2[] __initdata = "bar";
> > [jgarzik@rum tmp]$ gcc -D__KERNEL__ -I/spare/cvs/linux_2_4/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -mpreferred-stack-boundary=2 -march=i686 -c -o sectest.o sectest.c
> > [jgarzik@rum tmp]$
>
> No section type conflict appears.

Now it SHOULD conflict on these binutils, but doesn't on mine (2.9.5) ;-)

It is decided to put it into .data.init as expected.

AFAIK "const" is only a promise to the compiler, that we write
this data ONCE and read only after this initial write. So the
decision on the section is implementation defined.

What I don't understand is, why GCC overrides our explicit
override (done by setting the "section attribute" explicitly).

I would consider this a BUG in GCC. I don't understand, why we
support this BUG...

Maybe some GCC people can enlighten me, why GCC ignores such
overrides, that are for the cases where we DO KNOW BETTER than
GCC, what section is correct.

Regards

Ingo Oeser
--
To the systems programmer,
users and applications serve only to provide a test load.