[PATCH] Gold: Treat symbols with version index 0 as unversioned
H.J. Lu
hjl.tools@gmail.com
Fri Nov 14 23:44:57 GMT 2025
Oracle Solaris 11.4 Linker and Libraries Guide:
https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/linkers
-libraries/version-symbol-section.html
defines VER_NDX_LOCAL to 0 with a comment, "Symbol has local scope". This
leads to different interpretations by different linker implementations.
However Solaris as well as ld and ld.so in glibc always treat symbols
with version index 0 as unversioned symbols, defined or undefined, with
global visibility. As discussed in
https://sourceware.org/bugzilla/show_bug.cgi?id=33577
in hindsight, VER_NDX_NONE might be a better name. Ali from Oracle is
working on clarifying what version index 0 really means for unversioned
symbols, defined or undefined, with global visibility. In the meantime,
update gold to treat symbols with version index 0 as unversioned without
making them a local symbol.
elfcpp/
PR gold/33577
* elfcpp.h (VER_NDX_LOCAL): Update comments.
(VER_NDX_GLOBAL): Likewise.
gold/
PR gold/33577
* dynobj.cc (Versions::symbol_section_contents): Set unversioned
symbol version index to VER_NDX_LOCAL.
* symtab.cc (Symbol_table::add_from_dynobj): Don't check
VER_NDX_LOCAL.
* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_pr33577.sh.
(check_DATA): Add ver_test_pr33577a.syms and
ver_test_pr33577b.syms.
(ver_test_pr33577a.syms): New rule.
(ver_test_pr33577.so): Likewise.
(ver_test_pr33577b.syms): Likewise.
(ver_test_pr33577): Likewise.
* testsuite/Makefile.in: Regenerated.
* testsuite/ver_matching_test.sh: Updated to checking missing
Base version.
* testsuite/ver_test_14.sh (check_missing): New.
Updated to check missing Base version.
* testsuite/ver_test_pr33577.sh: New fille.
* testsuite/ver_test_pr33577a.c: Likewise.
* testsuite/ver_test_pr33577b.c: Likewise.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Gold-Treat-symbols-with-version-index-0-as-unversion.patch
Type: text/x-patch
Size: 14632 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20251115/e5268179/attachment-0001.bin>
More information about the Binutils
mailing list