[PATCH] Gold: Treat symbols with version index 0 as unversioned
H.J. Lu
hjl.tools@gmail.com
Mon Nov 17 22:04:54 GMT 2025
On Mon, Nov 17, 2025 at 11:02 PM Michael Matz <matz@suse.de> wrote:
>
> Hello,
>
> On Sat, 15 Nov 2025, H.J. Lu wrote:
>
> > 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.
>
> Hmm? I don't think that's what he's saying. PR33577 was specifically
> about how NDX_LOCAL should be valid (and sensible) for _undefined_
> symbols. The only mentions of defined symbols related to the problems at
> hand was https://sourceware.org/bugzilla/show_bug.cgi?id=33577#c5:
>
> ...
> - Symbols that are not versioned are given version index 0. These can
> be either definitions, or external references.
>
> - The BASE version, which has index 1, is the version that holds the
> symbols defined by the object itself, that have not otherwise been
> assigned to a different version, possibly with a linker script.
> By convention, the version is given the SONAME of the object. This
> is a VERDEF, so external references don't belong here.
> ...
>
> So, sure, index 0 _can_ be used for defined symbols. But I can't see how
> they then can used for resolving. If they could, then there'd be an
> internal inconsistency in the above two items: symbols defined in an
> object (and that don't have a version otherwise), are to use index 1. So,
> for index 0 to be used the symbol in question must be (a) unversioned and
> (b) not be defined (in the sense of being available to resolve against)
> by the object (lest it had index 1).
>
> So, no, I don't think you should resolve against defined symbols with
> NDX_LOCAL. They have, as stated everywhere, local scope.
>
The key point is that VER_NDX_LOCAL doesn't change symbol
binding which is determined by the st_other field as implemented
by ld and ld.so in glibc.
--
H.J.
More information about the Binutils
mailing list