From 81209eff905bf76a01bbc3dc07b8973d1d0cdaad Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 20 Jun 2017 09:30:23 +0930 Subject: [PATCH] PowerPC64 tocsave testcases * testsuite/ld-powerpc/powerpc.exp: Run TOCSAVE tests. * testsuite/ld-powerpc/tocsave1.s, * testsuite/ld-powerpc/tocsave1a.d, * testsuite/ld-powerpc/tocsave1s.d, * testsuite/ld-powerpc/tocsave2.s, * testsuite/ld-powerpc/tocsave2a.d, * testsuite/ld-powerpc/tocsave2s.d, * testsuite/ld-powerpc/tocsavelib.s: New files. --- ld/ChangeLog | 11 +++++++++++ ld/testsuite/ld-powerpc/powerpc.exp | 10 ++++++++++ ld/testsuite/ld-powerpc/tocsave1.s | 24 ++++++++++++++++++++++++ ld/testsuite/ld-powerpc/tocsave1a.d | 15 +++++++++++++++ ld/testsuite/ld-powerpc/tocsave1s.d | 9 +++++++++ ld/testsuite/ld-powerpc/tocsave2.s | 24 ++++++++++++++++++++++++ ld/testsuite/ld-powerpc/tocsave2a.d | 18 ++++++++++++++++++ ld/testsuite/ld-powerpc/tocsave2s.d | 13 +++++++++++++ ld/testsuite/ld-powerpc/tocsavelib.s | 5 +++++ 9 files changed, 129 insertions(+) create mode 100644 ld/testsuite/ld-powerpc/tocsave1.s create mode 100644 ld/testsuite/ld-powerpc/tocsave1a.d create mode 100644 ld/testsuite/ld-powerpc/tocsave1s.d create mode 100644 ld/testsuite/ld-powerpc/tocsave2.s create mode 100644 ld/testsuite/ld-powerpc/tocsave2a.d create mode 100644 ld/testsuite/ld-powerpc/tocsave2s.d create mode 100644 ld/testsuite/ld-powerpc/tocsavelib.s diff --git a/ld/ChangeLog b/ld/ChangeLog index 417c464b4ef..f146c3a69f2 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2017-06-21 Alan Modra + + * testsuite/ld-powerpc/powerpc.exp: Run TOCSAVE tests. + * testsuite/ld-powerpc/tocsave1.s, + * testsuite/ld-powerpc/tocsave1a.d, + * testsuite/ld-powerpc/tocsave1s.d, + * testsuite/ld-powerpc/tocsave2.s, + * testsuite/ld-powerpc/tocsave2a.d, + * testsuite/ld-powerpc/tocsave2s.d, + * testsuite/ld-powerpc/tocsavelib.s: New files. + 2017-06-19 H.J. Lu PR ld/21626 diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp index f12e413cd86..f709b1ed69c 100644 --- a/ld/testsuite/ld-powerpc/powerpc.exp +++ b/ld/testsuite/ld-powerpc/powerpc.exp @@ -231,6 +231,16 @@ set ppc64elftests { {{ld tocopt7.out} {objdump -s tocopt7.d}} "tocopt7"} {"TOC opt8" "-melf64ppc" "" "-a64 -mpower9" {tocopt8.s} {{objdump -s tocopt8.d}} "tocopt8"} + {"tocsave lib" "-shared -melf64ppc" "" "-a64" {tocsavelib.s} + {} "tocsavelib.so"} + {"tocsave1 shared" "-melf64ppc" "tmpdir/tocsavelib.so" "-a64" {tocsave1.s} + {{objdump -dr tocsave1s.d}} "tocsave1s"} + {"tocsave1 static" "-melf64ppc" "tmpdir/tocsavelib.o" "-a64" {tocsave1.s} + {{objdump -dr tocsave1a.d}} "tocsave1a"} + {"tocsave2 shared" "-melf64ppc" "tmpdir/tocsavelib.so" "-a64" {tocsave2.s} + {{objdump -dr tocsave2s.d}} "tocsave2s"} + {"tocsave2 static" "-melf64ppc" "tmpdir/tocsavelib.o" "-a64" {tocsave2.s} + {{objdump -dr tocsave2a.d}} "tocsave2a"} {"ambig shared v1" "-shared -melf64ppc" "" "-a64" {funv1.s} {} "funv1.so"} {"ambig shared v2" "-shared -melf64ppc" "" "-a64" {funv2.s} {} "funv2.so"} } diff --git a/ld/testsuite/ld-powerpc/tocsave1.s b/ld/testsuite/ld-powerpc/tocsave1.s new file mode 100644 index 00000000000..75de27ac0bb --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave1.s @@ -0,0 +1,24 @@ + .abiversion 1 + .global _start + .type _start,@function + .section ".opd","aw",@progbits + .p2align 3 +_start: + .quad .L_start, .TOC.@tocbase, 0 + + .text +.L_start: + nop +.L1: +# tocsave in a function prologue + .reloc .,R_PPC64_TOCSAVE,.L1 + nop + + nop +# tocsave on a call + bl foo + .reloc .,R_PPC64_TOCSAVE,.L1 + nop + + blr + .size _start, .-.L_start diff --git a/ld/testsuite/ld-powerpc/tocsave1a.d b/ld/testsuite/ld-powerpc/tocsave1a.d new file mode 100644 index 00000000000..9ae5ed53504 --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave1a.d @@ -0,0 +1,15 @@ + +.*: file format .* + +Disassembly of section \.text: + +.* <\._start>: +.*: (00 00 00 60|60 00 00 00) nop +.*: (00 00 00 60|60 00 00 00) nop +.*: (00 00 00 60|60 00 00 00) nop +.*: (0d 00 00 48|48 00 00 0d) bl .* +.*: (00 00 00 60|60 00 00 00) nop +.*: (20 00 80 4e|4e 80 00 20) blr + +.* : +.*: (20 00 80 4e|4e 80 00 20) blr diff --git a/ld/testsuite/ld-powerpc/tocsave1s.d b/ld/testsuite/ld-powerpc/tocsave1s.d new file mode 100644 index 00000000000..1e6eb9bfff5 --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave1s.d @@ -0,0 +1,9 @@ +#... +.* <\._start>: +.*: (00 00 00 60|60 00 00 00) nop +.*: (28 00 41 f8|f8 41 00 28) std r2,40\(r1\) +.*: (00 00 00 60|60 00 00 00) nop +.*: (.. .. .. 4b|4b .. .. ..) bl .* <.*\.plt_call\.foo> +.*: (28 00 41 e8|e8 41 00 28) ld r2,40\(r1\) +.*: (20 00 80 4e|4e 80 00 20) blr +#pass diff --git a/ld/testsuite/ld-powerpc/tocsave2.s b/ld/testsuite/ld-powerpc/tocsave2.s new file mode 100644 index 00000000000..94683c60430 --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave2.s @@ -0,0 +1,24 @@ + .abiversion 2 + .global _start + .type _start,@function +_start: + nop +.L1: +# Function prologue tocsave. + .reloc .,R_PPC64_TOCSAVE,.L1 + nop + + nop +# Call with tocsave on nop + bl foo + .reloc .,R_PPC64_TOCSAVE,.L1 + nop + + nop +# A call without tocsave (maybe in a different function, or after alloca +# dynamic stack allocation loses r2 save in same function). + bl foo + nop + + blr + .size _start, .-_start diff --git a/ld/testsuite/ld-powerpc/tocsave2a.d b/ld/testsuite/ld-powerpc/tocsave2a.d new file mode 100644 index 00000000000..fbae8c009dd --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave2a.d @@ -0,0 +1,18 @@ + +.*: file format .* + +Disassembly of section \.text: + +.* <_start>: +.*: (00 00 00 60|60 00 00 00) nop +.*: (00 00 00 60|60 00 00 00) nop +.*: (00 00 00 60|60 00 00 00) nop +.*: (19 00 00 48|48 00 00 19) bl .* +.*: (00 00 00 60|60 00 00 00) nop +.*: (00 00 00 60|60 00 00 00) nop +.*: (0d 00 00 48|48 00 00 0d) bl .* +.*: (00 00 00 60|60 00 00 00) nop +.*: (20 00 80 4e|4e 80 00 20) blr + +.* : +.*: (20 00 80 4e|4e 80 00 20) blr diff --git a/ld/testsuite/ld-powerpc/tocsave2s.d b/ld/testsuite/ld-powerpc/tocsave2s.d new file mode 100644 index 00000000000..b44eae164b3 --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsave2s.d @@ -0,0 +1,13 @@ +#... +.* <_start>: +.*: (00 00 00 60|60 00 00 00) nop +.*: (18 00 41 f8|f8 41 00 18) std r2,24\(r1\) +.*: (00 00 00 60|60 00 00 00) nop +.*: (.. .. .. 4b|4b .. .. ..) bl .* <.*\.plt_call\.foo\+0x4> +.*: (18 00 41 e8|e8 41 00 18) ld r2,24\(r1\) +.*: (00 00 00 60|60 00 00 00) nop +.*: (.. .. .. 4b|4b .. .. ..) bl .* <.*\.plt_call\.foo> +.*: (18 00 41 e8|e8 41 00 18) ld r2,24\(r1\) +.*: (20 00 80 4e|4e 80 00 20) blr +.*: (00 00 00 60|60 00 00 00) nop +#pass diff --git a/ld/testsuite/ld-powerpc/tocsavelib.s b/ld/testsuite/ld-powerpc/tocsavelib.s new file mode 100644 index 00000000000..7375af2e7fb --- /dev/null +++ b/ld/testsuite/ld-powerpc/tocsavelib.s @@ -0,0 +1,5 @@ + .global foo + .type foo,@function +foo: + blr + .size foo, .-foo -- 2.30.2