[PATCH] elf: Properly place base symbols in DT_GNU_HASH and DT_HASH
H.J. Lu
hjl.tools@gmail.com
Fri Nov 28 00:48:43 GMT 2025
The base symbol, a symbol with the empty version string, created by
asm (".symver foo_base, foo@");
is used to provide a compatibility symbol in a versioned shared library
for binaries linked against the previous unversioned shared library.
The dynamic linker will pick the first match to resolve the unversioned
symbol reference. If the newest version, VERS_1,
asm (".symver foo_v1, foo@@VERS_1");
is picked before the base symbol in DT_GNU_HASH and DT_HASH, foo@@VERS_1,
instead of foo@, will be used to resolve the unversioned reference.
Properly place base symbols in DT_GNU_HASH and DT_HASH so that they will
be picked first.
bfd/
PR ld/33673
* elf-bfd.h (elf_link_hash_entry): Add base_symbol.
* elflink.c (_bfd_elf_merge_symbol): Set base_symbol if the
version string is empty.
(collect_gnu_hash_codes): Add base_symbol.
(elf_gnu_hash_process_symidx): Skip if base symbol doesn't match.
(bfd_elf_size_dynsym_hash_dynstr): Output base symbols first in
DT_GNU_HASH.
(elf_outext_info): Add base_symbol.
(elf_link_output_extsym): Skip if base symbol doesn't match.
(_bfd_elf_final_link): Output base symbols last in DT_HASH.
ld/
PR ld/33673
* ld-elfvers/vers.exp (base_symbol_test): Run PR ld/33673 tests.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-elf-Properly-place-base-symbols-in-DT_GNU_HASH-and-D.patch
Type: text/x-patch
Size: 8131 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20251128/3c4c95b4/attachment.bin>
More information about the Binutils
mailing list