PR26002 undefined symbol VER_NDX_GLOBAL vs. VER_NDX_LOCAL
authorAlan Modra <amodra@gmail.com>
Fri, 15 Jan 2021 10:47:43 +0000 (21:17 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 16 Jan 2021 00:41:51 +0000 (11:11 +1030)
This patch makes undefined unversioned dynamic symbols use
VER_NDX_GLOBAL (version 1) rather than VER_NDX_LOCAL (version 0).
There really isn't much use for an undefined local dynamic symbol, so
we may as well use the logically correct value in .gnu.version.
https://docs.oracle.com/cd/E26505_01/html/E26506/chapter6-54676.html

bfd/
PR 26002
* elflink.c (elf_link_output_extsym): Use version 1 in
.gnu.version for undefined unversioned symbols.
ld/
PR 26002
* testsuite/ld-elfvers/vers6.dsym: Expect "Base" for undefined
unversioned symbols.
* testsuite/ld-elfvers/vers16.dsym: Likewise.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-elfvers/vers16.dsym
ld/testsuite/ld-elfvers/vers6.dsym

index 3ff16684c6126b9efbd9069e42367f24f2aa590c..d3282a3defbbd356f41d5db0a228ae2ef838c523 100644 (file)
@@ -1,3 +1,9 @@
+2021-01-16  Alan Modra  <amodra@gmail.com>
+
+       PR 26002
+       * elflink.c (elf_link_output_extsym): Use version 1 in
+       .gnu.version for undefined unversioned symbols.
+
 2021-01-15  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfnn-riscv.c (riscv_relax_delete_bytes): Fixed the indent that
index d20857eb6bd063ed60122d526e69b7ab7f32ce4c..8794864f54cb50fa79b970a62e871fdd4511af81 100644 (file)
@@ -10568,7 +10568,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
              if (h->verinfo.verdef == NULL
                  || (elf_dyn_lib_class (h->verinfo.verdef->vd_bfd)
                      & (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED)))
-               iversym.vs_vers = 0;
+               iversym.vs_vers = 1;
              else
                iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1;
            }
index 5a0f07f22652427106adb15cc43a5e315a4bc7c1..c412eb64c67d5ba04ef2f6e691dbcdfff1348a83 100644 (file)
@@ -1,3 +1,10 @@
+2021-01-16  Alan Modra  <amodra@gmail.com>
+
+       PR 26002
+       * testsuite/ld-elfvers/vers6.dsym: Expect "Base" for undefined
+       unversioned symbols.
+       * testsuite/ld-elfvers/vers16.dsym: Likewise.
+
 2021-01-15  Nelson Chu  <nelson.chu@sifive.com>
 
        * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
index 8ee491879249dd2a24e01af9753c42916142d9e8..cc0c4e11d930af91adb0f91075ba4cf3c13f612e 100644 (file)
@@ -1,2 +1,2 @@
 [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
+[0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +Base +(0x[0-9a-f]+ )?_?show_foo
index a53099bbedb4d19c79d69be74cd80505577a3f78..a5a805377ca519f7dbbb2a20a64aa2b6740e9617 100644 (file)
@@ -1,4 +1,4 @@
-[0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_foo
+[0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +Base +(0x[0-9a-f]+ )?_?show_foo
 [0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +VERS_2.0 +(0x[0-9a-f]+ )?_?show_foo
 [0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +VERS_1.2 +(0x[0-9a-f]+ )?_?show_foo
 [0-9a-f]+ +DF \*UND\*  [0-9a-f]+ +VERS_1.1 +(0x[0-9a-f]+ )?_?show_foo