]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/ELF: don't lose trailing globals from SHF_MERGE sections
authorJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 07:25:31 +0000 (09:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 07:25:31 +0000 (09:25 +0200)
_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.

bfd/merge.c

index f09078ae31e74dc8360642a759cfb1ae5785e7c6..f5a41b50a5325b29f35b04106c8855cbc9ae9cfe 100644 (file)
@@ -1125,7 +1125,8 @@ _bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
          /* xgettext:c-format */
          (_("%pB: access beyond end of merged section (%" PRId64 ")"),
           sec->owner, (int64_t) offset);
-      return secinfo->first_str ? sec->size : 0;
+      *psec = sec = secinfo->reprsec;
+      return sec->size;
     }
 
   if (secinfo->fast_state != 2)