summaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-i386/got1.dd19
-rw-r--r--ld/testsuite/ld-i386/got1.out7
-rw-r--r--ld/testsuite/ld-i386/got1a.S20
-rw-r--r--ld/testsuite/ld-i386/got1b.c7
-rw-r--r--ld/testsuite/ld-i386/got1c.c7
-rw-r--r--ld/testsuite/ld-i386/got1d.S54
-rw-r--r--ld/testsuite/ld-i386/i386.exp30
-rw-r--r--ld/testsuite/ld-i386/lea1c.d2
-rw-r--r--ld/testsuite/ld-i386/lea2.s9
-rw-r--r--ld/testsuite/ld-i386/lea2a.d4
-rw-r--r--ld/testsuite/ld-i386/lea2b.d13
-rw-r--r--ld/testsuite/ld-i386/lea3.s15
-rw-r--r--ld/testsuite/ld-i386/lea3a.d18
-rw-r--r--ld/testsuite/ld-i386/lea3b.d18
-rw-r--r--ld/testsuite/ld-i386/lea4.s8
-rw-r--r--ld/testsuite/ld-i386/lea4a.d4
-rw-r--r--ld/testsuite/ld-i386/lea4b.d13
-rw-r--r--ld/testsuite/ld-i386/plt-main1.rd2
-rw-r--r--ld/testsuite/ld-i386/plt-main3.rd2
-rw-r--r--ld/testsuite/ld-i386/plt-main4.rd2
20 files changed, 250 insertions, 4 deletions
diff --git a/ld/testsuite/ld-i386/got1.dd b/ld/testsuite/ld-i386/got1.dd
new file mode 100644
index 00000000000..de078b9e395
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1.dd
@@ -0,0 +1,19 @@
+#...
+[a-f0-9]+ <main>:
+[ ]*[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
+[ ]*[a-f0-9]+: [ a-f0-9]+ addr16 call [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: [ a-f0-9]+ call \*0x[a-f0-9]+
+[ ]*[a-f0-9]+: [ a-f0-9]+ call \*0x[a-f0-9]+
+[ ]*[a-f0-9]+: [ a-f0-9]+ lea *0x[a-f0-9]+,%eax
+[ ]*[a-f0-9]+: ff d0 call \*%eax
+[ ]*[a-f0-9]+: [ a-f0-9]+ mov *0x[a-f0-9]+,%eax
+[ ]*[a-f0-9]+: ff d0 call \*%eax
+[ ]*[a-f0-9]+: [ a-f0-9]+ mov *0x[a-f0-9]+,%eax
+[ ]*[a-f0-9]+: ff d0 call \*%eax
+[ ]*[a-f0-9]+: [ a-f0-9]+ lea *0x[a-f0-9]+,%ecx
+[ ]*[a-f0-9]+: ff d1 call \*%ecx
+[ ]*[a-f0-9]+: 83 ec 0c sub \$0xc,%esp
+[ ]*[a-f0-9]+: 6a 00 push \$0x0
+[ ]*[a-f0-9]+: [ a-f0-9]+ jmp [a-f0-9]+ <myexit>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/got1.out b/ld/testsuite/ld-i386/got1.out
new file mode 100644
index 00000000000..99d4f7fc9f8
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1.out
@@ -0,0 +1,7 @@
+foo
+bar
+plt
+foo
+bar
+plt
+foo
diff --git a/ld/testsuite/ld-i386/got1a.S b/ld/testsuite/ld-i386/got1a.S
new file mode 100644
index 00000000000..453025b70eb
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1a.S
@@ -0,0 +1,20 @@
+ .text
+ .globl main
+ .type main, @function
+main:
+ subl $12, %esp
+ call *foo@GOT
+ call *bar@GOT
+ call *plt@GOT
+ movl foo@GOT, %eax
+ call *%eax
+ movl bar@GOT, %eax
+ call *%eax
+ movl plt@GOT, %eax
+ call *%eax
+ movl foo@GOT(%ebx), %ecx
+ call *%ecx
+ subl $12, %esp
+ pushl $0
+ jmp *myexit@GOT
+ .size main, .-main
diff --git a/ld/testsuite/ld-i386/got1b.c b/ld/testsuite/ld-i386/got1b.c
new file mode 100644
index 00000000000..cf0c78e222a
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1b.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+foo (void)
+{
+ printf ("%s\n", __FUNCTION__);
+}
diff --git a/ld/testsuite/ld-i386/got1c.c b/ld/testsuite/ld-i386/got1c.c
new file mode 100644
index 00000000000..05f5fc2e3a7
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1c.c
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+
+void
+myexit (int status)
+{
+ exit (status);
+}
diff --git a/ld/testsuite/ld-i386/got1d.S b/ld/testsuite/ld-i386/got1d.S
new file mode 100644
index 00000000000..a6d51c66eed
--- /dev/null
+++ b/ld/testsuite/ld-i386/got1d.S
@@ -0,0 +1,54 @@
+ .globl bar
+ .type bar, @function
+bar:
+ pushl %ebx
+ call __x86.get_pc_thunk.cx
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+ subl $24, %esp
+ leal __FUNCTION__.1862@GOTOFF(%ecx), %eax
+ movl %eax, (%esp)
+ call *puts@GOT(%ecx)
+ addl $24, %esp
+ popl %ebx
+ ret
+ .size bar, .-bar
+
+ .globl plt
+ .type plt, @function
+plt:
+ pushl %esi
+ pushl %ebx
+ call __x86.get_pc_thunk.bx
+1:
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $20, %esp
+ leal __FUNCTION__.1866@GOTOFF(%ebx), %esi
+ movl %esi, (%esp)
+ call *puts@GOT(%ebx)
+ addl $20, %esp
+ popl %ebx
+ popl %esi
+ ret
+ .section .rodata
+ .type __FUNCTION__.1866, @object
+ .size __FUNCTION__.1866, 4
+__FUNCTION__.1866:
+ .string "plt"
+ .type __FUNCTION__.1862, @object
+ .size __FUNCTION__.1862, 4
+__FUNCTION__.1862:
+ .string "bar"
+ .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 .text.__x86.get_pc_thunk.cx,"axG",@progbits,__x86.get_pc_thunk.cx,comdat
+ .globl __x86.get_pc_thunk.cx
+ .hidden __x86.get_pc_thunk.cx
+ .type __x86.get_pc_thunk.cx, @function
+__x86.get_pc_thunk.cx:
+ movl (%esp), %ecx
+ ret
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 6213dbebcca..eca48dcc251 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -291,6 +291,12 @@ run_dump_test "lea1c"
run_dump_test "lea1d"
run_dump_test "lea1e"
run_dump_test "lea1f"
+run_dump_test "lea2a"
+run_dump_test "lea2b"
+run_dump_test "lea3a"
+run_dump_test "lea3b"
+run_dump_test "lea4a"
+run_dump_test "lea4b"
run_dump_test "mov1a"
run_dump_test "mov1b"
@@ -490,6 +496,22 @@ if { [isnative]
{{readelf {-Wrd} pr18900b.rd}} \
"pr18900b" \
] \
+ [list \
+ "Build got1d.so" \
+ "-shared" \
+ "" \
+ { got1d.S } \
+ "" \
+ "got1d.so" \
+ ] \
+ [list \
+ "Build gotpc1" \
+ "tmpdir/got1d.so" \
+ "" \
+ { got1a.S got1b.c got1c.c } \
+ {{objdump {-dw} got1.dd}} \
+ "got1" \
+ ] \
]
run_ld_link_exec_tests [] [list \
@@ -552,6 +574,14 @@ if { [isnative]
"pr18900" \
"pr18900.out" \
] \
+ [list \
+ "Run got1" \
+ "tmpdir/got1d.so" \
+ "" \
+ { got1a.S got1b.c got1c.c } \
+ "got1" \
+ "got1.out" \
+ ] \
]
}
diff --git a/ld/testsuite/ld-i386/lea1c.d b/ld/testsuite/ld-i386/lea1c.d
index 5ba82753243..f47dd1a8932 100644
--- a/ld/testsuite/ld-i386/lea1c.d
+++ b/ld/testsuite/ld-i386/lea1c.d
@@ -9,5 +9,5 @@
Disassembly of section .text:
#...
-[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax
+[ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax
#pass
diff --git a/ld/testsuite/ld-i386/lea2.s b/ld/testsuite/ld-i386/lea2.s
new file mode 100644
index 00000000000..fe2c4cd325b
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea2.s
@@ -0,0 +1,9 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .globl _start
+ .type _start, @function
+_start:
+ movl foo@GOT, %eax
diff --git a/ld/testsuite/ld-i386/lea2a.d b/ld/testsuite/ld-i386/lea2a.d
new file mode 100644
index 00000000000..b00853bc792
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea2a.d
@@ -0,0 +1,4 @@
+#source: lea2.s
+#as: --32
+#ld: -Bsymbolic -shared -melf_i386
+#error: direct GOT relocation R_386_LOAD_GOT32 against `foo' without base register can not be used when making a shared object
diff --git a/ld/testsuite/ld-i386/lea2b.d b/ld/testsuite/ld-i386/lea2b.d
new file mode 100644
index 00000000000..b9077a794e8
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea2b.d
@@ -0,0 +1,13 @@
+#source: lea2.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax
+#pass
diff --git a/ld/testsuite/ld-i386/lea3.s b/ld/testsuite/ld-i386/lea3.s
new file mode 100644
index 00000000000..0cd02a1f01c
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea3.s
@@ -0,0 +1,15 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .type bar, @function
+bar:
+ ret
+ .globl _start
+ .type _start, @function
+_start:
+ call *foo@GOT
+ call *bar@GOT
+ jmp *foo@GOT
+ jmp *bar@GOT
diff --git a/ld/testsuite/ld-i386/lea3a.d b/ld/testsuite/ld-i386/lea3a.d
new file mode 100644
index 00000000000..a7e972497e7
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea3a.d
@@ -0,0 +1,18 @@
+#source: lea3.s
+#as: --32
+#ld: -Bsymbolic -shared -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]*addr16 call [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]*addr16 call [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: [ a-f0-9]+ jmp [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 90 nop
+[ ]*[a-f0-9]+: [ a-f0-9]+ jmp [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/lea3b.d b/ld/testsuite/ld-i386/lea3b.d
new file mode 100644
index 00000000000..bb16fc0974b
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea3b.d
@@ -0,0 +1,18 @@
+#source: lea3.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]*addr16 call [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 67 e8 ([0-9a-f]{2} ){4}[ ]*addr16 call [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: [ a-f0-9]+ jmp [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 90 nop
+[ ]*[a-f0-9]+: [ a-f0-9]+ jmp [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 90 nop
+#pass
diff --git a/ld/testsuite/ld-i386/lea4.s b/ld/testsuite/ld-i386/lea4.s
new file mode 100644
index 00000000000..1ecd50c1ebc
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea4.s
@@ -0,0 +1,8 @@
+ .text
+ .type foo, @function
+foo:
+ ret
+ .globl _start
+ .type _start, @function
+_start:
+ movl foo@GOT, %eax
diff --git a/ld/testsuite/ld-i386/lea4a.d b/ld/testsuite/ld-i386/lea4a.d
new file mode 100644
index 00000000000..5e4361513a9
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea4a.d
@@ -0,0 +1,4 @@
+#source: lea4.s
+#as: --32
+#ld: -Bsymbolic -shared -melf_i386
+#error: direct GOT relocation R_386_LOAD_GOT32 against `foo' without base register can not be used when making a shared object
diff --git a/ld/testsuite/ld-i386/lea4b.d b/ld/testsuite/ld-i386/lea4b.d
new file mode 100644
index 00000000000..745ea4f4978
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea4b.d
@@ -0,0 +1,13 @@
+#source: lea4.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax
+#pass
diff --git a/ld/testsuite/ld-i386/plt-main1.rd b/ld/testsuite/ld-i386/plt-main1.rd
index d27589e1632..8eab423a2a3 100644
--- a/ld/testsuite/ld-i386/plt-main1.rd
+++ b/ld/testsuite/ld-i386/plt-main1.rd
@@ -1,3 +1,3 @@
#...
-[0-9a-f ]+R_386_GOT32 +0+ +bar
+[0-9a-f ]+R_386_LOAD_GOT32 +0+ +bar
#pass
diff --git a/ld/testsuite/ld-i386/plt-main3.rd b/ld/testsuite/ld-i386/plt-main3.rd
index 7b78818d0be..0364fb1fe0e 100644
--- a/ld/testsuite/ld-i386/plt-main3.rd
+++ b/ld/testsuite/ld-i386/plt-main3.rd
@@ -1,5 +1,5 @@
#...
-[0-9a-f ]+R_386_GOT32 +0+ +bar
+[0-9a-f ]+R_386_(LOAD_|)GOT32 +0+ +bar
#...
[0-9a-f ]+R_386_PLT32 +0+ +bar
#pass
diff --git a/ld/testsuite/ld-i386/plt-main4.rd b/ld/testsuite/ld-i386/plt-main4.rd
index 882a3ad565c..bde39e93d48 100644
--- a/ld/testsuite/ld-i386/plt-main4.rd
+++ b/ld/testsuite/ld-i386/plt-main4.rd
@@ -1,5 +1,5 @@
#...
-[0-9a-f ]+R_386_GOT32 +0+ +foo
+[0-9a-f ]+R_386_LOAD_GOT32 +0+ +foo
#...
[0-9a-f ]+R_386_PLT32 +0+ +foo
#pass