i386: Test external function reference without PLT
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 8 Jun 2016 19:41:50 +0000 (12:41 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 8 Jun 2016 19:41:50 +0000 (12:41 -0700)
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.

29 files changed:
ld/testsuite/ld-i386/libno-plt-1b.dd [new file with mode: 0644]
ld/testsuite/ld-i386/libno-plt-1b.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1a.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1a.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1b.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1b.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1c.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1c.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1d.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1d.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1e.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1e.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1f.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1f.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1g.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1g.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1h.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1h.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1i.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1i.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1j.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1j.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-check1a.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-check1b.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-extern1a.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-extern1b.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-func1.c [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-main1.c [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt.exp [new file with mode: 0644]

diff --git a/ld/testsuite/ld-i386/libno-plt-1b.dd b/ld/testsuite/ld-i386/libno-plt-1b.dd
new file mode 100644 (file)
index 0000000..507ed16
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/libno-plt-1b.rd b/ld/testsuite/ld-i386/libno-plt-1b.rd
new file mode 100644 (file)
index 0000000..6881a2d
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1a.dd b/ld/testsuite/ld-i386/no-plt-1a.dd
new file mode 100644 (file)
index 0000000..8fcf9cf
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1a.rd b/ld/testsuite/ld-i386/no-plt-1a.rd
new file mode 100644 (file)
index 0000000..4aad3c4
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1b.dd b/ld/testsuite/ld-i386/no-plt-1b.dd
new file mode 100644 (file)
index 0000000..5af3471
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1b.rd b/ld/testsuite/ld-i386/no-plt-1b.rd
new file mode 100644 (file)
index 0000000..638dd6d
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1c.dd b/ld/testsuite/ld-i386/no-plt-1c.dd
new file mode 100644 (file)
index 0000000..ebfc403
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1c.rd b/ld/testsuite/ld-i386/no-plt-1c.rd
new file mode 100644 (file)
index 0000000..bf8cd22
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1d.dd b/ld/testsuite/ld-i386/no-plt-1d.dd
new file mode 100644 (file)
index 0000000..246b252
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1d.rd b/ld/testsuite/ld-i386/no-plt-1d.rd
new file mode 100644 (file)
index 0000000..b7f75a3
--- /dev/null
@@ -0,0 +1,7 @@
+#readelf: -Wr
+#target: i?86-*-*
+
+#failif
+#...
+[0-9a-f ]+R_386_GLOB_DAT +.*
+#pass
diff --git a/ld/testsuite/ld-i386/no-plt-1e.dd b/ld/testsuite/ld-i386/no-plt-1e.dd
new file mode 100644 (file)
index 0000000..2787dae
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1e.rd b/ld/testsuite/ld-i386/no-plt-1e.rd
new file mode 100644 (file)
index 0000000..4aad3c4
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1f.dd b/ld/testsuite/ld-i386/no-plt-1f.dd
new file mode 100644 (file)
index 0000000..5af3471
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1f.rd b/ld/testsuite/ld-i386/no-plt-1f.rd
new file mode 100644 (file)
index 0000000..638dd6d
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1g.dd b/ld/testsuite/ld-i386/no-plt-1g.dd
new file mode 100644 (file)
index 0000000..546c16d
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1g.rd b/ld/testsuite/ld-i386/no-plt-1g.rd
new file mode 100644 (file)
index 0000000..bf8cd22
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1h.dd b/ld/testsuite/ld-i386/no-plt-1h.dd
new file mode 100644 (file)
index 0000000..9d07d39
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1h.rd b/ld/testsuite/ld-i386/no-plt-1h.rd
new file mode 100644 (file)
index 0000000..4aad3c4
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1i.dd b/ld/testsuite/ld-i386/no-plt-1i.dd
new file mode 100644 (file)
index 0000000..d6f93b7
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1i.rd b/ld/testsuite/ld-i386/no-plt-1i.rd
new file mode 100644 (file)
index 0000000..981f76e
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1j.dd b/ld/testsuite/ld-i386/no-plt-1j.dd
new file mode 100644 (file)
index 0000000..50fd693
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-1j.rd b/ld/testsuite/ld-i386/no-plt-1j.rd
new file mode 100644 (file)
index 0000000..b7f75a3
--- /dev/null
@@ -0,0 +1,7 @@
+#readelf: -Wr
+#target: i?86-*-*
+
+#failif
+#...
+[0-9a-f ]+R_386_GLOB_DAT +.*
+#pass
diff --git a/ld/testsuite/ld-i386/no-plt-check1a.S b/ld/testsuite/ld-i386/no-plt-check1a.S
new file mode 100644 (file)
index 0000000..1699dbe
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-check1b.S b/ld/testsuite/ld-i386/no-plt-check1b.S
new file mode 100644 (file)
index 0000000..d27ab83
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-extern1a.S b/ld/testsuite/ld-i386/no-plt-extern1a.S
new file mode 100644 (file)
index 0000000..38d4dd0
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-extern1b.S b/ld/testsuite/ld-i386/no-plt-extern1b.S
new file mode 100644 (file)
index 0000000..ab35bbe
--- /dev/null
@@ -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
diff --git a/ld/testsuite/ld-i386/no-plt-func1.c b/ld/testsuite/ld-i386/no-plt-func1.c
new file mode 100644 (file)
index 0000000..ec4040c
--- /dev/null
@@ -0,0 +1,5 @@
+int
+func (void)
+{
+  return 0x12345678;
+}
diff --git a/ld/testsuite/ld-i386/no-plt-main1.c b/ld/testsuite/ld-i386/no-plt-main1.c
new file mode 100644 (file)
index 0000000..370275a
--- /dev/null
@@ -0,0 +1,8 @@
+extern void check (void);
+
+int
+main ()
+{
+  check ();
+  return 0;
+}
diff --git a/ld/testsuite/ld-i386/no-plt.exp b/ld/testsuite/ld-i386/no-plt.exp
new file mode 100644 (file)
index 0000000..87d64b9
--- /dev/null
@@ -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" \
+    ] \
+]