This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 15 Feb 2017 19:12:09 -0000
- Subject: [binutils-gdb] Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5def14f1ca70e14d9433cb229c9369fa3051598
commit a5def14f1ca70e14d9433cb229c9369fa3051598
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Feb 15 10:55:51 2017 -0800
Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error
bfd/
PR ld/20244
* elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC
symbol name when reporting R_386_GOT32/R_386_GOT32X relocation
error against local IFUNC symbol without a base register for
PIC.
ld/
PR ld/20244
* testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and
pr20244-4c.
* testsuite/ld-i386/pr20244-4.s: New file.
* testsuite/ld-i386/pr20244-4a.d: Likewise.
* testsuite/ld-i386/pr20244-4b.d: Likewise.
* testsuite/ld-i386/pr20244-4c.d: Likewise.
Diff:
---
bfd/ChangeLog | 8 ++++++++
bfd/elf32-i386.c | 2 +-
ld/ChangeLog | 10 ++++++++++
ld/testsuite/ld-i386/i386.exp | 3 +++
ld/testsuite/ld-i386/pr20244-4.s | 10 ++++++++++
ld/testsuite/ld-i386/pr20244-4a.d | 18 ++++++++++++++++++
ld/testsuite/ld-i386/pr20244-4b.d | 11 +++++++++++
ld/testsuite/ld-i386/pr20244-4c.d | 4 ++++
8 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index edd7633..cbea9a9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2017-02-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20244
+ * elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC
+ symbol name when reporting R_386_GOT32/R_386_GOT32X relocation
+ error against local IFUNC symbol without a base register for
+ PIC.
+
2017-02-15 Maciej W. Rozycki <macro@imgtec.com>
* elf32-ppc.c (ppc_elf_check_relocs): Use `%H:' rather than
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 0860ada..3bee4ca 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4355,7 +4355,7 @@ r_386_got32:
const char *name;
disallow_got32:
- if (h == NULL)
+ if (h == NULL || h->root.root.string == NULL)
name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
NULL);
else
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1fc23dc..3f88091 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2017-02-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20244
+ * testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and
+ pr20244-4c.
+ * testsuite/ld-i386/pr20244-4.s: New file.
+ * testsuite/ld-i386/pr20244-4a.d: Likewise.
+ * testsuite/ld-i386/pr20244-4b.d: Likewise.
+ * testsuite/ld-i386/pr20244-4c.d: Likewise.
+
2017-02-15 Maciej W. Rozycki <macro@imgtec.com>
* ldmisc.c (vfinfo): Don't print the function name again either
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 43cb3c5..7680ff5 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -408,6 +408,9 @@ run_dump_test "pr20244-2a"
run_dump_test "pr20244-2b"
run_dump_test "pr20244-2c"
run_dump_test "pr20244-2d"
+run_dump_test "pr20244-4a"
+run_dump_test "pr20244-4b"
+run_dump_test "pr20244-4c"
run_dump_test "pr20253-3"
run_dump_test "pr20253-4a"
run_dump_test "pr20253-4b"
diff --git a/ld/testsuite/ld-i386/pr20244-4.s b/ld/testsuite/ld-i386/pr20244-4.s
new file mode 100644
index 0000000..0197256
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20244-4.s
@@ -0,0 +1,10 @@
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ mov ifunc@GOT, %eax
+ ret
+ .type ifunc, @gnu_indirect_function
+ifunc:
+ mov $0xbadbeef, %eax
+ ret
diff --git a/ld/testsuite/ld-i386/pr20244-4a.d b/ld/testsuite/ld-i386/pr20244-4a.d
new file mode 100644
index 0000000..420d179
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20244-4a.d
@@ -0,0 +1,18 @@
+#source: pr20244-4.s
+#as: --32
+#ld: -m elf_i386
+#objdump: -dw
+#notarget: i?86-*-nacl* x86_64-*-nacl*
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+804807c <_start>:
+ +[a-f0-9]+: 8b 05 8c 90 04 08 mov 0x804908c,%eax
+ +[a-f0-9]+: c3 ret
+
+0+8048083 <ifunc>:
+ +[a-f0-9]+: b8 ef be ad 0b mov \$0xbadbeef,%eax
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/pr20244-4b.d b/ld/testsuite/ld-i386/pr20244-4b.d
new file mode 100644
index 0000000..16e5243
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20244-4b.d
@@ -0,0 +1,11 @@
+#source: pr20244-4.s
+#as: --32
+#ld: -m elf_i386
+#objdump: -s -j .got
+#notarget: i?86-*-nacl* x86_64-*-nacl*
+
+.*: +file format .*
+
+Contents of section .got:
+ 804908c 83800408 +.... +
+#pass
diff --git a/ld/testsuite/ld-i386/pr20244-4c.d b/ld/testsuite/ld-i386/pr20244-4c.d
new file mode 100644
index 0000000..07b2b19
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20244-4c.d
@@ -0,0 +1,4 @@
+#source: pr20244-4.s
+#as: --32
+#ld: -pie -m elf_i386
+#error: direct GOT relocation R_386_GOT32X against `ifunc' without base register can not be used when making a shared object