This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Gnu ld creates phantom sections
- From: Erik Christiansen <erik at dd dot nec dot com dot au>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 14 Nov 2002 14:51:54 +1100
- Subject: Gnu ld creates phantom sections
Why would ld tack digits onto the end of the names of real sections,
just to create troublesome empty sections?
$ powerpc-linux-ld -V
GNU ld version 2.13.90.0.4 20020814
Supported emulations:
elf32ppclinux
elf32ppc
elf32ppcsim
Despite no mention of them in the linker script, or single assembler
source file, ld created the following empty sections, in each case
tacking a digit onto a real section name, then had the cheek to bitch
about them:
powerpc-linux-ld: warning: no memory region specified for section
`.data.1'
powerpc-linux-ld: warning: no memory region specified for section
`.sdata.3'
powerpc-linux-ld: warning: no memory region specified for section
`.bss.2'
powerpc-linux-ld: warning: no memory region specified for section
`.sbss.4'
powerpc-linux-ld: warning: no memory region specified for section
`.sdata2.5'
After some googling, the ld option: --gc-sections made them go away.
The manpage seems to explain why --gc-sections helps:
--gc-sections
Enable garbage collection of unused input sections.
The phantom sections do not exist prior to involving ld:
$ objdump -h init.o # shows only: .text .data .bss .rom_init
The linker script has:
SECTIONS
{
.text : AT (__DATA_ROM1_START) { *(.text) *(.init) *(.fini) *(.eini) } > ram
.sdata2 : AT (__DATA_ROM1_START + SIZEOF(.text)) {} > ram
.data : AT (__DATA_ROM1_START + SIZEOF(.text) + SIZEOF(.sdata2)) {} > ram
.sdata : AT (__DATA_ROM1_START + SIZEOF(.text) + SIZEOF(.sdata2) + SIZEOF(.data)) {} > ram
__DATA_RAM_END = .;
.sbss : {} > ram
. = 0x00200000; /* Assume Flash code is max 2Mb and sdram allocated
for flash code is also Max 2Mb*/
.bss : {} > ram /*After this 2MB normal ram starts*/
. = __DATA_ROM1_START + SIZEOF(.text) + SIZEOF(.sdata2) + SIZEOF(.data) +
SIZEOF(.sdata);
.startup : { *(.rom_init) } > rom
__DATA_ROM_END = .;
.heap : {} > rta /* Bring the region into section namespace. */
}
So the cause of their creation is unexplained, and thus unnerving.
Haven't found anything directly relevant in the archives.
Regards,
Erik