]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd: generalize _bfd_elf_merge_sections()
authorJan Beulich <jbeulich@suse.com>
Fri, 24 Oct 2025 13:11:11 +0000 (15:11 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Oct 2025 13:11:11 +0000 (15:11 +0200)
commit810b19952d5d89405c80b468ba5182a5319dbb3e
tree38491f6284149c62c4aa22787344af3b409cc687
parent1e1701c4d81a50183875d9431587790ff0acfc8a
bfd: generalize _bfd_elf_merge_sections()

Except for the ELF class check, which isn't needed anymore when the
generic linker knows how to deal with SEC_MERGE sections, there isn't
anything substantially ELF-specific left in the function.

This also eliminates the need for the "remove_hook" callback.

As a result, section merging itself now works for mixed-class ELF input
objects (issues with dropping of symbols and relocations that were there
before for such cases remain present, though), i.e. the PR ld/19013
testcases need adjusting accordingly: Both now expect identical .rodata
contents. While making the change, add another line of expected output,
to properly match after "#...". Else a mismatch on the important line
isn't properly visible in ld.log.

In set_symbol_from_hash() additionally set BSF_GLOBAL when dealing with a
defined symbol. Without that the if() body ahead of the one being added to
default_indirect_link_order() would not be entered once previously
undefined symbols become defined (suggesting that there is a pre-existing
issue there).
12 files changed:
bfd/bfd-in2.h
bfd/elf-bfd.h
bfd/elflink.c
bfd/elfxx-target.h
bfd/libbfd-in.h
bfd/libbfd.h
bfd/linker.c
bfd/merge.c
bfd/reloc.c
bfd/syms.c
ld/testsuite/ld-x86-64/pr19013-x32.d
ld/testsuite/ld-x86-64/pr19013.d