diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-08-01 07:26:20 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-08-04 05:07:42 -0700 |
commit | f897689c880ed1049b708e6c1f9745c8604808e3 (patch) | |
tree | 7ed28cb0d032325e8d8d00704dddf391bff9c131 /ld | |
parent | 6a7ee0010e63a3eac4c58c48f2484a0fafdb7d2e (diff) | |
download | fsf-binutils-gdb-f897689c880ed1049b708e6c1f9745c8604808e3.zip fsf-binutils-gdb-f897689c880ed1049b708e6c1f9745c8604808e3.tar.gz fsf-binutils-gdb-f897689c880ed1049b708e6c1f9745c8604808e3.tar.bz2 |
elf: Treat undefined version as hidden
Since undefined version can't be used to resolve any references without
the original definition, treat it as hidden.
bfd/
PR binutils/28158
* elf.c (_bfd_elf_get_symbol_version_string): Treat undefined
version as hidden.
ld/
PR binutils/28158
* testsuite/ld-elf/linux-x86.exp: Run PR binutils/28158 tests.
* testsuite/ld-elf/pr28158-1.c: New file.
* testsuite/ld-elf/pr28158-2.S: Likewise.
* testsuite/ld-elf/pr28158.nd: Likewise.
* testsuite/ld-elf/pr28158.rd: Likewise.
* testsuite/ld-elf/pr28158.t: Likewise.
* testsuite/ld-elfvers/vers2.dsym: Updated.
* testsuite/ld-elfvers/vers3.dsym: Likewise.
* testsuite/ld-elfvers/vers6.dsym: Likewise.
* testsuite/ld-elfvers/vers19.dsym: Likewise.
* testsuite/ld-elfvers/vers22.dsym: Likewise.
* testsuite/ld-elfvers/vers23.dsym: Likewise.
* testsuite/ld-elfvers/vers23d.dsym: Likewise.
* testsuite/ld-elfvers/vers27d4.dsym: Likewise.
* testsuite/ld-elfvers/vers28c.dsym: Likewise.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-elf/linux-x86.exp | 17 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr28158-1.c | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr28158-2.S | 16 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr28158.nd | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr28158.rd | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr28158.t | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers19.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers2.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers22.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers23.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers23d.dsym | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers27d4.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers28c.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers3.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfvers/vers6.dsym | 6 |
15 files changed, 62 insertions, 12 deletions
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index 8192374..ee03b56 100644 --- a/ld/testsuite/ld-elf/linux-x86.exp +++ b/ld/testsuite/ld-elf/linux-x86.exp @@ -117,6 +117,23 @@ run_cc_link_tests [list \ {{readelf -rn indirect-extern-access-3.rd}} \ "indirect-extern-access-2b" \ ] \ + [list \ + "Build pr28158.so" \ + "-shared -Wl,-version-script,pr27128.t" \ + "-fPIC" \ + { pr28158-1.c } \ + {} \ + "pr28158.so" \ + ] \ + [list \ + "Build pr28158" \ + "$NOPIE_LDFLAGS -Wl,--no-as-needed \ + tmpdir/pr28158.so" \ + "" \ + { pr28158-2.S } \ + {{readelf {--dyn-syms -W} pr28158.rd} {nm -D pr28158.nd}} \ + "pr28158" \ + ] \ ] run_ld_link_exec_tests [list \ diff --git a/ld/testsuite/ld-elf/pr28158-1.c b/ld/testsuite/ld-elf/pr28158-1.c new file mode 100644 index 0000000..2bc87d0 --- /dev/null +++ b/ld/testsuite/ld-elf/pr28158-1.c @@ -0,0 +1 @@ +int foo = 0; diff --git a/ld/testsuite/ld-elf/pr28158-2.S b/ld/testsuite/ld-elf/pr28158-2.S new file mode 100644 index 0000000..4e703b2 --- /dev/null +++ b/ld/testsuite/ld-elf/pr28158-2.S @@ -0,0 +1,16 @@ + .text + .section .text.startup,"ax",@progbits + .p2align 4 + .globl main + .type main, @function +main: + .cfi_startproc +#ifdef __x86_64__ + movl foo(%rip), %eax +#else + movl foo, %eax +#endif + ret + .cfi_endproc + .size main, .-main + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-elf/pr28158.nd b/ld/testsuite/ld-elf/pr28158.nd new file mode 100644 index 0000000..3b1a9bc --- /dev/null +++ b/ld/testsuite/ld-elf/pr28158.nd @@ -0,0 +1,3 @@ +#... +[0-9a-z]+ B foo@VERS_2.0 +#pass diff --git a/ld/testsuite/ld-elf/pr28158.rd b/ld/testsuite/ld-elf/pr28158.rd new file mode 100644 index 0000000..7488410 --- /dev/null +++ b/ld/testsuite/ld-elf/pr28158.rd @@ -0,0 +1,7 @@ +#ld: -shared -version-script pr27128.t +#readelf: --dyn-syms --wide +#target: x86_64-*-linux* i?86-*-linux-gnu + +#... + +[0-9]+: +[0-9a-f]+ +[0-9]+ +OBJECT +GLOBAL +DEFAULT +[1-9]+ foo@VERS_2.0 \(2\) +#pass diff --git a/ld/testsuite/ld-elf/pr28158.t b/ld/testsuite/ld-elf/pr28158.t new file mode 100644 index 0000000..2b82842 --- /dev/null +++ b/ld/testsuite/ld-elf/pr28158.t @@ -0,0 +1,6 @@ +VERS_2.0 { +global: + foo; +local: + *; +}; diff --git a/ld/testsuite/ld-elfvers/vers19.dsym b/ld/testsuite/ld-elfvers/vers19.dsym index a77f949..798466f 100644 --- a/ld/testsuite/ld-elfvers/vers19.dsym +++ b/ld/testsuite/ld-elfvers/vers19.dsym @@ -1 +1 @@ -[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_2\.0\) +(0x[0-9a-f]+ )?_?show_foo diff --git a/ld/testsuite/ld-elfvers/vers2.dsym b/ld/testsuite/ld-elfvers/vers2.dsym index 30ba91b..f820fdc 100644 --- a/ld/testsuite/ld-elfvers/vers2.dsym +++ b/ld/testsuite/ld-elfvers/vers2.dsym @@ -1,3 +1,3 @@ -[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_2\.0\) +(0x[0-9a-f]+ )?_?show_foo 0+ g +DO \*ABS\* 0+ +VERS_XXX_1\.1 VERS_XXX_1\.1 [0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+ +VERS_XXX_1\.1 (0x[0-9a-f]+ )?_?show_xyzzy diff --git a/ld/testsuite/ld-elfvers/vers22.dsym b/ld/testsuite/ld-elfvers/vers22.dsym index db2aeec..65a1833 100644 --- a/ld/testsuite/ld-elfvers/vers22.dsym +++ b/ld/testsuite/ld-elfvers/vers22.dsym @@ -1 +1 @@ -[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +VERS\.0 +(0x[0-9a-f]+ )?_?bar +[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +\(VERS\.0\) +(0x[0-9a-f]+ )?_?bar diff --git a/ld/testsuite/ld-elfvers/vers23.dsym b/ld/testsuite/ld-elfvers/vers23.dsym index dfd6a33..d6c93b4 100644 --- a/ld/testsuite/ld-elfvers/vers23.dsym +++ b/ld/testsuite/ld-elfvers/vers23.dsym @@ -1 +1 @@ -[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +VERS\.0 +(0x[0-9a-f]+ )?_?foo +[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +\(VERS\.0\) +(0x[0-9a-f]+ )?_?foo diff --git a/ld/testsuite/ld-elfvers/vers23d.dsym b/ld/testsuite/ld-elfvers/vers23d.dsym index ab5fbd8..12f8c59 100644 --- a/ld/testsuite/ld-elfvers/vers23d.dsym +++ b/ld/testsuite/ld-elfvers/vers23d.dsym @@ -1,2 +1,2 @@ -[0-9a-f]* DF \*UND\* [0-9a-f]* VERS.0 (0x[0-9a-f][0-9a-f] )?_?bar -[0-9a-f]* DF \*UND\* [0-9a-f]* VERS.0 (0x[0-9a-f][0-9a-f] )?_?foo +[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +\(VERS\.0\) +(0x[0-9a-f]+ )?_?bar +[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +\(VERS\.0\) +(0x[0-9a-f]+ )?_?foo diff --git a/ld/testsuite/ld-elfvers/vers27d4.dsym b/ld/testsuite/ld-elfvers/vers27d4.dsym index dfd6a33..d6c93b4 100644 --- a/ld/testsuite/ld-elfvers/vers27d4.dsym +++ b/ld/testsuite/ld-elfvers/vers27d4.dsym @@ -1 +1 @@ -[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +VERS\.0 +(0x[0-9a-f]+ )?_?foo +[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +\(VERS\.0\) +(0x[0-9a-f]+ )?_?foo diff --git a/ld/testsuite/ld-elfvers/vers28c.dsym b/ld/testsuite/ld-elfvers/vers28c.dsym index 7ad5678..a575eff 100644 --- a/ld/testsuite/ld-elfvers/vers28c.dsym +++ b/ld/testsuite/ld-elfvers/vers28c.dsym @@ -1 +1 @@ -[0-9a-f]+[ ]+DF[ ]+\*UND\*[ ]+[0-9a-f]+[ ]+VERS\.0[ ]+(0x[0-9a-f]+ )?_?foo +[0-9a-f]+[ ]+DF[ ]+\*UND\*[ ]+[0-9a-f]+[ ]+\(VERS\.0\)[ ]+(0x[0-9a-f]+ )?_?foo diff --git a/ld/testsuite/ld-elfvers/vers3.dsym b/ld/testsuite/ld-elfvers/vers3.dsym index a77f949..798466f 100644 --- a/ld/testsuite/ld-elfvers/vers3.dsym +++ b/ld/testsuite/ld-elfvers/vers3.dsym @@ -1 +1 @@ -[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_2\.0\) +(0x[0-9a-f]+ )?_?show_foo diff --git a/ld/testsuite/ld-elfvers/vers6.dsym b/ld/testsuite/ld-elfvers/vers6.dsym index a5a8053..6d07312 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]+ +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 +[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 |