[binutils-gdb/binutils-2_47-branch] bfd: SEC_DEBUGGING in bfd_generic_get_relocated_section_contents()

Jan Beulich jbeulich@sourceware.org
Fri Aug 14 08:40:25 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3357ea1d3cbf887eef7e4f478a9e7adc266dce2f

commit 3357ea1d3cbf887eef7e4f478a9e7adc266dce2f
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 14 10:36:01 2026 +0200

    bfd: SEC_DEBUGGING in bfd_generic_get_relocated_section_contents()
    
    Unilaterally excluding debugging sections as done by 810b19952d5d ("bfd:
    generalize _bfd_elf_merge_sections()") is clearly wrong. I did test
    linking of a decent size "real" binary without that, inspecting debug info
    to all be fine. Then, upon finding quite a bit of testsuite fallout, I
    added the check (as the comment there says, realizing it can't be quite
    right) without re-testing on the real binary. Which (of course) ends up
    with all broken debug info. Which in turn has become easily noticable in
    2.47 due to bfd118583ed6 ("Add --debug-dir option to readelf and objdump.
    Load separate debug info files when disassemblng."), resulting in warnings
    from objdump doing disassembly of the resulting binary (which is part of
    the overall build process there).
    
    The issues spotted by the testsuite (many actually went silently [visible
    only when inspecting ld.log], due to overly lax expectations) need dealing
    with differently: Like done in the "if()" corresponding to the enclosing
    "else" here, special treatment of calls from underneath
    bfd_simple_get_relocated_section_contents() is necessary.

Diff:
---
 bfd/reloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/bfd/reloc.c b/bfd/reloc.c
index 6b9e00da5d6..f49c1972b9b 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8148,8 +8148,9 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
 	    {
 	      if ((symbol->flags & BSF_SECTION_SYM)
 		  && symbol->section->sec_info_type == SEC_INFO_TYPE_MERGE
-		  /* This, while apparently necessary, feels bogus.  */
-		  && !(symbol->section->flags & SEC_DEBUGGING))
+		  /* bfd_simple_get_relocated_section_contents() is special.  */
+		  && (!(input_section->flags & SEC_DEBUGGING)
+		      || link_info->input_bfds != link_info->output_bfd))
 		{
 		  asection *sec = symbol->section;


More information about the Binutils-cvs mailing list