On Thu, 18 Oct 2007, Franck Bui-Huu wrote: > So it seems there is no way from a linker script to specify that a > section has the nobits type, is it ? Well, you cannot switch section types in a linker script at all in general. The place to do it is always in the assembler, which is the tool which actually emits this data. > After spending some fun time trying several different configurations > with gcc and ld, I noticed that gcc makes a section with @nobits > attribute if the section name starts with .bss.* Exactly how GCC sets section flags is mostly determined by default_section_type_flags() in gcc/varasm.c; some flags are set elsewhere too. This is with HEAD of GCC. > Another test I did is to put .init.bss (not .bss.init) section right > before .bss section in order to have only one segment to load. And it > makes magically ld do the right thing. I must admit that I don't > understand why, and the lack of documentation doesn't help... Hmm, isn't what `info ld' says enough? I think a look at what the SysV ABI documents say about ELF could clarify some matters too. Also have a look at how sections are mapped to segments as after the final link it is segments that matter -- `readelf -l' will do. > Unfortunately I don't know if we can rely on one of these > behaviours. IOW if they're going to work with all supported versions > of gcc/ld. Probably -- I guess you only need to check what GCC 3.2 did. Or you could use a hack with __attribute__((section())) like one I did for merging strings -- unlike with SECTION_BSS I think there is no way to request (SECTION_MERGE | SECTION_STRINGS) in an implicit way anyhow. Maciej