This is the mail archive of the
mailing list for the binutils project.
[gold] Relocation data handling for comdat sections when doing a relocatable link
- From: Artemiy Volkov <artemiyv at acm dot org>
- To: binutils at sourceware dot org
- Cc: Cary Coutant <ccoutant at gmail dot com>
- Date: Mon, 28 Nov 2016 13:23:32 +0300
- Subject: [gold] Relocation data handling for comdat sections when doing a relocatable link
- Authentication-results: sourceware.org; auth=none
- Reply-to: artemiyv at acm dot org
I've stumbled upon an issue when linking a lot of C++ template-heavy
code into a single library with gold. To ensure that there's only one
copy of each text section corresponding to an instantiation of a
template function, it uses the comdat section mechanism, which is
handled just fine for regular linking in relocate_section().
However, for relocatable linking it uses scan_relocatable_relocs() +
relocate_relocs(). AFAICT, scan_relocatable_relocs() is simply setting
relocation strategy to RELOC_DISCARD for every relocation that refers
to a section that's being discarded, and that's a problem for every
comdat section except those whose contents end up being included in
the output file. This way lots of relocations in the debug sections
are discarded instead of adjusted and the debug information becomes
Is this a known problem? Or might I be doing something wrong?