https://sourceware.org/bugzilla/show_bug.cgi?id=33577

--- Comment #51 from Michael Matz <matz at suse dot de> ---
So the below would revert the questionable behaviour, i.e. return back to
generating version index VER_NDX_GLOBAL for defined global symbols (using index
0 for undefined symbols, the point of this bug report, remains unchanged).

To not regress the testsuite as is, it would also need reversion of
2be0f2da ("readelf: Display the base symbol version as empty string")
that always prints "foo@" for VER_NDX_GLOBAL symbols.  That could also be done
by adjusting some of the testcases to accept that syntax.

---
    Use version index 1 for defined symbols

    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.

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to