[PATCH] Gold: Treat symbols with version index 0 as unversioned

Cary Coutant ccoutant@gmail.com
Mon Nov 17 07:26:29 GMT 2025
> 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


More information about the Binutils mailing list