From: Alan Modra Date: Fri, 15 Jan 2021 10:47:43 +0000 (+1030) Subject: PR26002 undefined symbol VER_NDX_GLOBAL vs. VER_NDX_LOCAL X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb6e6af8c17a8f4e120d79cb5f2451ebe60aaf4e;p=binutils-gdb.git PR26002 undefined symbol VER_NDX_GLOBAL vs. VER_NDX_LOCAL 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3ff16684c61..d3282a3defb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-01-16 Alan Modra + + PR 26002 + * elflink.c (elf_link_output_extsym): Use version 1 in + .gnu.version for undefined unversioned symbols. + 2021-01-15 Nelson Chu * elfnn-riscv.c (riscv_relax_delete_bytes): Fixed the indent that diff --git a/bfd/elflink.c b/bfd/elflink.c index d20857eb6bd..8794864f54c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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; } diff --git a/ld/ChangeLog b/ld/ChangeLog index 5a0f07f2265..c412eb64c67 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2021-01-16 Alan Modra + + PR 26002 + * testsuite/ld-elfvers/vers6.dsym: Expect "Base" for undefined + unversioned symbols. + * testsuite/ld-elfvers/vers16.dsym: Likewise. + 2021-01-15 Nelson Chu * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated. diff --git a/ld/testsuite/ld-elfvers/vers16.dsym b/ld/testsuite/ld-elfvers/vers16.dsym index 8ee49187924..cc0c4e11d93 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]+( +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 diff --git a/ld/testsuite/ld-elfvers/vers6.dsym b/ld/testsuite/ld-elfvers/vers6.dsym index a53099bbedb..a5a805377ca 100644 --- a/ld/testsuite/ld-elfvers/vers6.dsym +++ b/ld/testsuite/ld-elfvers/vers6.dsym @@ -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