[binutils-gdb/binutils-2_30-branch] x86: Don't set eh->local_ref to 1 for versioned symbol
H.J.Lu
hjl@sourceware.org
Mon May 21 15:53:00 GMT 2018
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=88193e0fdef1646fec917bd1ebd1f1049cae660e
commit 88193e0fdef1646fec917bd1ebd1f1049cae660e
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri May 18 14:23:41 2018 -0700
x86: Don't set eh->local_ref to 1 for versioned symbol
bfd_hide_sym_by_version can't be used to check if a versioned symbol is
hidden. It has to be synced with _bfd_elf_link_assign_sym_version to
get the correct answer.
bfd/
PR ld/23194
* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
set eh->local_ref to 1 if a symbol is versioned and there is a
version script.
ld/
PR ld/23194
* testsuite/ld-i386/i386.exp: Run pr23194.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23194.d: New file.
* testsuite/ld-i386/pr23194.map: Likewise.
* testsuite/ld-i386/pr23194.s: Likewise.
* testsuite/ld-x86-64/pr23194.d: Likewise.
* testsuite/ld-x86-64/pr23194.map: Likewise.
* testsuite/ld-x86-64/pr23194.s: Likewise.
(cherry picked from commit 97373b2eba6077d5059370a95931b93a8b118813)
Diff:
---
bfd/ChangeLog | 7 +++++++
bfd/elfxx-x86.c | 7 +++++--
ld/ChangeLog | 12 ++++++++++++
ld/testsuite/ld-i386/i386.exp | 1 +
ld/testsuite/ld-i386/pr23194.d | 7 +++++++
ld/testsuite/ld-i386/pr23194.map | 6 ++++++
ld/testsuite/ld-i386/pr23194.s | 12 ++++++++++++
ld/testsuite/ld-x86-64/pr23194.d | 7 +++++++
ld/testsuite/ld-x86-64/pr23194.map | 6 ++++++
ld/testsuite/ld-x86-64/pr23194.s | 12 ++++++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 1 +
11 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c491ed7..c776c02 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/23194
+ * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
+ set eh->local_ref to 1 if a symbol is versioned and there is a
+ version script.
+
+2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/23189
* elf32-i386.c (elf_i386_relocate_section): Handle R_386_GOT32X
like R_386_GOT32.
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 8f0523d..b7edcde 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -1967,8 +1967,11 @@ _bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
}
/* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
- script aren't forced local here yet. */
- if (!h->root.ldscript_def)
+ script aren't forced local here yet. bfd_hide_sym_by_version
+ can't be used to check if a versioned symbol is hidden. It has to
+ be syncd with _bfd_elf_link_assign_sym_version to get the correct
+ answer. */
+ if (!h->root.ldscript_def && h->versioned == unversioned)
eh->local_ref = 1;
return FALSE;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 5460921..f866d97 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,17 @@
2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/23194
+ * testsuite/ld-i386/i386.exp: Run pr23194.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+ * testsuite/ld-i386/pr23194.d: New file.
+ * testsuite/ld-i386/pr23194.map: Likewise.
+ * testsuite/ld-i386/pr23194.s: Likewise.
+ * testsuite/ld-x86-64/pr23194.d: Likewise.
+ * testsuite/ld-x86-64/pr23194.map: Likewise.
+ * testsuite/ld-x86-64/pr23194.s: Likewise.
+
+2018-05-21 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/23189
* testsuite/ld-i386/i386.exp: Run pr23189.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index b01ab26..22f377e 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -452,6 +452,7 @@ run_dump_test "pr22115-1d"
run_dump_test "pr22135"
run_dump_test "pr22782"
run_dump_test "pr23189"
+run_dump_test "pr23194"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr23194.d b/ld/testsuite/ld-i386/pr23194.d
new file mode 100644
index 0000000..b5e8c33
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr23194.d
@@ -0,0 +1,7 @@
+#as: --32 -mrelax-relocations=yes
+#ld: -shared -melf_i386 --version-script pr23194.map
+#readelf: -r --wide
+
+Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
+ Offset Info Type Sym. Value Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
diff --git a/ld/testsuite/ld-i386/pr23194.map b/ld/testsuite/ld-i386/pr23194.map
new file mode 100644
index 0000000..353c194
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr23194.map
@@ -0,0 +1,6 @@
+FOO {
+ global:
+ bar;
+ local:
+ *;
+};
diff --git a/ld/testsuite/ld-i386/pr23194.s b/ld/testsuite/ld-i386/pr23194.s
new file mode 100644
index 0000000..32693fe
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr23194.s
@@ -0,0 +1,12 @@
+ .text
+ .symver foo,foo@FOO
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl bar
+ .type bar, @function
+bar:
+ jmp *foo@GOT(%eax)
+ .size bar, .-bar
diff --git a/ld/testsuite/ld-x86-64/pr23194.d b/ld/testsuite/ld-x86-64/pr23194.d
new file mode 100644
index 0000000..6b12060
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23194.d
@@ -0,0 +1,7 @@
+#as: --64 -mrelax-relocations=yes
+#ld: -shared -melf_x86_64 --version-script pr23194.map
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
+ Offset Info Type Symbol's Value Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr23194.map b/ld/testsuite/ld-x86-64/pr23194.map
new file mode 100644
index 0000000..353c194
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23194.map
@@ -0,0 +1,6 @@
+FOO {
+ global:
+ bar;
+ local:
+ *;
+};
diff --git a/ld/testsuite/ld-x86-64/pr23194.s b/ld/testsuite/ld-x86-64/pr23194.s
new file mode 100644
index 0000000..277c19d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23194.s
@@ -0,0 +1,12 @@
+ .text
+ .symver foo,foo@FOO
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl bar
+ .type bar, @function
+bar:
+ jmp *foo@GOTPCREL(%rip)
+ .size bar, .-bar
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 9632a90..f128bd3 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -382,6 +382,7 @@ run_dump_test "pr22135"
run_dump_test "pr22782a"
run_dump_test "pr22782b"
run_dump_test "pr23189"
+run_dump_test "pr23194"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return
More information about the Binutils-cvs
mailing list