Re: const __init
On 05.21 Richard Henderson wrote: > On Mon, May 21, 2001 at 01:07:50PM +1000, Keith Owens wrote: > > 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. > > Fixed in compilers newer than 2 years old. > Somebody should officially certify 2.95.2 (or better 2.95.3, if all the kernel related bugs are solved), and change: "The recommended compiler for the kernel is egcs 1.1.2 (gcc 2.91.66), and it should be used when you need absolute stability. You may use gcc 2.95.x instead if you wish, although it may cause problems." -- J.A. Magallon # Let the source be with you... mailto:[EMAIL PROTECTED] Linux Mandrake release 8.1 (Cooker) for i586 Linux werewolf 2.4.4-ac11 #2 SMP Fri May 18 12:27:06 CEST 2001 i686 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
Richard Henderson wrote: > No, the problem is not with which section, but what flags that > section should have. If you put only "const" data in a section, > then the section should have SHF_WRITE clear. Conversely, if > you put writable data in a section then SHF_WRITE should be set. > > Now, one could argue that gcc should scan the entire file to > see if there are any non-constant data members added to a > particular section, and set SHF_WRITE if any such exist. > > My answer is: you would not like gcc's memory usage under these > conditions. No, I'd argue that gcc should offer a `section_flags' attribute to be used along with the `section' attribute. Then we change the definition of __init. -- Jamie. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Mon, May 21, 2001 at 01:07:50PM +1000, Keith Owens wrote: > 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. Fixed in compilers newer than 2 years old. r~ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Sun, 20 May 2001 17:34:48 -0400, Jeff Garzik <[EMAIL PROTECTED]> wrote: >(let me know if the following test is flawed) > > [jgarzik@rum tmp]$ cat > sectest.c > #include > #include > 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. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Mon, May 21, 2001 at 12:19:49AM +0200, Ingo Oeser wrote: > 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. No, the problem is not with which section, but what flags that section should have. If you put only "const" data in a section, then the section should have SHF_WRITE clear. Conversely, if you put writable data in a section then SHF_WRITE should be set. Now, one could argue that gcc should scan the entire file to see if there are any non-constant data members added to a particular section, and set SHF_WRITE if any such exist. My answer is: you would not like gcc's memory usage under these conditions. r~ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Sun, 20 May 2001 22:16:11 +0200, Franz Sirl <[EMAIL PROTECTED]> wrote: >Yes, and gcc3 errors on these constructs, cause it cannot decide if the data >should be put into a .data or .rodata section. >Dunno if it's worth to create a __initconstdata/__initrodata though, but it >would be easy implement I guess. Not worth it. Adding finer grained init.data sections requires changes to every architecture's vmlinux.lds script but it gains you nothing, the sections are discarded after the kernel has booted. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
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 > > #include > > 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. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Sun, May 20, 2001 at 09:51:04PM +0200, Geert Uytterhoeven wrote: > Appendix: here's the list of affected source files: > > arch/arm/kernel/setup.c Thanks for pointing it out. -- Russell King ([EMAIL PROTECTED])The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
Geert Uytterhoeven wrote: > > On Sun, 20 May 2001, Jeff Garzik wrote: > > Geert Uytterhoeven wrote: > > > Since a while include/linux/init.h contains the line > > > > > > * Also note, that this data cannot be "const". > > > > > > Why is this? Because const data will be put in a different section? > > > > Causes a "section type conflict" build error, at least on x86. > > On m68k I only saw section type conflict errors when using __init while it > should have been __initdata. This might be a very valid point... (let me know if the following test is flawed) > [jgarzik@rum tmp]$ cat > sectest.c > #include > #include > 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. -- Jeff Garzik | "Do you have to make light of everything?!" Building 1024| "I'm extremely serious about nailing your MandrakeSoft | step-daughter, but other than that, yes." - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Sun, 20 May 2001, Jeff Garzik wrote: > Geert Uytterhoeven wrote: > > Since a while include/linux/init.h contains the line > > > > * Also note, that this data cannot be "const". > > > > Why is this? Because const data will be put in a different section? > > Causes a "section type conflict" build error, at least on x86. On m68k I only saw section type conflict errors when using __init while it should have been __initdata. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [EMAIL PROTECTED] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
On Sunday 20 May 2001 21:51, Geert Uytterhoeven wrote: > Since a while include/linux/init.h contains the line > > * Also note, that this data cannot be "const". > > Why is this? Because const data will be put in a different section? Yes, and gcc3 errors on these constructs, cause it cannot decide if the data should be put into a .data or .rodata section. Dunno if it's worth to create a __initconstdata/__initrodata though, but it would be easy implement I guess. > drivers/video/aty128fb.c Fixed in bk 2_4. Franz. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: const __init
Geert Uytterhoeven wrote: > > Since a while include/linux/init.h contains the line > > * Also note, that this data cannot be "const". > > Why is this? Because const data will be put in a different section? Causes a "section type conflict" build error, at least on x86. > FWIW, many sources still use __init for data, while it should be __initdata. *blink* wow -- Jeff Garzik | "Do you have to make light of everything?!" Building 1024| "I'm extremely serious about nailing your MandrakeSoft | step-daughter, but other than that, yes." - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/