From: Denys Vlasenko on 17 Jun 2010 16:20 >> This is doable in asm, yes. For .bss, we need to not forget about >> @nobits too: section .bss.foo,"aw",@nobits > > That's only for bss ... we have about a handful of such statements and > they always use the assembler .bss directive (which doesn't need flags). > >> > Actually, as I said, that would be .data- You are right, in assembly we can specify needed attributes. I am more concerned about C: arch/x86/include/asm/cache.h: #define __read_mostly __attribute__((__section__(".data..read_mostly"))) If we change it to #define __read_mostly __attribute__((__section__(".data-read_mostly"))) What makes this section have correct attributes? With current gcc, __attribute__((__section__(".bss-page_aligned"))) does get wrong attributes. That's why we settled on .bss..foo scheme. > I thought I just refuted that in the above: we don't care what the > assembler sections are flagged as because the linker script gets to pick > the flags anyway ... so most bugs arrived at this way have no visible > side effects ... and section merging problems have to be accounted for > anyway in the final linker scripts. When I was working on a older iteration of this patch, I renamed .bss.page_aligned to .page_aligned.bss and was bitten by linker bug: linker tried to merge the sections and corrupted them. Aha, here is it: http://sourceware.org/bugzilla/show_bug.cgi?id=5006 It was since fixed, and if I read the ld patch correctly, now ld emits a warning and switches entire target section to PROGBITS - not what we want to happen to bss. -- vda -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: James Bottomley on 17 Jun 2010 16:40
On Thu, 2010-06-17 at 22:19 +0200, Denys Vlasenko wrote: > >> This is doable in asm, yes. For .bss, we need to not forget about > >> @nobits too: section .bss.foo,"aw",@nobits > > > > That's only for bss ... we have about a handful of such statements and > > they always use the assembler .bss directive (which doesn't need flags). > > > >> > Actually, as I said, that would be .data- > > You are right, in assembly we can specify needed attributes. > > I am more concerned about C: > > arch/x86/include/asm/cache.h: > #define __read_mostly __attribute__((__section__(".data..read_mostly"))) > > If we change it to > > #define __read_mostly __attribute__((__section__(".data-read_mostly"))) > > What makes this section have correct attributes? The fact that we specify it correctly in the sectional gather in the linker scripts. i.e. we should have a (NOLOAD) type for the gathered .bss section ... although currently we don't. The point (for the third time) is that if our linker scripts specify the sections and attributes absolutely (and correctly) it doesn't matter what random attributes the .o files pick up. It's only if we miss a specifier that the linker tries to work it out from the input sections. That's how we make postfix or any other type of "nonstandard" section name work. James -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |