[1/3] Use version index 1 for defined symbols
Michael Matz
matz@suse.de
Thu Nov 20 15:30:17 GMT 2025
It's reasonable to use version index 0 for undefined
symbols, so let's continue doing that. For defined (global)
symbols that aren't otherwise versioned continue using
VER_NDX_GLOBAL (partly reverting behaviour introduced in
commit f685e395).
bfd/
PR ld/33577
* elflink.c (elf_link_output_extsym): Don't set noversion
for defined syms.
ld/
PR ld/33577
* ld-elfvers/vers16.dsym: Add back the "Base" version for
defined syms.
---
I got approval for this on in bugzilla, but as there are relations to a
readelf change I'll make this part of the whole series.
---
bfd/elflink.c | 8 +-------
ld/testsuite/ld-elfvers/vers16.dsym | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ec3ad9735fe..7d284c08c00 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11158,13 +11158,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
else
{
if (h->verinfo.vertree == NULL)
- {
- iversym.vs_vers = 1;
- if (elf_tdata (flinfo->output_bfd)->cverdefs == 0)
- /* Defined symbol has no version if there is no
- linker version script. */
- noversion = true;
- }
+ iversym.vs_vers = 1;
else
iversym.vs_vers = h->verinfo.vertree->vernum + 1;
if (flinfo->info->create_default_symver)
diff --git a/ld/testsuite/ld-elfvers/vers16.dsym b/ld/testsuite/ld-elfvers/vers16.dsym
index 076d0eb07ed..a32abd7aad9 100644
--- a/ld/testsuite/ld-elfvers/vers16.dsym
+++ b/ld/testsuite/ld-elfvers/vers16.dsym
@@ -1,2 +1,2 @@
-[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_bar
+[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+( +Base +)? +(0x[0-9a-f]+ )?_?show_bar
[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_foo
--
2.48.1
More information about the Binutils
mailing list