[PATCH] Gold: Treat symbols with version index 0 as unversioned
H.J. Lu
hjl.tools@gmail.com
Mon Nov 17 22:16:57 GMT 2025
On Mon, Nov 17, 2025 at 3:26 PM Cary Coutant <ccoutant@gmail.com> wrote:
>
> > 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.
>
> @@ -1634,17 +1634,9 @@ Symbol_table::add_from_dynobj(
>
> // The Sun documentation says that V can be VER_NDX_LOCAL,
> // or VER_NDX_GLOBAL, or a version index. The meaning of
> - // VER_NDX_LOCAL is defined as "Symbol has local scope."
> - // The old GNU linker will happily generate VER_NDX_LOCAL
> - // for an undefined symbol. I don't know what the Sun
> - // linker will generate.
> -
> - if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
> - && st_shndx != elfcpp::SHN_UNDEF)
> - {
> - // This symbol should not be visible outside the object.
> - continue;
> - }
> + // VER_NDX_LOCAL means that symbol is a local dynamic symbol
> + // or an unversioned global/weak symbol which is defined or
> + // undefined.
>
> Move this comment down to just before the next block of code, beginning with:
>
> if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
> || v == static_cast<unsigned int>(elfcpp::VER_NDX_GLOBAL))
>
> OK with that change.
>
> -cary
This is what I checked in.
Thanks.
--
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: 14927 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20251118/04971482/attachment-0001.bin>
More information about the Binutils
mailing list