Re: const __init

Keith Owens
2001-05-21T07:50:22Z

On Sun, 20 May 2001 17:34:48 -0400,
Jeff Garzik <jgarzik@mandrakesoft.com> wrote:
>(let me know if the following test is flawed)
>
> [jgarzik@rum tmp]$ cat > sectest.c
> #include <linux/module.h>
> #include <linux/init.h>
> static const char version[] __initdata = "foo";
> [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.

With just one variable in initdata there is no conflict, it takes two
to conflict.

static const char var1[] __attribute__ ((__section__ (".data.init"))) = "foo";
int main(void) { return(0); }
static int var2[] __attribute__ ((__section__ (".data.init"))) = {0,1};

does cause a section conflict, egcs 1.1.2.

Interestingly enough, if var[12] are together, without the intervening
text, then gcc does not flag an error, instead it puts both variables
in section .data.init and marks it as read only. This looks like a bug
in gcc.