aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-06-19 20:20:52 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-06-19 20:21:04 -0700
commit406b4ada55b2957c10fedaeaada801e77912d976 (patch)
treee53f5b5356ec93296df94c593b8d6617681c1e49 /ld/testsuite/ld-i386
parent7e3941ac0619431d51a9643e20cb0e0720502101 (diff)
downloadgdb-406b4ada55b2957c10fedaeaada801e77912d976.zip
gdb-406b4ada55b2957c10fedaeaada801e77912d976.tar.gz
gdb-406b4ada55b2957c10fedaeaada801e77912d976.tar.bz2
x86: Count PLT for GOTOFF relocation against IFUNC symbol
Since GOTOFF relocations against IFUNC symbols must go through PLT, set PLT reference count to 1 for GOTOFF relocation. bfd/ PR ld/27998 * elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF relocation against IFUNC symbols. (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. ld/ PR ld/27998 * testsuite/ld-i386/i386.exp: Run PR ld/27998 tests. * testsuite/ld-i386/pr27998a.d: New file. * testsuite/ld-i386/pr27998a.s: Likewise. * testsuite/ld-i386/pr27998b.d: Likewise. * testsuite/ld-i386/pr27998b.s: Likewise.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r--ld/testsuite/ld-i386/i386.exp2
-rw-r--r--ld/testsuite/ld-i386/pr27998a.d7
-rw-r--r--ld/testsuite/ld-i386/pr27998a.s22
-rw-r--r--ld/testsuite/ld-i386/pr27998b.d7
-rw-r--r--ld/testsuite/ld-i386/pr27998b.s20
5 files changed, 58 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 3d6047b..ceb6000 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -519,6 +519,8 @@ run_dump_test "pr19939a"
run_dump_test "pr19939b"
run_dump_test "tlsdesc2"
run_dump_test "report-reloc-1"
+run_dump_test "pr27998a"
+run_dump_test "pr27998b"
proc undefined_weak {cflags ldflags} {
set testname "Undefined weak symbol"
diff --git a/ld/testsuite/ld-i386/pr27998a.d b/ld/testsuite/ld-i386/pr27998a.d
new file mode 100644
index 0000000..ca3c920
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr27998a.d
@@ -0,0 +1,7 @@
+#as: --32
+#ld: -shared -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.plt' 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_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr27998a.s b/ld/testsuite/ld-i386/pr27998a.s
new file mode 100644
index 0000000..ec55cd6
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr27998a.s
@@ -0,0 +1,22 @@
+ .text
+ .p2align 4
+ .type my_foo, @function
+my_foo:
+ ret
+ .size my_foo, .-my_foo
+ .p2align 4
+ .type resolve_foo, @function
+resolve_foo:
+ leal my_foo@GOTOFF(%eax), %eax
+ ret
+ .size resolve_foo, .-resolve_foo
+ .globl foo
+ .hidden foo
+ .type foo, @gnu_indirect_function
+ .set foo,resolve_foo
+ .p2align 4
+ .globl bar
+ .type bar, @function
+bar:
+ leal foo@GOTOFF(%eax), %eax
+ ret
diff --git a/ld/testsuite/ld-i386/pr27998b.d b/ld/testsuite/ld-i386/pr27998b.d
new file mode 100644
index 0000000..ca3c920
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr27998b.d
@@ -0,0 +1,7 @@
+#as: --32
+#ld: -shared -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.plt' 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_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr27998b.s b/ld/testsuite/ld-i386/pr27998b.s
new file mode 100644
index 0000000..8b023e9
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr27998b.s
@@ -0,0 +1,20 @@
+ .text
+ .p2align 4
+ .type my_foo, @function
+my_foo:
+ ret
+ .size my_foo, .-my_foo
+ .p2align 4
+ .type resolve_foo, @function
+resolve_foo:
+ leal my_foo@GOTOFF(%eax), %eax
+ ret
+ .size resolve_foo, .-resolve_foo
+ .type foo, @gnu_indirect_function
+ .set foo,resolve_foo
+ .p2align 4
+ .globl bar
+ .type bar, @function
+bar:
+ leal foo@GOTOFF(%eax), %eax
+ ret