From d4c517eec101a1b0375430b695cb79551b823666 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 10 Oct 2025 09:25:31 +0200 Subject: [PATCH] bfd/ELF: don't lose trailing globals from SHF_MERGE sections _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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bfd/merge.c b/bfd/merge.c index f09078ae31e..f5a41b50a53 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -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) -- 2.47.3