diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-05-30 06:36:56 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-07-23 06:15:53 -0700 |
commit | 510901034039a446ec67cbe968849475c4749da5 (patch) | |
tree | fb04eb7538802e50b86b43291f0914508d35da23 | |
parent | 8b0c9520240f385f6c69d87d0d25c9b610134af2 (diff) | |
download | binutils-gdb-users/hjl/relax.tar.gz |
Add testcases for R_386_RELAX_GOT32users/hjl/relax
-rw-r--r-- | gas/testsuite/gas/i386/got.d | 23 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/got.s | 21 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/i386.exp | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1.dd | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1.out | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1a.S | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1b.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1c.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/got1d.S | 54 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/i386.exp | 24 |
10 files changed, 164 insertions, 0 deletions
diff --git a/gas/testsuite/gas/i386/got.d b/gas/testsuite/gas/i386/got.d new file mode 100644 index 00000000000..2e899957a1d --- /dev/null +++ b/gas/testsuite/gas/i386/got.d @@ -0,0 +1,23 @@ +#objdump: -dwr + +.*: +file format .* + + +Disassembly of section .text: + +0+ <_start>: +[ ]*[a-f0-9]+: b8 00 00 00 00 mov \$0x0,%eax 1: R_386_GOT32 foo +[ ]*[a-f0-9]+: a1 00 00 00 00 mov 0x0,%eax 6: R_386_GOT32 foo +[ ]*[a-f0-9]+: 8b 80 00 00 00 00 mov 0x0\(%eax\),%eax c: R_386_GOT32 foo +[ ]*[a-f0-9]+: ff 15 00 00 00 00 call \*0x0 12: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff 90 00 00 00 00 call \*0x0\(%eax\) 18: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmp \*0x0 1e: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff a0 00 00 00 00 jmp \*0x0\(%eax\) 24: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: b8 00 00 00 00 mov \$0x0,%eax 29: R_386_GOT32 foo +[ ]*[a-f0-9]+: a1 00 00 00 00 mov 0x0,%eax 2e: R_386_GOT32 foo +[ ]*[a-f0-9]+: 8b 80 00 00 00 00 mov 0x0\(%eax\),%eax 34: R_386_GOT32 foo +[ ]*[a-f0-9]+: ff 90 00 00 00 00 call \*0x0\(%eax\) 3a: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff 15 00 00 00 00 call \*0x0 40: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff a0 00 00 00 00 jmp \*0x0\(%eax\) 46: R_386_RELAX_GOT32 foo +[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmp \*0x0 4c: R_386_RELAX_GOT32 foo +#pass diff --git a/gas/testsuite/gas/i386/got.s b/gas/testsuite/gas/i386/got.s new file mode 100644 index 00000000000..4cccac2d006 --- /dev/null +++ b/gas/testsuite/gas/i386/got.s @@ -0,0 +1,21 @@ + .text +_start: + movl $foo@GOT, %eax + movl foo@GOT, %eax + movl foo@GOT(%eax), %eax + + call *foo@GOT + call *foo@GOT(%eax) + jmp *foo@GOT + jmp *foo@GOT(%eax) + + .intel_syntax noprefix + + mov eax, offset foo@got + mov eax, DWORD PTR [foo@GOT] + mov eax, DWORD PTR [eax + foo@GOT] + + call DWORD PTR [eax + foo@GOT] + call DWORD PTR [foo@GOT] + jmp DWORD PTR [eax + foo@GOT] + jmp DWORD PTR [foo@GOT] diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 6d6fc2b25cf..d4fd9fd65bf 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -403,6 +403,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]] run_dump_test "relax-3" run_dump_test "relax-4" + run_dump_test "got" + if {![istarget "*-*-nacl*"]} then { run_dump_test "iamcu-1" run_dump_test "iamcu-2" diff --git a/ld/testsuite/ld-i386/got1.dd b/ld/testsuite/ld-i386/got1.dd new file mode 100644 index 00000000000..7a99e643749 --- /dev/null +++ b/ld/testsuite/ld-i386/got1.dd @@ -0,0 +1,11 @@ +#... +[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]+: 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..8e9e06363b8 --- /dev/null +++ b/ld/testsuite/ld-i386/got1.out @@ -0,0 +1,3 @@ +foo +bar +plt diff --git a/ld/testsuite/ld-i386/got1a.S b/ld/testsuite/ld-i386/got1a.S new file mode 100644 index 00000000000..961bc9e04f4 --- /dev/null +++ b/ld/testsuite/ld-i386/got1a.S @@ -0,0 +1,12 @@ + .text + .globl main + .type main, @function +main: + subl $12, %esp + call *foo@GOT + call *bar@GOT + call *plt@GOT + 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 61f95998461..fb5a5f9b91c 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -461,6 +461,22 @@ if { [isnative] {{readelf {-Wr} pr17827.rd}} \ "pr17827" \ ] \ + [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 \ @@ -515,6 +531,14 @@ if { [isnative] "pr17689ver" \ "pr17689.out" \ ] \ + [list \ + "Run got1" \ + "tmpdir/got1d.so" \ + "" \ + { got1a.S got1b.c got1c.c } \ + "got1" \ + "got1.out" \ + ] \ ] } |