[0/3] Revert to using version index 1

Michael Matz matz@suse.de
Thu Nov 20 15:29:27 GMT 2025


Hello,

[here's three patches that try to fix some of the recent version index 
breakage.  I'd like to get approval for 1+2, but see below for why there 
are three.]

Defined unversioned symbols certainly can use VER_NDX_GLOBAL (1) as their 
version index.  There are different opinions if VER_NDX_LOCAL (0) should 
be usable for those as well, but many tools don't expect that, as in: link 
editors don't resolve against those (ld.bfd being an exception).

So, no matter the opinions, the change from NDX_GLOBAL to NDX_LOCAL for 
defined symbols causes real-world breakage.  It also has no precedent, as 
the reason for this change was a bug report about inconsistency for 
_undefined_ symbols vis Solaris.

IMO it's reasonable to continue using the value 0 for undefined symbols 
(when the reference itself wasn't versioned); it increases consistency 
with other OSes and doesn't hurt existing infrastructure.  (I do think 
value 1 is reasonable as well, FWIW)

So, to that end the first patch makes it so that NDX_GLOBAL is again 
generated for defined, global unversioned symbols.  It leaves alone the 
NDX_LOCAL for undefined syms.

In connection to all the above readelf was also changed to print 'foo@@' 
for normal unversioned defined exported symbols (those using NDX_GLOBAL).  
I think that's harmful, as the symbol to resolve against (and hence what 
users will try to look up when investigating stuff) is named 'foo', not 
anything else.  It's also very peculiar and not what other readelfs do.

To that end the second patch reverts that part of 2be0f2da, but again only 
for NDX_GLOBAL.  I.e. for symbols with a hidden unnamed version we 
continue printing 'foo@', which seems useful as an indication of something 
special going on (in particular a reference to 'foo' can not be resolve by 
such symbol).

I really really want to have that second patch in as well.  But just in 
case the decision is that readelf should indeed continue to print 'foo@@' 
for normal symbols then patch three is there to fix testsuite fallout from 
the first patch.

I've tested the combination 1+2 and 1+2+3 on x86_64-linux on 155 targets 
without regressions.  Okay for 1+2, please? :)



Michael Matz (3):
  Use version index 1 for defined symbols
  Make readelf not print 'foo@@' for normal symbols
  Adjust testcases for readelf printing 'foo@@'

 bfd/elflink.c                             | 8 +-------
 binutils/readelf.c                        | 4 ++--
 ld/testsuite/ld-elf/pr23161b.rd           | 6 +++---
 ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd | 4 ++--
 ld/testsuite/ld-elf/pr28348.rd            | 2 +-
 ld/testsuite/ld-elf/pr33599.d             | 2 +-
 ld/testsuite/ld-elfvers/vers16.dsym       | 2 +-
 ld/testsuite/ld-ifunc/pr23169a.rd         | 2 +-
 ld/testsuite/ld-ifunc/pr23169b.rd         | 2 +-
 ld/testsuite/ld-ifunc/pr23169c.rd         | 2 +-
 ld/testsuite/ld-plugin/pr22983.1.d        | 2 +-
 ld/testsuite/ld-plugin/pr22983.2.d        | 2 +-
 ld/testsuite/ld-plugin/pr22983.3.d        | 2 +-
 ld/testsuite/ld-plugin/pr22983.4.d        | 2 +-
 14 files changed, 18 insertions(+), 24 deletions(-)

-- 
2.48.1


More information about the Binutils mailing list