diff options
author | Alan Modra <amodra@gmail.com> | 2019-04-30 16:33:25 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-05-24 10:27:53 +0930 |
commit | 4a421c53cf609d68fe956c2e7270d34c0ab8500f (patch) | |
tree | 8a241a9458a01b131577c6eaf6b5ca98d91d4421 /ld | |
parent | 5663e321848545857a690f30a780187e3366bd2d (diff) | |
download | binutils-4a421c53cf609d68fe956c2e7270d34c0ab8500f.zip binutils-4a421c53cf609d68fe956c2e7270d34c0ab8500f.tar.gz binutils-4a421c53cf609d68fe956c2e7270d34c0ab8500f.tar.bz2 |
PowerPC GOT_PCREL34 optimisation
bfd/
* elf64-ppc.c (ppc64_elf_check_relocs): Set has_gotrel for
R_PPC64_GOT_PCREL34.
(xlate_pcrel_opt): New function.
(ppc64_elf_edit_toc): Handle R_PPC64_GOT_PCREL34.
(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
for R_PPC64_GOT_PCREL34. Implement R_PPC64_PCREL_OPT optimisation.
ld/
* testsuite/ld-powerpc/pcrelopt.s,
* testsuite/ld-powerpc/pcrelopt.d,
* testsuite/ld-powerpc/pcrelopt.sec: New test.
* testsuite/ld-powerpc/powerpc.exp: Run it.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/pcrelopt.d | 89 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/pcrelopt.s | 119 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/pcrelopt.sec | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/powerpc.exp | 4 |
5 files changed, 225 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 0965cd7..be42aba 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2019-05-24 Alan Modra <amodra@gmail.com> + + * testsuite/ld-powerpc/pcrelopt.s, + * testsuite/ld-powerpc/pcrelopt.d, + * testsuite/ld-powerpc/pcrelopt.sec: New test. + * testsuite/ld-powerpc/powerpc.exp: Run it. + 2019-05-23 Jose E. Marchesi <jose.marchesi@oracle.com> * Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64bpf.c. diff --git a/ld/testsuite/ld-powerpc/pcrelopt.d b/ld/testsuite/ld-powerpc/pcrelopt.d new file mode 100644 index 0000000..18fdb95 --- /dev/null +++ b/ld/testsuite/ld-powerpc/pcrelopt.d @@ -0,0 +1,89 @@ + +.*: file format .* + +Disassembly of section \.text: + +0+10000200 <_start>: +.*: (06 10 00 01|01 00 10 06) plbz r3,66320 +.*: (88 60 03 10|10 03 60 88) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) plhz r4,66308 +.*: (a0 80 03 04|04 03 80 a0) +.*: (60 00 00 00|00 00 00 60) nop +.*: (60 00 00 00|00 00 00 60) nop +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) plha r3,66288 +.*: (a8 60 02 f0|f0 02 60 a8) +.*: (40 82 ff f4|f4 ff 82 40) bne .* +.*: (06 10 00 01|01 00 10 06) plwz r3,66276 +.*: (80 60 02 e4|e4 02 60 80) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plwa r3,66264 +.*: (a4 60 02 d8|d8 02 60 a4) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pld r3,66252 +.*: (e4 60 02 cc|cc 02 60 e4) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plq r14,66240 +.*: (e1 c0 02 c0|c0 02 c0 e1) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) plfs f1,66228 +.*: (c0 20 02 b4|b4 02 20 c0) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) plfd f1,66216 +.*: (c8 20 02 a8|a8 02 20 c8) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plxsd v30,66204 +.*: (ab c0 02 9c|9c 02 c0 ab) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plxssp v31,66192 +.*: (af e0 02 90|90 02 e0 af) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plxv vs63,66180 +.*: (cf e0 02 84|84 02 e0 cf) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) plxv vs0,66168 +.*: (c8 00 02 78|78 02 00 c8) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) pstb r3,66156 +.*: (98 60 02 6c|6c 02 60 98) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) psth r3,66144 +.*: (b0 60 02 60|60 02 60 b0) +.*: (60 00 00 00|00 00 00 60) nop +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) pstw r3,66128 +.*: (90 60 02 50|50 02 60 90) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstd r3,66116 +.*: (f4 60 02 44|44 02 60 f4) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstq r14,66104 +.*: (f1 c0 02 38|38 02 c0 f1) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) pstfd f1,66092 +.*: (d8 20 02 2c|2c 02 20 d8) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) pstfs f2,66080 +.*: (d0 40 02 20|20 02 40 d0) +.*: (60 00 00 00|00 00 00 60) nop +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstxsd v30,66064 +.*: (bb c0 02 10|10 02 c0 bb) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstxssp v31,66052 +.*: (bf e0 02 04|04 02 e0 bf) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstxv vs63,66040 +.*: (df e0 01 f8|f8 01 e0 df) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pstxv vs0,66028 +.*: (d8 00 01 ec|ec 01 00 d8) +.*: (60 00 00 00|00 00 00 60) nop +.*: (04 10 00 01|01 00 10 04) pld r9,66008 +.*: (e5 20 01 d8|d8 01 20 e5) +.*: (e8 09 00 00|00 00 09 e8) ld r0,0\(r9\) +.*: (60 00 00 00|00 00 00 60) nop +.*: (06 10 00 01|01 00 10 06) pla r7,66000 +.*: (38 e0 01 d0|d0 01 e0 38) +.*: (88 c7 00 00|00 00 c7 88) lbz r6,0\(r7\) diff --git a/ld/testsuite/ld-powerpc/pcrelopt.s b/ld/testsuite/ld-powerpc/pcrelopt.s new file mode 100644 index 0000000..78b0f51 --- /dev/null +++ b/ld/testsuite/ld-powerpc/pcrelopt.s @@ -0,0 +1,119 @@ + .text + .globl _start +_start: +# original PCREL_OPT definition, with second insn immediately after first + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0 + lbz 3,0(9) + +# but we now allow an offset to the second insn + pld 22,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) + nop +0: lhz 4,0(22) + +# in fact, it can even be before the "first" insn +0: lha 3,0(9) + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0b-(.-8) + bne 0b + +# and of course, other local labels work + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,.L1-(.-8) +.L1: lwz 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lwa 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: ld 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lq 14,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lfs 1,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lfd 1,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lxsd 30,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lxssp 31,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lxv 63,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: lxv 0,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stb 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: sth 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stw 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: std 3,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stq 14,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stfd 1,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stfs 2,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stxsd 30,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stxssp 31,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stxv 63,0(9) + + pld 9,sym@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: stxv 0,0(9) + +# This should not optimize + .extern i + .type i,@object + pld 9,i@got@pcrel + .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8) +0: ld 0,0(9) + +# and this should edit from GOT indirect to GOT relative +# ie. change the pld to paddi, leaving the lbz as is. + pld 7,sym@got@pcrel + lbz 6,0(7) + + .data +sym: .space 32 diff --git a/ld/testsuite/ld-powerpc/pcrelopt.sec b/ld/testsuite/ld-powerpc/pcrelopt.sec new file mode 100644 index 0000000..1dcd3a7 --- /dev/null +++ b/ld/testsuite/ld-powerpc/pcrelopt.sec @@ -0,0 +1,6 @@ +# check for just one GOT entry +#... +.* \.rela\.dyn +RELA +[0-9a-f]+ [0-9a-f]+ 000018 .* +#... +.* \.got +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000010 .* +#pass diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp index a2dcfdc..658f319 100644 --- a/ld/testsuite/ld-powerpc/powerpc.exp +++ b/ld/testsuite/ld-powerpc/powerpc.exp @@ -260,6 +260,10 @@ set ppc64elftests { {"notoc ext" "" "" "-a64" {ext.s} {} ""} {"notoc" "-melf64ppc --no-plt-localentry -T ext.lnk" "" "-a64" {notoc.s} {{objdump -d notoc.d} {readelf {-wf -W} notoc.wf}} "notoc"} + {"pcrelopt" "-melf64ppc --hash-style=gnu" "tmpdir/symtocbase.so" + "-a64 -mfuture" {pcrelopt.s} + {{objdump {-d -Mfuture} pcrelopt.d} + {readelf {-S --wide} pcrelopt.sec}} "pcrelopt" } } set ppceabitests { |