LD version 2.18.x produces bogus "section .xxx overlaps section .bss", while LD version 2.16.1 works just fine. Here is cut-down test to reproduce the problem: $ echo -n | ~/try/bin/sparc-elf-as -o test.o $ ~/try/bin/sparc-elf-ld -v -o test -T test.lnk test.o GNU ld (GNU Binutils) 2.18.50.20080218 /home/osv/try/bin/sparc-elf-ld: section .xxx [00000110 -> 0000011f] overlaps section .bss [00000110 -> 0000022f] $ cat test.lnk MEMORY { ROM : ORIGIN = 0, LENGTH = 0x1000 RAM : ORIGIN = 0x4000, LENGTH = 0x1000 } SECTIONS { .data : AT(__data_image) { . += 0x110; } > RAM .bss : { . += 0x120; } > RAM .data_image (NOLOAD): { __data_image = .; . += SIZEOF(.data); } > ROM .xxx : { . += 0x10; } > ROM .text : { *(.text) } > ROM } $
Created attachment 2287 [details] Respect the AT> syntax even if no other memory region for the section has been specified
Subject: Re: New: Spurious "section xxx overlaps section yyy" Hi Sergei, > LD version 2.18.x produces bogus "section .xxx overlaps section .bss", while LD > version 2.16.1 works just fine. Well the 2.18 linker is behaving as documented. Specifically in the bit on the "Output Section LMA" in the manual: If neither AT nor AT> is specified for an allocatable section, the linker will set the LMA such that the difference between VMA and LMA for the section is the same as the preceding output section in the same region. Since the .bss section does not have an AT or an AT> directive its LMA is set to 0x110, so that difference between its VMA (0x4110), as set by the "> RAM" directive, and its LMA is 0x4000, ie the same as the difference between the VMA and the LMA of the .data section. (Try running the linker with the --no-check-sections option and then looking at the section headers to see this). This is a change in the linker's behaviour that was made for the 2.18 release. There is even a mention of it in the NEWS file. It does suggest a workaround for the problem: Change the "> RAM" in the description of the .bss section to "AT> RAM". ie: .bss : { . += 0x120; } AT> RAM According to the manual this will set both the LMA and the VMA for the section, and you will end up with the same behaviour as the 2.16 linker. (This change is backwards compatible, i.e. it will work with the 2.16 linker as well). Unfortunately there is a bug in the current linker sources such that the "AT> [region-name]" syntax is ignored unless there is also an "> [region-name-2]" specified for the section, and the two regions are different. I can see no good reason for this, and the behaviour certainly isn't documented, so I am planning to check in the uploaded patch to remove this restriction unless my regression testing shows up a problem. Cheers Nick
Patch checked in with this changelog entry. ld/ChangeLog 2008-02-22 Nick Clifton <nickc@redhat.com> PR ld/5785 * ldlang.c (lang_size_sections_1): Honour the setting of an lma_region even if there is no vma region set, or the vma region is the same as the lma region.