[PATCH] bfd/ELF: don't lose trailing globals from SHF_MERGE sections
Jan Beulich
jbeulich@suse.com
Tue Oct 7 12:02:42 GMT 2025
On 30.09.2025 16:08, Michael Matz wrote:
> On Fri, 26 Sep 2025, Jan Beulich wrote:
>> _bfd_merged_section_offset() treats trailing symbols specially: That of
>> the retained section will be assigned the section size, while all ones in
>> replaced sections will be set to zero (which will then have output offset
>> added, i.e. generally the size of the retained section). However, in
>> neither case will the function change the section. Hence such trailing
>> symbols, when not originating from the retained section, will appear to
>> live in excluded sections, when they really belong to the sole retained
>> one.
>>
>> Replace the section in all cases, and uniformly return section size.
>> ---
>> I actually wonder whether we shouldn't also respect offset > sec->rawsize,
>> by adding offset - sec->rawsize to the return value.
>>
>> If, for whatever reason, this adjustment was unacceptable, the SEC_EXCLUDE
>> check in elf_link_output_extsym() may want extending to also look for
>> SEC_KEEP, which replaced sections will have set (afaict).
>
> Have you found testcases taking that code path?
Yes (if "testcases" isn't meant to be limited to what is in the tree right
now), and that other change was in fact the fix I had first tried. Having
thought of the (posted) alternative, I considered that the hopefully more
"clean" approach.
Jan
More information about the Binutils
mailing list