aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-12 13:31:29 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-12 13:47:41 -0700
commit13a2df29c930eda49837741902b67021ab004990 (patch)
tree3e544f21be3e9df04686f21a6ff0b3c061209870 /ld
parent4dafcdeb1341c4dd1a4641373bc17aab3ef2e788 (diff)
downloadgdb-13a2df29c930eda49837741902b67021ab004990.zip
gdb-13a2df29c930eda49837741902b67021ab004990.tar.gz
gdb-13a2df29c930eda49837741902b67021ab004990.tar.bz2
Set EI_OSABI to ELFOSABI_GNU for local IFUNC symbols
Since the backend elf_add_symbol_hook isn't called on local symbols, the EI_OSABI field isn't to ELFOSABI_GNU where are local IFUNC symbols. This patch changes the x86 backends to set has_gnu_symbols if there are relocations against IFUNC symbols. Other backends with IFUNC support may need a similar change. This patch also changes the type of has_gnu_symbols from bfd_boolean to enum elf_gnu_symbols. bfd/ PR ld/18815 * elf-bfd.h (elf_gnu_symbols): New enum. (elf_obj_tdata): Use elf_gnu_symbols on has_gnu_symbols. * elf-s390-common.c (elf_s390_add_symbol_hook): Set has_gnu_symbols to elf_gnu_symbol_any. * elf32-arm.c (elf32_arm_add_symbol_hook): Likewise. * elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise. * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise. * lfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise. * elf32-i386.c (elf_i386_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_i386_add_symbol_hook): Don't check STT_GNU_IFUNC here. * elf64-x86-64. (elf_x86_64_check_relocs): Update has_gnu_symbols if there are relocations against IFUNC symbols. (elf_x86_64_add_symbol_hook): Don't check STT_GNU_IFUNC here. ld/testsuite/ PR ld/18815 * ld-i386/i386.exp: Run pr18815. * ld-x86-64/x86-64.exp: Likewise. * ld-i386/pr18815.d: New file. * ld-i386/pr18815.s: Likewise. * ld-x86-64/pr18815.d: Likewise. * ld-x86-64/pr18815.s: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-i386/i386.exp1
-rw-r--r--ld/testsuite/ld-i386/pr18815.d9
-rw-r--r--ld/testsuite/ld-i386/pr18815.s15
-rw-r--r--ld/testsuite/ld-x86-64/pr18815.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr18815.s15
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp1
6 files changed, 50 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 0dbdd1e..0a718cf 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -309,6 +309,7 @@ run_dump_test "pr14215"
run_dump_test "pr17057"
run_dump_test "pr17935-1"
run_dump_test "pr17935-2"
+run_dump_test "pr18815"
# Add $PLT_CFLAGS if PLT is expected.
global PLT_CFLAGS
diff --git a/ld/testsuite/ld-i386/pr18815.d b/ld/testsuite/ld-i386/pr18815.d
new file mode 100644
index 0000000..f49ecf7
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr18815.d
@@ -0,0 +1,9 @@
+#name: PR ld/18815
+#as: --32
+#ld: -melf_i386
+#readelf: -h
+
+ELF Header:
+#...
+ OS/ABI: UNIX - GNU
+#pass
diff --git a/ld/testsuite/ld-i386/pr18815.s b/ld/testsuite/ld-i386/pr18815.s
new file mode 100644
index 0000000..ac3377d
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr18815.s
@@ -0,0 +1,15 @@
+ .text
+ .type selector, %function
+foo:
+ movl $0, %eax
+ ret
+selector:
+ mov $foo, %eax
+ ret
+ .type selector, %gnu_indirect_function
+ .globl _start
+_start:
+ mov $selector, %eax
+ call *%eax
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr18815.d b/ld/testsuite/ld-x86-64/pr18815.d
new file mode 100644
index 0000000..dd95b2a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr18815.d
@@ -0,0 +1,9 @@
+#name: PR ld/18815
+#as: --64
+#ld: -melf_x86_64
+#readelf: -h
+
+ELF Header:
+#...
+ OS/ABI: UNIX - GNU
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr18815.s b/ld/testsuite/ld-x86-64/pr18815.s
new file mode 100644
index 0000000..6ec79ba
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr18815.s
@@ -0,0 +1,15 @@
+ .text
+ .type selector, %function
+foo:
+ movl $0, %eax
+ ret
+selector:
+ mov $foo, %eax
+ ret
+ .type selector, %gnu_indirect_function
+ .globl _start
+_start:
+ mov $selector, %rax
+ call *%rax
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index d67ff2a..bd48cd3 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -325,6 +325,7 @@ run_dump_test "pr17935-1"
run_dump_test "pr17935-2"
run_dump_test "pr18160"
run_dump_test "pr18176"
+run_dump_test "pr18815"
# Add $PLT_CFLAGS if PLT is expected.
global PLT_CFLAGS