[binutils-gdb] Make readelf not print 'foo@@' for normal symbols

Michael Matz matz@sourceware.org
Mon Nov 24 14:33:48 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=365cf9bd156c5676cf289b695460fda5c69ceb60

commit 365cf9bd156c5676cf289b695460fda5c69ceb60
Author: Michael Matz <matz@suse.de>
Date:   Thu Nov 20 15:30:50 2025 +0100

    Make readelf not print 'foo@@' for normal symbols
    
    when a symbol 'foo' is exported and non-hidden and hence is
    available for resolving from other objects it's unreasonable
    for readelf to print it as 'foo@@'.  If it's not available
    for unversioned resolving because its version is hidden
    (but without name), then continue printing it as 'foo@' to
    indicate that something special goes on.

Diff:
---
 binutils/readelf.c            | 4 ++--
 ld/testsuite/ld-elf/pr33599.d | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 633453ae2b2..425b7b78653 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -14500,8 +14500,8 @@ get_symbol_version_string (Filedata *filedata,
   *sym_info = (vers_data & VERSYM_HIDDEN) != 0 ? symbol_hidden : symbol_public;
   max_vd_ndx = 0;
 
-  /* Return the empty string for the base version.  */
-  if ((vers_data & VERSYM_VERSION) == VERSYM_BASE)
+  /* Return the empty string for the hidden base version.  */
+  if (vers_data == (VERSYM_HIDDEN | VERSYM_BASE))
     return "";
 
   /* Usually we'd only see verdef for defined symbols, and verneed for
diff --git a/ld/testsuite/ld-elf/pr33599.d b/ld/testsuite/ld-elf/pr33599.d
index 9a06427aca2..f3aee6eb114 100644
--- a/ld/testsuite/ld-elf/pr33599.d
+++ b/ld/testsuite/ld-elf/pr33599.d
@@ -5,7 +5,7 @@
 
 Symbol table '\.dynsym' contains [0-9]+ entries:
 #...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +bar@@
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +bar
 #...
  +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo@
 #pass


More information about the Binutils-cvs mailing list