mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-05 00:04:22 +08:00
i386: Test external function reference without PLT
To call an external function, the direct branch to the PLT entry can be replaced by an indirect branch via the GOT slot, which is similar to the first instruction in the PLT slot. Instead using the PLT slot as function address, the function address is retrieved from the GOT slot. The R_386_GOT32X relocation can be used to compute the address of the symbol’s GOT entry without base register when PIC is disabled. In non-PIC executable, call/jmp *func@GOT should be used for indirect branch via the GOT slot and movl func@GOT, %eax should be used to load function address. Unlike PIC case, no register is needed to access GOT. If linker determines the function is defined locally, it converts indirect branch via the GOT slot to direct branch with a nop prefix and converts load via the GOT slot to load immediate or lea. * testsuite/ld-i386/libno-plt-1b.dd: New file. * testsuite/ld-i386/libno-plt-1b.rd: Likewise. * testsuite/ld-i386/no-plt-1a.dd: Likewise. * testsuite/ld-i386/no-plt-1a.rd: Likewise. * testsuite/ld-i386/no-plt-1b.dd: Likewise. * testsuite/ld-i386/no-plt-1b.rd: Likewise. * testsuite/ld-i386/no-plt-1c.dd: Likewise. * testsuite/ld-i386/no-plt-1c.rd: Likewise. * testsuite/ld-i386/no-plt-1d.dd: Likewise. * testsuite/ld-i386/no-plt-1d.rd: Likewise. * testsuite/ld-i386/no-plt-1e.dd: Likewise. * testsuite/ld-i386/no-plt-1e.rd: Likewise. * testsuite/ld-i386/no-plt-1f.dd: Likewise. * testsuite/ld-i386/no-plt-1f.rd: Likewise. * testsuite/ld-i386/no-plt-1g.dd: Likewise. * testsuite/ld-i386/no-plt-1g.rd: Likewise. * testsuite/ld-i386/no-plt-1h.dd: Likewise. * testsuite/ld-i386/no-plt-1h.rd: Likewise. * testsuite/ld-i386/no-plt-1i.dd: Likewise. * testsuite/ld-i386/no-plt-1i.rd: Likewise. * testsuite/ld-i386/no-plt-1j.dd: Likewise. * testsuite/ld-i386/no-plt-1j.rd: Likewise. * testsuite/ld-i386/no-plt-check1a.S: Likewise. * testsuite/ld-i386/no-plt-check1b.S: Likewise. * testsuite/ld-i386/no-plt-extern1a.S: Likewise. * testsuite/ld-i386/no-plt-extern1b.S: Likewise. * testsuite/ld-i386/no-plt-func1.c: Likewise. * testsuite/ld-i386/no-plt-main1.c: Likewise. * testsuite/ld-i386/no-plt.exp: Likewise.
This commit is contained in:
parent
dcc03cb366
commit
ffc89b17f2
19
ld/testsuite/ld-i386/libno-plt-1b.dd
Normal file
19
ld/testsuite/ld-i386/libno-plt-1b.dd
Normal file
@ -0,0 +1,19 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: 8b 80 ([0-9a-f]{2} ){4}[ ]+mov +-0x[a-f0-9]+\(%eax\),%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: ff a0 ([0-9a-f]{2} ){4}[ ]+jmp +\*-0x[0-9a-f]+\(%eax\)
|
||||
#pass
|
8
ld/testsuite/ld-i386/libno-plt-1b.rd
Normal file
8
ld/testsuite/ld-i386/libno-plt-1b.rd
Normal file
@ -0,0 +1,8 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +func
|
||||
#pass
|
43
ld/testsuite/ld-i386/no-plt-1a.dd
Normal file
43
ld/testsuite/ld-i386/no-plt-1a.dd
Normal file
@ -0,0 +1,43 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 81 f8 ([0-9a-f]{2} ){4}[ ]+cmp +\$0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c7 c0 ([0-9a-f]{2} ){4}[ ]+mov +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: e9 ([0-9a-f]{2} ){4}[ ]+jmp +[0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 90 nop
|
||||
#pass
|
10
ld/testsuite/ld-i386/no-plt-1a.rd
Normal file
10
ld/testsuite/ld-i386/no-plt-1a.rd
Normal file
@ -0,0 +1,10 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#pass
|
31
ld/testsuite/ld-i386/no-plt-1b.dd
Normal file
31
ld/testsuite/ld-i386/no-plt-1b.dd
Normal file
@ -0,0 +1,31 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3b 83 ([0-9a-f]{2} ){4}[ ]+cmp +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#pass
|
16
ld/testsuite/ld-i386/no-plt-1b.rd
Normal file
16
ld/testsuite/ld-i386/no-plt-1b.rd
Normal file
@ -0,0 +1,16 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#pass
|
31
ld/testsuite/ld-i386/no-plt-1c.dd
Normal file
31
ld/testsuite/ld-i386/no-plt-1c.dd
Normal file
@ -0,0 +1,31 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 81 f8 ([0-9a-f]{2} ){4}[ ]+cmp +\$0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#pass
|
14
ld/testsuite/ld-i386/no-plt-1c.rd
Normal file
14
ld/testsuite/ld-i386/no-plt-1c.rd
Normal file
@ -0,0 +1,14 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#pass
|
43
ld/testsuite/ld-i386/no-plt-1d.dd
Normal file
43
ld/testsuite/ld-i386/no-plt-1d.dd
Normal file
@ -0,0 +1,43 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 81 f8 ([0-9a-f]{2} ){4}[ ]+cmp +\$0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <.*puts.*>
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <abort>
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c7 c0 ([0-9a-f]{2} ){4}[ ]+mov +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: e9 ([0-9a-f]{2} ){4}[ ]+jmp +[0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 90 nop
|
||||
#pass
|
7
ld/testsuite/ld-i386/no-plt-1d.rd
Normal file
7
ld/testsuite/ld-i386/no-plt-1d.rd
Normal file
@ -0,0 +1,7 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
#failif
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +.*
|
||||
#pass
|
43
ld/testsuite/ld-i386/no-plt-1e.dd
Normal file
43
ld/testsuite/ld-i386/no-plt-1e.dd
Normal file
@ -0,0 +1,43 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 3b 83 ([0-9a-f]{2} ){4}[ ]+cmp +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: 8d 80 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%eax\),%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call +[a-f0-9]+ <__x86.get_pc_thunk.ax>
|
||||
+[a-f0-9]+: 05 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: e9 ([0-9a-f]{2} ){4}[ ]+jmp +[0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 90 nop
|
||||
#pass
|
10
ld/testsuite/ld-i386/no-plt-1e.rd
Normal file
10
ld/testsuite/ld-i386/no-plt-1e.rd
Normal file
@ -0,0 +1,10 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#pass
|
31
ld/testsuite/ld-i386/no-plt-1f.dd
Normal file
31
ld/testsuite/ld-i386/no-plt-1f.dd
Normal file
@ -0,0 +1,31 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3b 83 ([0-9a-f]{2} ){4}[ ]+cmp +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#pass
|
16
ld/testsuite/ld-i386/no-plt-1f.rd
Normal file
16
ld/testsuite/ld-i386/no-plt-1f.rd
Normal file
@ -0,0 +1,16 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func|func)
|
||||
#pass
|
31
ld/testsuite/ld-i386/no-plt-1g.dd
Normal file
31
ld/testsuite/ld-i386/no-plt-1g.dd
Normal file
@ -0,0 +1,31 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 53 push %ebx
|
||||
+[a-f0-9]+: e8 ([0-9a-f]{2} ){4}[ ]+call [a-f0-9]+ <__x86.get_pc_thunk.bx>
|
||||
+[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add +\$0x[a-f0-9]+,%ebx
|
||||
+[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3b 83 ([0-9a-f]{2} ){4}[ ]+cmp +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 75 2f jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 22 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 15 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 8d 83 ([0-9a-f]{2} ){4}[ ]+lea +-0x[a-f0-9]+\(%ebx\),%eax
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 50 push %eax
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
+[a-f0-9]+: 83 c4 18 add \$0x18,%esp
|
||||
+[a-f0-9]+: 5b pop %ebx
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 93 ([0-9a-f]{2} ){4}[ ]+call +\*-0x[0-9a-f]+\(%ebx\)
|
||||
#pass
|
14
ld/testsuite/ld-i386/no-plt-1g.rd
Normal file
14
ld/testsuite/ld-i386/no-plt-1g.rd
Normal file
@ -0,0 +1,14 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|get_func|call_func)
|
||||
#pass
|
34
ld/testsuite/ld-i386/no-plt-1h.dd
Normal file
34
ld/testsuite/ld-i386/no-plt-1h.dd
Normal file
@ -0,0 +1,34 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 81 f8 ([0-9a-f]{2} ){4}[ ]+cmp +\$0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2c jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 1f jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 12 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 68 ([0-9a-f]{2} ){4}[ ]+push +\$0x[0-9a-f]+
|
||||
+[a-f0-9]+: ff 15 ([0-9a-f]{2} ){4}[ ]+call +\*0x[0-9a-f]+
|
||||
+[a-f0-9]+: 83 c4 1c add \$0x1c,%esp
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 15 ([0-9a-f]{2} ){4}[ ]+call +\*0x[0-9a-f]+
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: c7 c0 ([0-9a-f]{2} ){4}[ ]+mov +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e9 ([0-9a-f]{2} ){4}[ ]+jmp +[0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 90 nop
|
||||
#pass
|
10
ld/testsuite/ld-i386/no-plt-1h.rd
Normal file
10
ld/testsuite/ld-i386/no-plt-1h.rd
Normal file
@ -0,0 +1,10 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort|puts).*
|
||||
#pass
|
33
ld/testsuite/ld-i386/no-plt-1i.dd
Normal file
33
ld/testsuite/ld-i386/no-plt-1i.dd
Normal file
@ -0,0 +1,33 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 3b 05 ([0-9a-f]{2} ){4}[ ]+cmp +0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2c jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: ff 15 ([0-9a-f]{2} ){4}[ ]+call +\*0x[0-9a-f]+
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 1f jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 12 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 68 ([0-9a-f]{2} ){4}[ ]+push +\$0x[0-9a-f]+
|
||||
+[a-f0-9]+: ff 15 ([0-9a-f]{2} ){4}[ ]+call +\*0x[0-9a-f]+
|
||||
+[a-f0-9]+: 83 c4 1c add \$0x1c,%esp
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: ff 15 ([0-9a-f]{2} ){4}[ ]+call +\*0x[0-9a-f]+
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: 8b 05 ([0-9a-f]{2} ){4}[ ]+mov +0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmp +\*0x[0-9a-f]+
|
||||
#pass
|
12
ld/testsuite/ld-i386/no-plt-1i.rd
Normal file
12
ld/testsuite/ld-i386/no-plt-1i.rd
Normal file
@ -0,0 +1,12 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
+Offset +Info +Type +Sym. Value +Symbol's Name
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|func)
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +0+ +(abort.*|puts.*|func)
|
||||
#pass
|
34
ld/testsuite/ld-i386/no-plt-1j.dd
Normal file
34
ld/testsuite/ld-i386/no-plt-1j.dd
Normal file
@ -0,0 +1,34 @@
|
||||
#objdump: -dwrj.text
|
||||
#target: i?86-*-*
|
||||
|
||||
.*: +file format elf32-i386.*
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
#...
|
||||
[0-9a-f]+ <check>:
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <get_func>
|
||||
+[a-f0-9]+: 81 f8 ([0-9a-f]{2} ){4}[ ]+cmp +\$0x[0-9a-f]+,%eax
|
||||
+[a-f0-9]+: 75 2c jne [0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 1f jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <call_func>
|
||||
+[a-f0-9]+: 3d 78 56 34 12 cmp \$0x12345678,%eax
|
||||
+[a-f0-9]+: 75 12 jne +[0-9a-f]+ <check\+0x[0-9a-f]+>
|
||||
+[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
|
||||
+[a-f0-9]+: 68 ([0-9a-f]{2} ){4}[ ]+push +\$0x[0-9a-f]+
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <.*puts.*>
|
||||
+[a-f0-9]+: 83 c4 1c add \$0x1c,%esp
|
||||
+[a-f0-9]+: c3 ret
|
||||
+[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]+addr16 call [0-9a-f]+ <abort>
|
||||
#...
|
||||
[0-9a-f]+ <get_func>:
|
||||
+[a-f0-9]+: c7 c0 ([0-9a-f]{2} ){4}[ ]+mov +\$0x[a-f0-9]+,%eax
|
||||
+[a-f0-9]+: c3 ret
|
||||
#...
|
||||
[0-9a-f]+ <call_func>:
|
||||
+[a-f0-9]+: e9 ([0-9a-f]{2} ){4}[ ]+jmp +[0-9a-f]+ <func>
|
||||
+[a-f0-9]+: 90 nop
|
||||
#pass
|
7
ld/testsuite/ld-i386/no-plt-1j.rd
Normal file
7
ld/testsuite/ld-i386/no-plt-1j.rd
Normal file
@ -0,0 +1,7 @@
|
||||
#readelf: -Wr
|
||||
#target: i?86-*-*
|
||||
|
||||
#failif
|
||||
#...
|
||||
[0-9a-f ]+R_386_GLOB_DAT +.*
|
||||
#pass
|
39
ld/testsuite/ld-i386/no-plt-check1a.S
Normal file
39
ld/testsuite/ld-i386/no-plt-check1a.S
Normal file
@ -0,0 +1,39 @@
|
||||
.section .rodata.str1.1,"aMS",@progbits,1
|
||||
.LC0:
|
||||
.string "PASS"
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl check
|
||||
.type check, @function
|
||||
check:
|
||||
pushl %ebx
|
||||
call __x86.get_pc_thunk.bx
|
||||
addl $_GLOBAL_OFFSET_TABLE_, %ebx
|
||||
subl $8, %esp
|
||||
call *get_func@GOT(%ebx)
|
||||
cmpl func@GOT(%ebx), %eax
|
||||
jne .L3
|
||||
call *func@GOT(%ebx)
|
||||
cmpl $305419896, %eax
|
||||
jne .L3
|
||||
call *call_func@GOT(%ebx)
|
||||
cmpl $305419896, %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
|
28
ld/testsuite/ld-i386/no-plt-check1b.S
Normal file
28
ld/testsuite/ld-i386/no-plt-check1b.S
Normal file
@ -0,0 +1,28 @@
|
||||
.section .rodata.str1.1,"aMS",@progbits,1
|
||||
.LC0:
|
||||
.string "PASS"
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl check
|
||||
.type check, @function
|
||||
check:
|
||||
subl $12, %esp
|
||||
call *get_func@GOT
|
||||
cmpl func@GOT, %eax
|
||||
jne .L3
|
||||
call *func@GOT
|
||||
cmpl $305419896, %eax
|
||||
jne .L3
|
||||
call *call_func@GOT
|
||||
cmpl $305419896, %eax
|
||||
jne .L3
|
||||
subl $12, %esp
|
||||
pushl $.LC0
|
||||
call *puts@GOT
|
||||
addl $28, %esp
|
||||
ret
|
||||
.L3:
|
||||
call *abort@GOT
|
||||
.size check, .-check
|
||||
.text
|
||||
.section .note.GNU-stack,"",@progbits
|
26
ld/testsuite/ld-i386/no-plt-extern1a.S
Normal file
26
ld/testsuite/ld-i386/no-plt-extern1a.S
Normal file
@ -0,0 +1,26 @@
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl get_func
|
||||
.type get_func, @function
|
||||
get_func:
|
||||
call __x86.get_pc_thunk.ax
|
||||
addl $_GLOBAL_OFFSET_TABLE_, %eax
|
||||
movl func@GOT(%eax), %eax
|
||||
ret
|
||||
.size get_func, .-get_func
|
||||
.p2align 4,,15
|
||||
.globl call_func
|
||||
.type call_func, @function
|
||||
call_func:
|
||||
call __x86.get_pc_thunk.ax
|
||||
addl $_GLOBAL_OFFSET_TABLE_, %eax
|
||||
jmp *func@GOT(%eax)
|
||||
.size call_func, .-call_func
|
||||
.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
|
16
ld/testsuite/ld-i386/no-plt-extern1b.S
Normal file
16
ld/testsuite/ld-i386/no-plt-extern1b.S
Normal file
@ -0,0 +1,16 @@
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl get_func
|
||||
.type get_func, @function
|
||||
get_func:
|
||||
movl func@GOT, %eax
|
||||
ret
|
||||
.size get_func, .-get_func
|
||||
.p2align 4,,15
|
||||
.globl call_func
|
||||
.type call_func, @function
|
||||
call_func:
|
||||
jmp *func@GOT
|
||||
.size call_func, .-call_func
|
||||
.section .text.unlikely
|
||||
.section .note.GNU-stack,"",@progbits
|
5
ld/testsuite/ld-i386/no-plt-func1.c
Normal file
5
ld/testsuite/ld-i386/no-plt-func1.c
Normal file
@ -0,0 +1,5 @@
|
||||
int
|
||||
func (void)
|
||||
{
|
||||
return 0x12345678;
|
||||
}
|
8
ld/testsuite/ld-i386/no-plt-main1.c
Normal file
8
ld/testsuite/ld-i386/no-plt-main1.c
Normal file
@ -0,0 +1,8 @@
|
||||
extern void check (void);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
check ();
|
||||
return 0;
|
||||
}
|
257
ld/testsuite/ld-i386/no-plt.exp
Normal file
257
ld/testsuite/ld-i386/no-plt.exp
Normal file
@ -0,0 +1,257 @@
|
||||
# Expect script for i386 no-PLT tests.
|
||||
# Copyright (C) 2016 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU Binutils.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# The following tests require running the executable generated by ld,
|
||||
# or enough of a build environment to create a fully linked executable.
|
||||
# This is not commonly available when testing a cross-built linker.
|
||||
if ![isnative] {
|
||||
return
|
||||
}
|
||||
|
||||
if ![is_elf_format] {
|
||||
return
|
||||
}
|
||||
|
||||
if ![istarget "i?86-*-*"] {
|
||||
return
|
||||
}
|
||||
|
||||
# Check to see if the C compiler works
|
||||
if { [which $CC] == 0 } {
|
||||
return
|
||||
}
|
||||
|
||||
run_cc_link_tests [list \
|
||||
[list \
|
||||
"Build no-plt-func1.o no-plt-main1.o" \
|
||||
"" \
|
||||
"-fPIE" \
|
||||
{no-plt-func1.c no-plt-main1.c} \
|
||||
] \
|
||||
[list \
|
||||
"Build no-plt-check1a.o no-plt-extern1a.o \
|
||||
no-plt-check1b.o no-plt-extern1b.o" \
|
||||
"" \
|
||||
"-Wa,-mrelax-relocations=yes" \
|
||||
{no-plt-check1a.S no-plt-extern1a.S \
|
||||
no-plt-check1b.S no-plt-extern1b.S } \
|
||||
] \
|
||||
[list \
|
||||
"Build libno-plt-1a.so" \
|
||||
"-shared tmpdir/no-plt-func1.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{} \
|
||||
"libno-plt-1a.so" \
|
||||
] \
|
||||
[list \
|
||||
"Build libno-plt-1b.so" \
|
||||
"-shared tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr libno-plt-1b.rd} \
|
||||
{objdump -dwrj.text libno-plt-1b.dd}} \
|
||||
"libno-plt-1b.so" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1a)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \
|
||||
"no-plt-1a" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1b)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1b.rd} {objdump -dwrj.text no-plt-1b.dd}} \
|
||||
"no-plt-1b" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1c)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \
|
||||
"no-plt-1c" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (static 1d)" \
|
||||
"-static tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \
|
||||
"no-plt-1d" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1e)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1e.rd} {objdump -dwrj.text no-plt-1e.dd}} \
|
||||
"no-plt-1e" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1f)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
{{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \
|
||||
"no-plt-1f" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1g)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
{{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \
|
||||
"no-plt-1g" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1h)" \
|
||||
"tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1h.rd} {objdump -dwrj.text no-plt-1h.dd}} \
|
||||
"no-plt-1h" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1i)" \
|
||||
"tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1i.rd} {objdump -dwrj.text no-plt-1i.dd}} \
|
||||
"no-plt-1i" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (static 1j)" \
|
||||
"-static tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
{{readelf -Wr no-plt-1j.rd} {objdump -dwrj.text no-plt-1j.dd}} \
|
||||
"no-plt-1j" \
|
||||
] \
|
||||
]
|
||||
|
||||
run_ld_link_exec_tests [] [list \
|
||||
[list \
|
||||
"No PLT (dynamic 1a)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1a" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1b)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1b" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1c)" \
|
||||
"tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1c" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (static 1d)" \
|
||||
"-static tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1d" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1e)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1e" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1f)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1f" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (PIE 1g)" \
|
||||
"-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
|
||||
"" \
|
||||
{ dummy.s } \
|
||||
"no-plt-1g" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1h)" \
|
||||
"tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
"no-plt-1h" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (dynamic 1i)" \
|
||||
"tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
"no-plt-1i" \
|
||||
"pass.out" \
|
||||
] \
|
||||
[list \
|
||||
"No PLT (static 1j)" \
|
||||
"-static tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
|
||||
tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
|
||||
"" \
|
||||
{dummy.s} \
|
||||
"no-plt-1j" \
|
||||
"pass.out" \
|
||||
] \
|
||||
]
|
Loading…
Reference in New Issue
Block a user