]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Don't set eh->local_ref to 1 for versioned symbol
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 18 May 2018 21:23:41 +0000 (14:23 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 18 May 2018 21:34:49 +0000 (14:34 -0700)
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.

bfd/ChangeLog
bfd/elfxx-x86.c
ld/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr23194.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr23194.map [new file with mode: 0644]
ld/testsuite/ld-i386/pr23194.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr23194.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr23194.map [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr23194.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index cc8773cb144597218fa6a6af7ccccb6056de8c30..bab543b9cefb341eb4950aae487dbe99a236c80b 100644 (file)
@@ -1,3 +1,10 @@
+2018-05-18  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-18  Kito Cheng  <kito.cheng@gmail.com>
 
        * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Handle
index f4dbddf15e3cfe8cc7c8d9cb7bc18017765d44ef..29d92d288acdb0087f6473b94b167c0f8056f80a 100644 (file)
@@ -2048,8 +2048,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;
index eb7fac4892c9a7edd7981e986841e2cb50da4bf7..15de953374b3bd3330049b9440cce1c842373a06 100644 (file)
@@ -1,3 +1,15 @@
+2018-05-18  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-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/ld-i386/i386.exp: Run pr23189 for all targets.
index 5683a75208fee744117056d226de857cf92b8a91..bb91a760ca2203737bad6b493cf7340fac9a8723 100644 (file)
@@ -459,6 +459,7 @@ run_dump_test "pr22135"
 run_dump_test "pr22782"
 run_dump_test "pr22929"
 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 (file)
index 0000000..b5e8c33
--- /dev/null
@@ -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 (file)
index 0000000..353c194
--- /dev/null
@@ -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 (file)
index 0000000..32693fe
--- /dev/null
@@ -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 (file)
index 0000000..6b12060
--- /dev/null
@@ -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 (file)
index 0000000..353c194
--- /dev/null
@@ -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 (file)
index 0000000..277c19d
--- /dev/null
@@ -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
index 9654cda4facfea17825b30ba3d58570cf54d526d..d07054ca4c5a7d3d20f8e4f29619e495c3044a42 100644 (file)
@@ -396,6 +396,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