[PATCH] bfd/ELF: don't lose trailing globals from SHF_MERGE sections
Michael Matz
matz@suse.de
Tue Sep 30 14:08:36 GMT 2025
Hello,
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? When I last worked on
that whole string merging stuff I had trouble excercising all error paths
and therefore often just retained the old code, possibly with changes for
the current regime, which may or may not have been incomplete. (I don't
remember if this was one of the non-triggerable code paths)
I think your change does make sense, but seeing it in action would be
nice.
Ciao,
Michael.
More information about the Binutils
mailing list