aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
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-i386
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-i386')
-rw-r--r--ld/testsuite/ld-i386/i386.exp5
-rw-r--r--ld/testsuite/ld-i386/no-plt.exp118
-rw-r--r--ld/testsuite/ld-i386/pr13302.d4
-rw-r--r--ld/testsuite/ld-i386/pr20244-2a.d33
-rw-r--r--ld/testsuite/ld-i386/pr20244-2b.d3
-rw-r--r--ld/testsuite/ld-i386/pr20244-2c.d4
-rw-r--r--ld/testsuite/ld-i386/pr20253-1a.c8
-rw-r--r--ld/testsuite/ld-i386/pr20253-1b.S52
-rw-r--r--ld/testsuite/ld-i386/pr20253-1c.S35
-rw-r--r--ld/testsuite/ld-i386/pr20253-1d.S81
-rw-r--r--ld/testsuite/ld-i386/pr20253-2a.c8
-rw-r--r--ld/testsuite/ld-i386/pr20253-2b.S39
-rw-r--r--ld/testsuite/ld-i386/pr20253-2c.S24
-rw-r--r--ld/testsuite/ld-i386/pr20253-2d.S49
-rw-r--r--ld/testsuite/ld-i386/pr20253-3.d3
-rw-r--r--ld/testsuite/ld-i386/pr20253-3.s11
-rw-r--r--ld/testsuite/ld-i386/pr20253-4.s11
-rw-r--r--ld/testsuite/ld-i386/pr20253-4a.d8
-rw-r--r--ld/testsuite/ld-i386/pr20253-4b.d8
-rw-r--r--ld/testsuite/ld-i386/pr20253-4c.d9
-rw-r--r--ld/testsuite/ld-i386/pr20253-5.d7
-rw-r--r--ld/testsuite/ld-i386/pr20253-5.s10
22 files changed, 500 insertions, 30 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 98f0b1c..9efe406 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -408,6 +408,11 @@ run_dump_test "pr20244-2a"
run_dump_test "pr20244-2b"
run_dump_test "pr20244-2c"
run_dump_test "pr20244-2d"
+run_dump_test "pr20253-3"
+run_dump_test "pr20253-4a"
+run_dump_test "pr20253-4b"
+run_dump_test "pr20253-4c"
+run_dump_test "pr20253-5"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/no-plt.exp b/ld/testsuite/ld-i386/no-plt.exp
index c4af0a9..377253c 100644
--- a/ld/testsuite/ld-i386/no-plt.exp
+++ b/ld/testsuite/ld-i386/no-plt.exp
@@ -265,6 +265,27 @@ if { [check_ifunc_available] } {
"-fPIC -O2 -g" \
{ pr20244-3a.c pr20244-3b.S pr20244-3c.S pr20244-3d.S } \
] \
+ [list \
+ "Build pr20253-1a.o pr20253-1b.o pr20253-1c.o pr20253-1d.o" \
+ "" \
+ "-fPIE -O2 -g" \
+ { pr20253-1a.c pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
+ ] \
+ [list \
+ "Build libpr20253-1a.so" \
+ "-shared tmpdir/pr20253-1b.o \
+ tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
+ "" \
+ { dummy.s } \
+ {} \
+ "libpr20253-1a.so" \
+ ] \
+ [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 } \
+ ] \
]
run_ld_link_exec_tests [] [list \
@@ -286,5 +307,102 @@ if { [check_ifunc_available] } {
"pr20244-3b" \
"pass.out" \
] \
+ [list \
+ "Run pr20253-1a" \
+ "tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
+ tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-1a" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-1b" \
+ "--static tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
+ tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-1b" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-1c" \
+ "-pie tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
+ tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
+ "" \
+ { dummy.s } \
+ "pr20253-1c" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-1d" \
+ "tmpdir/pr20253-1a.o tmpdir/libpr20253-1a.so" \
+ "" \
+ { dummy.s } \
+ "pr20253-1d" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-1e" \
+ "-pie tmpdir/pr20253-1a.o tmpdir/libpr20253-1a.so" \
+ "" \
+ { dummy.s } \
+ "pr20253-1e" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr20253-1f" \
+ "tmpdir/pr20253-1a.o" \
+ "" \
+ { pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
+ "pr20253-1f" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
+ [list \
+ "Run pr20253-1g" \
+ "--static tmpdir/pr20253-1a.o" \
+ "" \
+ { pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
+ "pr20253-1g" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
+ [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" \
+ "tmpdir/pr20253-2a.o" \
+ "" \
+ { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
+ "pr20253-2c" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
+ [list \
+ "Run pr20253-2d" \
+ "--static tmpdir/pr20253-2a.o" \
+ "" \
+ { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
+ "pr20253-2d" \
+ "pass.out" \
+ "-DCHECK_PLT" \
+ ] \
]
}
diff --git a/ld/testsuite/ld-i386/pr13302.d b/ld/testsuite/ld-i386/pr13302.d
index 35c09ae..9ab4fa5 100644
--- a/ld/testsuite/ld-i386/pr13302.d
+++ b/ld/testsuite/ld-i386/pr13302.d
@@ -6,7 +6,3 @@
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name
[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
-
-Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
- Offset Info Type Sym. Value Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr20244-2a.d b/ld/testsuite/ld-i386/pr20244-2a.d
index a04902f..ec3948e 100644
--- a/ld/testsuite/ld-i386/pr20244-2a.d
+++ b/ld/testsuite/ld-i386/pr20244-2a.d
@@ -8,36 +8,25 @@
SYMBOL TABLE:
#...
-0+80480b1 l i .text 00000000 bar
+0+8048085 l i .text 00000000 bar
#...
-0+80480b2 g F .text 00000000 _start
+0+8048086 g F .text 00000000 _start
#...
-0+80480b0 g i .text 00000000 foo
+0+8048084 g i .text 00000000 foo
#...
-
-Disassembly of section .plt:
-
-0+8048090 <.plt>:
- +[a-f0-9]+: ff 25 e0 90 04 08 jmp \*0x80490e0
- +[a-f0-9]+: 68 00 00 00 00 push \$0x0
- +[a-f0-9]+: e9 00 00 00 00 jmp 80480a0 <foo-0x10>
- +[a-f0-9]+: ff 25 e4 90 04 08 jmp \*0x80490e4
- +[a-f0-9]+: 68 00 00 00 00 push \$0x0
- +[a-f0-9]+: e9 00 00 00 00 jmp 80480b0 <foo>
-
Disassembly of section .text:
-0+80480b0 <foo>:
+0+8048084 <foo>:
+[a-f0-9]+: c3 ret
-0+80480b1 <bar>:
+0+8048085 <bar>:
+[a-f0-9]+: c3 ret
-0+80480b2 <_start>:
- +[a-f0-9]+: ff 15 e0 90 04 08 call \*0x80490e0
- +[a-f0-9]+: ff 25 e4 90 04 08 jmp \*0x80490e4
- +[a-f0-9]+: c7 05 e4 90 04 08 00 00 00 00 movl \$0x0,0x80490e4
- +[a-f0-9]+: 83 3d e0 90 04 08 00 cmpl \$0x0,0x80490e0
- +[a-f0-9]+: b9 10 00 00 00 mov \$0x10,%ecx
+0+8048086 <_start>:
+ +[a-f0-9]+: ff 15 a8 90 04 08 call \*0x80490a8
+ +[a-f0-9]+: ff 25 ac 90 04 08 jmp \*0x80490ac
+ +[a-f0-9]+: c7 05 ac 90 04 08 00 00 00 00 movl \$0x0,0x80490ac
+ +[a-f0-9]+: 83 3d a8 90 04 08 00 cmpl \$0x0,0x80490a8
+ +[a-f0-9]+: b9 fc ff ff ff mov \$0xfffffffc,%ecx
#pass
diff --git a/ld/testsuite/ld-i386/pr20244-2b.d b/ld/testsuite/ld-i386/pr20244-2b.d
index fc0fa17..f23a406 100644
--- a/ld/testsuite/ld-i386/pr20244-2b.d
+++ b/ld/testsuite/ld-i386/pr20244-2b.d
@@ -7,5 +7,4 @@
.*: +file format .*
Contents of section .got.plt:
- 80490d4 00000000 00000000 00000000 b0800408 ................
- 80490e4 b1800408 ....
+ 80490b0 00000000 00000000 00000000 ............
diff --git a/ld/testsuite/ld-i386/pr20244-2c.d b/ld/testsuite/ld-i386/pr20244-2c.d
index 54eee9f..acca560 100644
--- a/ld/testsuite/ld-i386/pr20244-2c.d
+++ b/ld/testsuite/ld-i386/pr20244-2c.d
@@ -6,5 +6,5 @@
Relocation section '.rel.plt' at offset 0x74 contains 2 entries:
Offset Info Type Sym. Value Symbol's Name
-0+80490e4 0000002a R_386_IRELATIVE
-0+80490e0 0000002a R_386_IRELATIVE
+0+80490ac 0000002a R_386_IRELATIVE
+0+80490a8 0000002a R_386_IRELATIVE
diff --git a/ld/testsuite/ld-i386/pr20253-1a.c b/ld/testsuite/ld-i386/pr20253-1a.c
new file mode 100644
index 0000000..370275a
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-1a.c
@@ -0,0 +1,8 @@
+extern void check (void);
+
+int
+main ()
+{
+ check ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-i386/pr20253-1b.S b/ld/testsuite/ld-i386/pr20253-1b.S
new file mode 100644
index 0000000..93c6d26
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-1b.S
@@ -0,0 +1,52 @@
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "PASS"
+ .text
+ .globl check
+ .type check, @function
+check:
+ pushl %ebx
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $8, %esp
+ call *get_func1@GOT(%ebx)
+#ifdef CHECK_PLT
+ cmpl $func1, %eax
+#else
+ cmpl func1@GOT(%ebx), %eax
+#endif
+ jne .L3
+ movl func1_p@GOT(%ebx), %edx
+ cmpl %eax, (%edx)
+ jne .L3
+ call *func1@GOT(%ebx)
+ cmpl $1, %eax
+ jne .L3
+ call *call_func1@GOT(%ebx)
+ cmpl $1, %eax
+ jne .L3
+ call *get_func2@GOT(%ebx)
+ movl func2_p@GOT(%ebx), %edx
+ cmpl %eax, (%edx)
+ jne .L3
+ call *call_func2@GOT(%ebx)
+ cmpl $2, %eax
+ jne .L3
+ leal .LC0@GOTOFF(%ebx), %eax
+ subl $12, %esp
+ pushl %eax
+ call *puts@GOT(%ebx)
+ addl $24, %esp
+ popl %ebx
+ ret
+.L3:
+ call *abort@GOT(%ebx)
+ .size check, .-check
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+ movl (%esp), %ebx
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-1c.S b/ld/testsuite/ld-i386/pr20253-1c.S
new file mode 100644
index 0000000..8a17e7c
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-1c.S
@@ -0,0 +1,35 @@
+ .text
+ .globl get_func1
+ .type get_func1, @function
+get_func1:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ movl func1@GOT(%eax), %eax
+ ret
+ .size get_func1, .-get_func1
+ .globl call_func1
+ .type call_func1, @function
+call_func1:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ jmp *func1@GOT(%eax)
+ .size call_func1, .-call_func1
+ .globl func1_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+ .align 4
+ .type func1_p, @object
+ .size func1_p, 4
+func1_p:
+ .long func1
+ .section .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
+ .globl __x86.get_pc_thunk.ax
+ .hidden __x86.get_pc_thunk.ax
+ .type __x86.get_pc_thunk.ax, @function
+__x86.get_pc_thunk.ax:
+ movl (%esp), %eax
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-1d.S b/ld/testsuite/ld-i386/pr20253-1d.S
new file mode 100644
index 0000000..2d6a1de
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-1d.S
@@ -0,0 +1,81 @@
+ .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:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ leal implementation2@GOTOFF(%eax), %eax
+ ret
+ .size resolver2, .-resolver2
+ .type func2, @gnu_indirect_function
+ .set func2,resolver2
+ .type resolver1, @function
+resolver1:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ leal implementation1@GOTOFF(%eax), %eax
+ ret
+ .size resolver1, .-resolver1
+ .globl func1
+ .type func1, @gnu_indirect_function
+ .set func1,resolver1
+ .globl get_func2
+ .type get_func2, @function
+get_func2:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ movl func2@GOT(%eax), %eax
+ ret
+ .size get_func2, .-get_func2
+ .globl call_func2
+ .type call_func2, @function
+call_func2:
+ pushl %ebx
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $8, %esp
+ call *get_func2@GOT(%ebx)
+ cmpl func2@GOT(%ebx), %eax
+ jne .L10
+ addl $8, %esp
+ movl %ebx, %eax
+ popl %ebx
+ jmp *func2@GOT(%eax)
+.L10:
+ call *abort@GOT(%ebx)
+ .size call_func2, .-call_func2
+ .globl func2_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+ .align 4
+ .type func2_p, @object
+ .size func2_p, 4
+func2_p:
+ .long func2
+ .section .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
+ .globl __x86.get_pc_thunk.ax
+ .hidden __x86.get_pc_thunk.ax
+ .type __x86.get_pc_thunk.ax, @function
+__x86.get_pc_thunk.ax:
+ movl (%esp), %eax
+ ret
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+ movl (%esp), %ebx
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-2a.c b/ld/testsuite/ld-i386/pr20253-2a.c
new file mode 100644
index 0000000..370275a
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-2a.c
@@ -0,0 +1,8 @@
+extern void check (void);
+
+int
+main ()
+{
+ check ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-i386/pr20253-2b.S b/ld/testsuite/ld-i386/pr20253-2b.S
new file mode 100644
index 0000000..46ab4f4
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-2b.S
@@ -0,0 +1,39 @@
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "PASS"
+ .text
+ .globl check
+ .type check, @function
+check:
+ subl $12, %esp
+ call *get_func1@GOT
+#ifdef CHECK_PLT
+ movl $func1, %edx
+#else
+ movl func1@GOT, %edx
+#endif
+ cmpl %edx, %eax
+ jne .L3
+ cmpl %edx, func1_p
+ jne .L3
+ call *func1@GOT
+ cmpl $1, %eax
+ jne .L3
+ call *call_func1@GOT
+ cmpl $1, %eax
+ jne .L3
+ call *get_func2@GOT
+ cmpl %eax, func2_p
+ jne .L3
+ call *call_func2@GOT
+ cmpl $2, %eax
+ jne .L3
+ subl $12, %esp
+ pushl $.LC0
+ call *puts@GOT
+ addl $28, %esp
+ ret
+.L3:
+ call *abort@GOT
+ .size check, .-check
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-2c.S b/ld/testsuite/ld-i386/pr20253-2c.S
new file mode 100644
index 0000000..7e724b4
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-2c.S
@@ -0,0 +1,24 @@
+ .text
+ .globl get_func1
+ .type get_func1, @function
+get_func1:
+ movl func1@GOT, %eax
+ ret
+ .size get_func1, .-get_func1
+ .globl call_func1
+ .type call_func1, @function
+call_func1:
+ jmp *func1@GOT
+ .size call_func1, .-call_func1
+ .globl func1_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+ .align 4
+ .type func1_p, @object
+ .size func1_p, 4
+func1_p:
+ .long func1
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-2d.S b/ld/testsuite/ld-i386/pr20253-2d.S
new file mode 100644
index 0000000..5c1f9ae
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-2d.S
@@ -0,0 +1,49 @@
+ .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:
+ movl $implementation2, %eax
+ ret
+ .size resolver2, .-resolver2
+ .type func2, @gnu_indirect_function
+ .set func2,resolver2
+ .type resolver1, @function
+resolver1:
+ movl $implementation1, %eax
+ ret
+ .size resolver1, .-resolver1
+ .globl func1
+ .type func1, @gnu_indirect_function
+ .set func1,resolver1
+ .globl get_func2
+ .type get_func2, @function
+get_func2:
+ movl func2@GOT, %eax
+ ret
+ .size get_func2, .-get_func2
+ .globl call_func2
+ .type call_func2, @function
+call_func2:
+ jmp *func2@GOT
+ .size call_func2, .-call_func2
+ .globl func2_p
+#ifdef CHECK_PLT
+ .section .rodata,"a",@progbits
+#else
+ .section .data.rel,"aw",@progbits
+#endif
+ .align 4
+ .type func2_p, @object
+ .size func2_p, 4
+func2_p:
+ .long func2
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr20253-3.d b/ld/testsuite/ld-i386/pr20253-3.d
new file mode 100644
index 0000000..7ce0b58
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-3.d
@@ -0,0 +1,3 @@
+#as: --32
+#ld: -melf_i386
+#error: relocation R_386_PC32 against STT_GNU_IFUNC symbol `foo' isn't supported
diff --git a/ld/testsuite/ld-i386/pr20253-3.s b/ld/testsuite/ld-i386/pr20253-3.s
new file mode 100644
index 0000000..8cd25fb
--- /dev/null
+++ b/ld/testsuite/ld-i386/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-i386/pr20253-4.s b/ld/testsuite/ld-i386/pr20253-4.s
new file mode 100644
index 0000000..88f0f1b
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-4.s
@@ -0,0 +1,11 @@
+ .text
+ .type foo,%gnu_indirect_function
+foo:
+ ret
+ .globl _start
+_start:
+ movl __start@GOT(%eax), %eax
+ .globl __start
+__start:
+ .data
+ .dc.a foo
diff --git a/ld/testsuite/ld-i386/pr20253-4a.d b/ld/testsuite/ld-i386/pr20253-4a.d
new file mode 100644
index 0000000..cd10080
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-4a.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --32 -mrelax-relocations=yes
+#ld: -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr20253-4b.d b/ld/testsuite/ld-i386/pr20253-4b.d
new file mode 100644
index 0000000..3b45f8f
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-4b.d
@@ -0,0 +1,8 @@
+#source: pr20253-4.s
+#as: --32 -mrelax-relocations=yes
+#ld: -pie -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr20253-4c.d b/ld/testsuite/ld-i386/pr20253-4c.d
new file mode 100644
index 0000000..6fa68aa
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-4c.d
@@ -0,0 +1,9 @@
+#source: pr20253-4.s
+#as: --32 -mrelax-relocations=yes
+#ld: -shared -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +[0-9a-f]+ +__start
+[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr20253-5.d b/ld/testsuite/ld-i386/pr20253-5.d
new file mode 100644
index 0000000..0936d98
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-5.d
@@ -0,0 +1,7 @@
+#as: --32
+#ld: -melf_i386
+#readelf: -r --wide
+
+Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym.* Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
diff --git a/ld/testsuite/ld-i386/pr20253-5.s b/ld/testsuite/ld-i386/pr20253-5.s
new file mode 100644
index 0000000..0cc1803
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr20253-5.s
@@ -0,0 +1,10 @@
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ call *func1@GOT(%eax)
+ cmp $func1,%eax
+ .globl func1
+ .type func1, @gnu_indirect_function
+func1:
+ ret