aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-x86-64
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-06-18 09:16:52 -0700
committerH.J. Lu <hjl.tools@gmail.com>2016-06-18 09:17:25 -0700
commit233cc9c13af8e8182d0ce5b306526b59f5b11f37 (patch)
tree6381519cd959d8a585cd640de586e6aab3ca715b /ld/testsuite/ld-x86-64
parent854594f5ce00381eb0ed57e3c7fa08b5971eabec (diff)
downloadgdb-233cc9c13af8e8182d0ce5b306526b59f5b11f37.zip
gdb-233cc9c13af8e8182d0ce5b306526b59f5b11f37.tar.gz
gdb-233cc9c13af8e8182d0ce5b306526b59f5b11f37.tar.bz2
Don't generate PLT for IFUNC GOT/pointer reference
If a backend supports it, PLT entry isn't needed when all references to a STT_GNU_IFUNC symbols are done via GOT or static function pointers. For GOT entries, We generate dynamic R_*_GLOB_DAT relocations for preemptable symbols and R_*_IRELATIVE relocations for non-preemptable symbols to update them with real function address. For static pointer pointers, we generate dynamic pointer relocations and store them in: 1. .rel[a].ifunc section in PIC object. 2. .rel[a].got section in dynamic executable. 3. .rel[a].iplt section in static executable. We don't allocate GOT entry if it isn't used. bfd/ PR ld/20253 * elf-bfd.h (_bfd_elf_allocate_ifunc_dyn_relocs): Add an bfd_boolean argument. * elf-ifunc.c (_bfd_elf_create_ifunc_sections): Replace "shared object" with "PIC object" in comments. (_bfd_elf_allocate_ifunc_dyn_relocs): Updated. Replace "shared object" with "PIC object" in comments. Avoid PLT if requested. Generate dynamic relocations for non-GOT references. Make room for the special first entry in PLT and allocate PLT entry only for PLT and PC-relative references. Store dynamic GOT relocations in .rel[a].iplt section for static executables. If PLT isn't used, always use GOT for symbol value. Don't allocate GOT entry if it isn't used. * elf32-i386.c (elf_i386_check_relocs): Increment PLT reference count only in the code section. Allocate dynamic pointer relocation against STT_GNU_IFUNC symbol in the non-code section. (elf_i386_adjust_dynamic_symbol): Increment PLT reference count only for PC-relative references. (elf_i386_allocate_dynrelocs): Pass TRUE to _bfd_elf_allocate_ifunc_dyn_relocs. (elf_i386_relocate_section): Allow R_386_GOT32/R_386_GOT32X relocations against STT_GNU_IFUNC symbols without PLT. Generate dynamic pointer relocation against STT_GNU_IFUNC symbol in the non-code section and store it in the proper REL section. Don't allow non-pointer relocation against STT_GNU_IFUNC symbol without PLT. (elf_i386_finish_dynamic_symbol): Generate dynamic R_386_IRELATIVE and R_386_GLOB_DAT GOT relocations against STT_GNU_IFUNC symbols without PLT. (elf_i386_finish_dynamic_sections): Don't handle local STT_GNU_IFUNC symbols here. (elf_i386_output_arch_local_syms): Handle local STT_GNU_IFUNC symbols here. (elf_backend_output_arch_local_syms): New. * elf32-x86-64.c (elf_i386_check_relocs): Increment PLT reference count only in the code section. Allocate dynamic pointer relocation against STT_GNU_IFUNC symbol in the non-code section. (elf_x86_64_adjust_dynamic_symbol): Increment PLT reference count only for PC-relative references. (elf_x86_64_allocate_dynrelocs): Pass TRUE to _bfd_elf_allocate_ifunc_dyn_relocs. (elf_x86_64_relocate_section): Allow R_X86_64_GOTPCREL, R_X86_64_GOTPCRELX, R_X86_64_REX_GOTPCRELX and R_X86_64_GOTPCREL64 relocations against STT_GNU_IFUNC symbols without PLT. Generate dynamic pointer relocation against STT_GNU_IFUNC symbol in the non-code section and store it in the proper RELA section. Don't allow non-pointer relocation against STT_GNU_IFUNC symbol without PLT. (elf_x86_64_finish_dynamic_symbol): Generate dynamic R_X86_64_IRELATIVE and R_X86_64_GLOB_DAT GOT relocations against STT_GNU_IFUNC symbols without PLT. (elf_x86_64_finish_dynamic_sections): Don't handle local STT_GNU_IFUNC symbols here. (elf_x86_64_output_arch_local_syms): Handle local STT_GNU_IFUNC symbols here. (elf_backend_output_arch_local_syms): New. * elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs): Pass FALSE to _bfd_elf_allocate_ifunc_dyn_relocs. ld/ PR ld/20253 * testsuite/ld-i386/i386.exp: Run PR ld/20253 tests. * testsuite/ld-i386/no-plt.exp: Likewise. * testsuite/ld-x86-64/no-plt.exp: Likewise. * testsuite/ld-i386/pr13302.d: Remove .rel.plt section. * testsuite/ld-ifunc/ifunc-13-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-13-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-15-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-15-x86-64.d: Likewise. * testsuite/ld-x86-64/pr13082-5a.d: Likewise. * testsuite/ld-x86-64/pr13082-5b.d: Likewise. * testsuite/ld-x86-64/pr13082-6a.d: Likewise. * testsuite/ld-x86-64/pr13082-6b.d: Likewise. * testsuite/ld-i386/pr20244-2a.d: Remove .plt section. * testsuite/ld-ifunc/ifunc-21-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-22-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise. * testsuite/ld-i386/pr20244-2b.d: Updated. * testsuite/ld-i386/pr20244-2c.d: Likewise. * testsuite/ld-ifunc/ifunc-18a-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise. * testsuite/ld-i386/pr20253-1a.c: New file. * testsuite/ld-i386/pr20253-1b.S: Likewise. * testsuite/ld-i386/pr20253-1c.S: Likewise. * testsuite/ld-i386/pr20253-1d.S: Likewise. * testsuite/ld-i386/pr20253-2a.c: Likewise. * testsuite/ld-i386/pr20253-2b.S: Likewise. * testsuite/ld-i386/pr20253-2c.S: Likewise. * testsuite/ld-i386/pr20253-2d.S: Likewise. * testsuite/ld-i386/pr20253-3.d: Likewise. * testsuite/ld-i386/pr20253-3.s: Likewise. * testsuite/ld-i386/pr20253-4.s: Likewise. * testsuite/ld-i386/pr20253-4a.d: Likewise. * testsuite/ld-i386/pr20253-4b.d: Likewise. * testsuite/ld-i386/pr20253-4c.d: Likewise. * testsuite/ld-i386/pr20253-5.d: Likewise. * testsuite/ld-i386/pr20253-5.s: Likewise. * testsuite/ld-ifunc/ifunc-23-x86.s: Likewise. * testsuite/ld-ifunc/ifunc-23a-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-23b-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-23c-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-24-x86.s: Likewise. * testsuite/ld-ifunc/ifunc-24a-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-24b-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-24c-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-25-x86.s: Likewise. * testsuite/ld-ifunc/ifunc-25a-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-25b-x86.d: Likewise. * testsuite/ld-ifunc/ifunc-25c-x86.d: Likewise. * testsuite/ld-x86-64/pr20253-1.s: Likewise. * testsuite/ld-x86-64/pr20253-1a.d: Likewise. * testsuite/ld-x86-64/pr20253-1b.d: Likewise. * testsuite/ld-x86-64/pr20253-1c.d: Likewise. * testsuite/ld-x86-64/pr20253-1d.d: Likewise. * testsuite/ld-x86-64/pr20253-1e.d: Likewise. * testsuite/ld-x86-64/pr20253-1f.d: Likewise. * testsuite/ld-x86-64/pr20253-1g.d: Likewise. * testsuite/ld-x86-64/pr20253-1h.d: Likewise. * testsuite/ld-x86-64/pr20253-1i.d: Likewise. * testsuite/ld-x86-64/pr20253-1j.d: Likewise. * testsuite/ld-x86-64/pr20253-1k.d: Likewise. * testsuite/ld-x86-64/pr20253-1l.d: Likewise. * testsuite/ld-x86-64/pr20253-2a.c: Likewise. * testsuite/ld-x86-64/pr20253-2b.S: Likewise. * testsuite/ld-x86-64/pr20253-2c.S: Likewise. * testsuite/ld-x86-64/pr20253-2d.S: Likewise. * testsuite/ld-x86-64/pr20253-3.d: Likewise. * testsuite/ld-x86-64/pr20253-3.s: Likewise. * testsuite/ld-x86-64/pr20253-4.s: Likewise. * testsuite/ld-x86-64/pr20253-4a.d: Likewise. * testsuite/ld-x86-64/pr20253-4b.d: Likewise. * testsuite/ld-x86-64/pr20253-4c.d: Likewise. * testsuite/ld-x86-64/pr20253-4d.d: Likewise. * testsuite/ld-x86-64/pr20253-4e.d: Likewise. * testsuite/ld-x86-64/pr20253-4f.d: Likewise. * testsuite/ld-x86-64/pr20253-5.s: Likewise. * testsuite/ld-x86-64/pr20253-5a.d: Likewise. * testsuite/ld-x86-64/pr20253-5b.d: Likewise. * testsuite/ld-ifunc/ifunc-18a-i386.d: Remove extra IRELATIVE relocation. * testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise. * testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise. * testsuite/ld-ifunc/ifunc-18a.s: Fix a typo. * testsuite/ld-x86-64/x86-64.exp: Run pr20253-1 tests.
Diffstat (limited to 'ld/testsuite/ld-x86-64')
-rw-r--r--ld/testsuite/ld-x86-64/no-plt.exp85
-rw-r--r--ld/testsuite/ld-x86-64/pr13082-5a.d4
-rw-r--r--ld/testsuite/ld-x86-64/pr13082-5b.d4
-rw-r--r--ld/testsuite/ld-x86-64/pr13082-6a.d4
-rw-r--r--ld/testsuite/ld-x86-64/pr13082-6b.d4
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1.s18
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1a.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1b.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1c.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1d.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1e.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1f.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1g.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1h.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1i.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1j.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1k.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-1l.d25
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-2a.c8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-2b.S46
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-2c.S29
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-2d.S61
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-3.d3
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-3.s11
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4.s11
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4a.d8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4b.d8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4c.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4d.d8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4e.d8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-4f.d9
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-5.s10
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-5a.d8
-rw-r--r--ld/testsuite/ld-x86-64/pr20253-5b.d8
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp21
35 files changed, 573 insertions, 16 deletions
diff --git a/ld/testsuite/ld-x86-64/no-plt.exp b/ld/testsuite/ld-x86-64/no-plt.exp
index d57ccb5..bdf1843 100644
--- a/ld/testsuite/ld-x86-64/no-plt.exp
+++ b/ld/testsuite/ld-x86-64/no-plt.exp
@@ -199,3 +199,88 @@ run_ld_link_exec_tests [] [list \
"pass.out" \
] \
]
+
+# Run-time tests which require working IFUNC support.
+if { [check_ifunc_available] } {
+ run_cc_link_tests [list \
+ [list \
+ "Build pr20253-2a.o pr20253-2b.o pr20253-2c.o pr20253-2d.o" \
+ "" \
+ "-fPIE -O2 -g" \
+ { pr20253-2a.c pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
+ ] \
+ [list \
+ "Build libpr20253-2a.so" \
+ "-shared tmpdir/pr20253-2b.o \
+ tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
+ "" \
+ { dummy.s } \
+ {} \
+ "libpr20253-2a.so" \
+ ] \
+ ]
+
+ run_ld_link_exec_tests [] [list \
+ [list \
+ "Run pr20253-2a" \
+ "tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
+ tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-2a" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-2b" \
+ "--static tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
+ tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-2b" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-2c" \
+ "-pie tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
+ tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-2c" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-2d" \
+ "tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
+ "" \
+ { dummy.s } \
+ "pr20253-2d" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-2e" \
+ "-pie tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \
+ "" \
+ { dummy.s } \
+ "pr20253-2e" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-2f" \
+ "tmpdir/pr20253-2a.o" \
+ "" \
+ { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
+ "pr20253-2f" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
+ [list \
+ "Run pr20253-2g" \
+ "--static tmpdir/pr20253-2a.o" \
+ "" \
+ { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
+ "pr20253-2g" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
+ ]
+}
diff --git a/ld/testsuite/ld-x86-64/pr13082-5a.d b/ld/testsuite/ld-x86-64/pr13082-5a.d
index 191c29e..d1b100d 100644
--- a/ld/testsuite/ld-x86-64/pr13082-5a.d
+++ b/ld/testsuite/ld-x86-64/pr13082-5a.d
@@ -7,7 +7,3 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +ifunc\(\)+ +ifunc \+ 0
-
-Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
- Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +ifunc\(\)+ +ifunc \+ 0
diff --git a/ld/testsuite/ld-x86-64/pr13082-5b.d b/ld/testsuite/ld-x86-64/pr13082-5b.d
index 1c5a5e7..01e403b 100644
--- a/ld/testsuite/ld-x86-64/pr13082-5b.d
+++ b/ld/testsuite/ld-x86-64/pr13082-5b.d
@@ -7,7 +7,3 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
-
-Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
- Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr13082-6a.d b/ld/testsuite/ld-x86-64/pr13082-6a.d
index 9a1a655..5914f3d 100644
--- a/ld/testsuite/ld-x86-64/pr13082-6a.d
+++ b/ld/testsuite/ld-x86-64/pr13082-6a.d
@@ -7,7 +7,3 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
-
-Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
- Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr13082-6b.d b/ld/testsuite/ld-x86-64/pr13082-6b.d
index 792c348..6ff23ff 100644
--- a/ld/testsuite/ld-x86-64/pr13082-6b.d
+++ b/ld/testsuite/ld-x86-64/pr13082-6b.d
@@ -7,7 +7,3 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
-
-Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
- Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1.s b/ld/testsuite/ld-x86-64/pr20253-1.s
new file mode 100644
index 0000000..4b9b7a4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1.s
@@ -0,0 +1,18 @@
+ .text
+ .globl foo
+ .type foo, @gnu_indirect_function
+foo:
+ ret
+ .text
+ .type bar, @gnu_indirect_function
+bar:
+ ret
+ .globl _start
+ .type _start, @function
+_start:
+ call *foo@GOTPCREL(%rip)
+ jmp *bar@GOTPCREL(%rip)
+ movq $0, bar@GOTPCREL(%rip)
+ cmpq $0, foo@GOTPCREL(%rip)
+ cmpq foo@GOTPCREL(%rip), %rcx
+ cmpq bar@GOTPCREL(%rip), %rcx
diff --git a/ld/testsuite/ld-x86-64/pr20253-1a.d b/ld/testsuite/ld-x86-64/pr20253-1a.d
new file mode 100644
index 0000000..94c7c1d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1a.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1b.d b/ld/testsuite/ld-x86-64/pr20253-1b.d
new file mode 100644
index 0000000..247e042
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1b.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -melf_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+4000e0 <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+4000e1 <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+4000e2 <_start>:
+ +[a-f0-9]+: ff 15 28 00 20 00 callq \*0x200028\(%rip\) # 600110 <_start\+0x20002e>
+ +[a-f0-9]+: ff 25 2a 00 20 00 jmpq \*0x20002a\(%rip\) # 600118 <_start\+0x200036>
+ +[a-f0-9]+: 48 c7 05 1f 00 20 00 00 00 00 00 movq \$0x0,0x20001f\(%rip\) # 600118 <_start\+0x200036>
+ +[a-f0-9]+: 48 83 3d 0f 00 20 00 00 cmpq \$0x0,0x20000f\(%rip\) # 600110 <_start\+0x20002e>
+ +[a-f0-9]+: 48 3b 0d 08 00 20 00 cmp 0x200008\(%rip\),%rcx # 600110 <_start\+0x20002e>
+ +[a-f0-9]+: 48 3b 0d 09 00 20 00 cmp 0x200009\(%rip\),%rcx # 600118 <_start\+0x200036>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-1c.d b/ld/testsuite/ld-x86-64/pr20253-1c.d
new file mode 100644
index 0000000..02c4542
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1c.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -pie -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1d.d b/ld/testsuite/ld-x86-64/pr20253-1d.d
new file mode 100644
index 0000000..35c04f8
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1d.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+1c8 <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+1c9 <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+1ca <_start>:
+ +[a-f0-9]+: ff 15 28 01 20 00 callq \*0x200128\(%rip\) # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+: ff 25 2a 01 20 00 jmpq \*0x20012a\(%rip\) # 200300 <_DYNAMIC\+0x108>
+ +[a-f0-9]+: 48 c7 05 1f 01 20 00 00 00 00 00 movq \$0x0,0x20011f\(%rip\) # 200300 <_DYNAMIC\+0x108>
+ +[a-f0-9]+: 48 83 3d 0f 01 20 00 00 cmpq \$0x0,0x20010f\(%rip\) # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+: 48 3b 0d 08 01 20 00 cmp 0x200108\(%rip\),%rcx # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+: 48 3b 0d 09 01 20 00 cmp 0x200109\(%rip\),%rcx # 200300 <_DYNAMIC\+0x108>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-1e.d b/ld/testsuite/ld-x86-64/pr20253-1e.d
new file mode 100644
index 0000000..722fdf7
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1e.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -shared -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +foo\(\)+ +foo \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1f.d b/ld/testsuite/ld-x86-64/pr20253-1f.d
new file mode 100644
index 0000000..d84b60e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1f.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --64
+#ld: -shared -melf_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+1f8 <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+1f9 <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+1fa <_start>:
+ +[a-f0-9]+: ff 15 08 01 20 00 callq \*0x200108\(%rip\) # 200308 <_DYNAMIC\+0xe0>
+ +[a-f0-9]+: ff 25 0a 01 20 00 jmpq \*0x20010a\(%rip\) # 200310 <_DYNAMIC\+0xe8>
+ +[a-f0-9]+: 48 c7 05 ff 00 20 00 00 00 00 00 movq \$0x0,0x2000ff\(%rip\) # 200310 <_DYNAMIC\+0xe8>
+ +[a-f0-9]+: 48 83 3d ef 00 20 00 00 cmpq \$0x0,0x2000ef\(%rip\) # 200308 <_DYNAMIC\+0xe0>
+ +[a-f0-9]+: 48 3b 0d e8 00 20 00 cmp 0x2000e8\(%rip\),%rcx # 200308 <_DYNAMIC\+0xe0>
+ +[a-f0-9]+: 48 3b 0d e9 00 20 00 cmp 0x2000e9\(%rip\),%rcx # 200310 <_DYNAMIC\+0xe8>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-1g.d b/ld/testsuite/ld-x86-64/pr20253-1g.d
new file mode 100644
index 0000000..671a980
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1g.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1h.d b/ld/testsuite/ld-x86-64/pr20253-1h.d
new file mode 100644
index 0000000..77ff100
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1h.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -melf32_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+40008c <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+40008d <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+40008e <_start>:
+ +[a-f0-9]+: ff 15 28 00 20 00 callq \*0x200028\(%rip\) # 6000bc <_start\+0x20002e>
+ +[a-f0-9]+: ff 25 2a 00 20 00 jmpq \*0x20002a\(%rip\) # 6000c4 <_start\+0x200036>
+ +[a-f0-9]+: 48 c7 05 1f 00 20 00 00 00 00 00 movq \$0x0,0x20001f\(%rip\) # 6000c4 <_start\+0x200036>
+ +[a-f0-9]+: 48 83 3d 0f 00 20 00 00 cmpq \$0x0,0x20000f\(%rip\) # 6000bc <_start\+0x20002e>
+ +[a-f0-9]+: 48 3b 0d 08 00 20 00 cmp 0x200008\(%rip\),%rcx # 6000bc <_start\+0x20002e>
+ +[a-f0-9]+: 48 3b 0d 09 00 20 00 cmp 0x200009\(%rip\),%rcx # 6000c4 <_start\+0x200036>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-1i.d b/ld/testsuite/ld-x86-64/pr20253-1i.d
new file mode 100644
index 0000000..bf42ed1
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1i.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -pie -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1j.d b/ld/testsuite/ld-x86-64/pr20253-1j.d
new file mode 100644
index 0000000..6f5d666
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1j.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -pie -melf32_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+120 <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+121 <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+122 <_start>:
+ +[a-f0-9]+: ff 15 a8 00 20 00 callq \*0x2000a8\(%rip\) # 2001d0 <_DYNAMIC\+0x80>
+ +[a-f0-9]+: ff 25 aa 00 20 00 jmpq \*0x2000aa\(%rip\) # 2001d8 <_DYNAMIC\+0x88>
+ +[a-f0-9]+: 48 c7 05 9f 00 20 00 00 00 00 00 movq \$0x0,0x20009f\(%rip\) # 2001d8 <_DYNAMIC\+0x88>
+ +[a-f0-9]+: 48 83 3d 8f 00 20 00 00 cmpq \$0x0,0x20008f\(%rip\) # 2001d0 <_DYNAMIC\+0x80>
+ +[a-f0-9]+: 48 3b 0d 88 00 20 00 cmp 0x200088\(%rip\),%rcx # 2001d0 <_DYNAMIC\+0x80>
+ +[a-f0-9]+: 48 3b 0d 89 00 20 00 cmp 0x200089\(%rip\),%rcx # 2001d8 <_DYNAMIC\+0x88>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-1k.d b/ld/testsuite/ld-x86-64/pr20253-1k.d
new file mode 100644
index 0000000..1d55770
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1k.d
@@ -0,0 +1,9 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +foo\(\)+ +foo \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-1l.d b/ld/testsuite/ld-x86-64/pr20253-1l.d
new file mode 100644
index 0000000..0276558
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-1l.d
@@ -0,0 +1,25 @@
+#source: pr20253-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+158 <foo>:
+ +[a-f0-9]+: c3 retq
+
+0+159 <bar>:
+ +[a-f0-9]+: c3 retq
+
+0+15a <_start>:
+ +[a-f0-9]+: ff 15 98 00 20 00 callq \*0x200098\(%rip\) # 2001f8 <_DYNAMIC\+0x70>
+ +[a-f0-9]+: ff 25 9a 00 20 00 jmpq \*0x20009a\(%rip\) # 200200 <_DYNAMIC\+0x78>
+ +[a-f0-9]+: 48 c7 05 8f 00 20 00 00 00 00 00 movq \$0x0,0x20008f\(%rip\) # 200200 <_DYNAMIC\+0x78>
+ +[a-f0-9]+: 48 83 3d 7f 00 20 00 00 cmpq \$0x0,0x20007f\(%rip\) # 2001f8 <_DYNAMIC\+0x70>
+ +[a-f0-9]+: 48 3b 0d 78 00 20 00 cmp 0x200078\(%rip\),%rcx # 2001f8 <_DYNAMIC\+0x70>
+ +[a-f0-9]+: 48 3b 0d 79 00 20 00 cmp 0x200079\(%rip\),%rcx # 200200 <_DYNAMIC\+0x78>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr20253-2a.c b/ld/testsuite/ld-x86-64/pr20253-2a.c
new file mode 100644
index 0000000..370275a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-2a.c
@@ -0,0 +1,8 @@
+extern void check (void);
+
+int
+main ()
+{
+ check ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-x86-64/pr20253-2b.S b/ld/testsuite/ld-x86-64/pr20253-2b.S
new file mode 100644
index 0000000..9bfab0c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-2b.S
@@ -0,0 +1,46 @@
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "PASS"
+ .text
+ .globl check
+ .type check, @function
+check:
+ subq $8, %rsp
+ call *get_func1@GOTPCREL(%rip)
+#ifdef CHECK_PLT
+ cmpl $func1, %eax
+#else
+ cmpq func1@GOTPCREL(%rip), %rax
+#endif
+ jne .L3
+ movq func1_p@GOTPCREL(%rip), %rdx
+#ifdef __LP64__
+ cmpq %rax, (%rdx)
+#else
+ cmpl %eax, (%rdx)
+#endif
+ jne .L3
+ call *func1@GOTPCREL(%rip)
+ cmpl $1, %eax
+ jne .L3
+ call *call_func1@GOTPCREL(%rip)
+ cmpl $1, %eax
+ jne .L3
+ call *get_func2@GOTPCREL(%rip)
+ movq func2_p@GOTPCREL(%rip), %rdx
+#ifdef __LP64__
+ cmpq %rax, (%rdx)
+#else
+ cmpl %eax, (%rdx)
+#endif
+ jne .L3
+ call *call_func2@GOTPCREL(%rip)
+ cmpl $2, %eax
+ jne .L3
+ leaq .LC0(%rip), %rdi
+ addq $8, %rsp
+ jmp *puts@GOTPCREL(%rip)
+.L3:
+ call *abort@GOTPCREL(%rip)
+ .size check, .-check
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr20253-2c.S b/ld/testsuite/ld-x86-64/pr20253-2c.S
new file mode 100644
index 0000000..5ec7e76
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-2c.S
@@ -0,0 +1,29 @@
+ .text
+ .globl get_func1
+ .type get_func1, @function
+get_func1:
+ movq func1@GOTPCREL(%rip), %rax
+ ret
+ .size get_func1, .-get_func1
+ .globl call_func1
+ .type call_func1, @function
+call_func1:
+ jmp *func1@GOTPCREL(%rip)
+ .size call_func1, .-call_func1
+ .globl func1_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+#ifdef __LP64__
+ .align 8
+ .size func1_p, 8
+#else
+ .align 4
+ .size func1_p, 4
+#endif
+ .type func1_p, @object
+func1_p:
+ .dc.a func1
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr20253-2d.S b/ld/testsuite/ld-x86-64/pr20253-2d.S
new file mode 100644
index 0000000..bc4c32e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-2d.S
@@ -0,0 +1,61 @@
+ .text
+ .type implementation1, @function
+implementation1:
+ movl $1, %eax
+ ret
+ .size implementation1, .-implementation1
+ .type implementation2, @function
+implementation2:
+ movl $2, %eax
+ ret
+ .size implementation2, .-implementation2
+ .type resolver2, @function
+resolver2:
+ leaq implementation2(%rip), %rax
+ ret
+ .size resolver2, .-resolver2
+ .type func2, @gnu_indirect_function
+ .set func2,resolver2
+ .type resolver1, @function
+resolver1:
+ leaq implementation1(%rip), %rax
+ ret
+ .size resolver1, .-resolver1
+ .globl func1
+ .type func1, @gnu_indirect_function
+ .set func1,resolver1
+ .globl get_func2
+ .type get_func2, @function
+get_func2:
+ movq func2@GOTPCREL(%rip), %rax
+ ret
+ .size get_func2, .-get_func2
+ .globl call_func2
+ .type call_func2, @function
+call_func2:
+ subq $8, %rsp
+ call *get_func2@GOTPCREL(%rip)
+ cmpq func2@GOTPCREL(%rip), %rax
+ jne .L10
+ addq $8, %rsp
+ jmp *func2@GOTPCREL(%rip)
+.L10:
+ call *abort@GOTPCREL(%rip)
+ .size call_func2, .-call_func2
+ .globl func2_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+#ifdef __LP64__
+ .align 8
+ .size func2_p, 8
+#else
+ .align 4
+ .size func2_p, 4
+#endif
+ .type func2_p, @object
+func2_p:
+ .dc.a func2
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr20253-3.d b/ld/testsuite/ld-x86-64/pr20253-3.d
new file mode 100644
index 0000000..30db29c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-3.d
@@ -0,0 +1,3 @@
+#as: --64
+#ld: -melf_x86_64
+#error: relocation R_X86_64_PC32 against STT_GNU_IFUNC symbol `foo' isn't supported
diff --git a/ld/testsuite/ld-x86-64/pr20253-3.s b/ld/testsuite/ld-x86-64/pr20253-3.s
new file mode 100644
index 0000000..8cd25fb
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-3.s
@@ -0,0 +1,11 @@
+ .text
+ .type foo,%gnu_indirect_function
+foo:
+ ret
+ .globl _start
+_start:
+ ret
+ .globl __start
+__start:
+ .data
+ .long foo - .
diff --git a/ld/testsuite/ld-x86-64/pr20253-4.s b/ld/testsuite/ld-x86-64/pr20253-4.s
new file mode 100644
index 0000000..7dc9aa3
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4.s
@@ -0,0 +1,11 @@
+ .text
+ .type foo,%gnu_indirect_function
+foo:
+ ret
+ .globl _start
+_start:
+ movq __start@GOTPCREL(%rip), %rax
+ .globl __start
+__start:
+ .data
+ .dc.a foo
diff --git a/ld/testsuite/ld-x86-64/pr20253-4a.d b/ld/testsuite/ld-x86-64/pr20253-4a.d
new file mode 100644
index 0000000..041c164
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4a.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --64
+#ld: -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-4b.d b/ld/testsuite/ld-x86-64/pr20253-4b.d
new file mode 100644
index 0000000..6dc95b5
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4b.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --64
+#ld: -pie -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-4c.d b/ld/testsuite/ld-x86-64/pr20253-4c.d
new file mode 100644
index 0000000..26fa0df
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4c.d
@@ -0,0 +1,9 @@
+#source: pr20253-4.s
+#as: --64
+#ld: -shared -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +[0-9a-f]+ +__start \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-4d.d b/ld/testsuite/ld-x86-64/pr20253-4d.d
new file mode 100644
index 0000000..52dd877
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4d.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --x32
+#ld: -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-4e.d b/ld/testsuite/ld-x86-64/pr20253-4e.d
new file mode 100644
index 0000000..d9f2fa4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4e.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --x32
+#ld: -pie -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-4f.d b/ld/testsuite/ld-x86-64/pr20253-4f.d
new file mode 100644
index 0000000..fb3d6f8
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-4f.d
@@ -0,0 +1,9 @@
+#source: pr20253-4.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +[0-9a-f]+ +__start \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-5.s b/ld/testsuite/ld-x86-64/pr20253-5.s
new file mode 100644
index 0000000..ade0e8b
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-5.s
@@ -0,0 +1,10 @@
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ call *func1@GOTPCREL(%rip)
+ cmp $func1,%eax
+ .globl func1
+ .type func1, @gnu_indirect_function
+func1:
+ ret
diff --git a/ld/testsuite/ld-x86-64/pr20253-5a.d b/ld/testsuite/ld-x86-64/pr20253-5a.d
new file mode 100644
index 0000000..1eceda4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-5a.d
@@ -0,0 +1,8 @@
+#source: pr20253-5.s
+#as: --64
+#ld: -melf_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/pr20253-5b.d b/ld/testsuite/ld-x86-64/pr20253-5b.d
new file mode 100644
index 0000000..c1cb335
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr20253-5b.d
@@ -0,0 +1,8 @@
+#source: pr20253-5.s
+#as: --x32
+#ld: -melf32_x86_64
+#readelf: -r --wide
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 7fd953b..f6f89e2 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -503,6 +503,27 @@ run_dump_test "pr19609-7d"
run_dump_test "pr19939a"
run_dump_test "pr19939b"
run_dump_test "pr19719"
+run_dump_test "pr20253-1a"
+run_dump_test "pr20253-1b"
+run_dump_test "pr20253-1c"
+run_dump_test "pr20253-1d"
+run_dump_test "pr20253-1e"
+run_dump_test "pr20253-1f"
+run_dump_test "pr20253-1g"
+run_dump_test "pr20253-1h"
+run_dump_test "pr20253-1i"
+run_dump_test "pr20253-1j"
+run_dump_test "pr20253-1k"
+run_dump_test "pr20253-1l"
+run_dump_test "pr20253-3"
+run_dump_test "pr20253-4a"
+run_dump_test "pr20253-4b"
+run_dump_test "pr20253-4c"
+run_dump_test "pr20253-4d"
+run_dump_test "pr20253-4e"
+run_dump_test "pr20253-4f"
+run_dump_test "pr20253-5a"
+run_dump_test "pr20253-5b"
proc undefined_weak {cflags ldflags} {
set testname "Undefined weak symbol"