Output section descriptions with the same name

Alan Modra amodra@gmail.com
Tue Nov 24 21:42:40 GMT 2020


On Mon, Nov 23, 2020 at 09:32:28PM -0800, Fangrui Song wrote:
> I mentioned one discrepancy between GNU ld and gold in
> https://sourceware.org/pipermail/binutils/2020-November/114125.html
> That topic is mainly about DWARF64, so I am creating a separate topic
> here.
> 
> For output section descriptions with the same name, currently GNU ld
> concatenates the contents while gold (and LLD) create multiple output sections.

Yes.  This could easily be changed.  Note that gold was designed to
work without scripts, so there are quite a few differences between
ld.bfd and ld.gold with unusual linker scripts.  ie. gold probably
shouldn't be taken as a standard for GNU linker script behaviour.
Also, ld.bfd supports many more targets.  In particular, the embedded
targets are likely to have complex user generated scripts with unusual
features (and plain weird stuff that just happens to work by
accident).  Changing script behaviour, even slightly, often generates
bug reports..  I've been caught out before now, but I'm not against
this particular change.  It seems quite reasonable.

> 
>   SECTIONS {
>     .debug_info 0 : { a.o(.debug_info) }
>     .debug_info 0 : { b.o(.debug_info) }
>   }
> 
> I slightly prefer the gold behavior.
> 
> The decision here should ideally align with future linker script
> extension: https://sourceware.org/bugzilla/show_bug.cgi?id=26404

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list