aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-04-30 16:31:01 +0930
committerAlan Modra <amodra@gmail.com>2019-04-30 22:09:54 +0930
commit066f4018ae7822d81cb6747fd9494e5dd63bfecf (patch)
treed840b2ca4e38182f327d99d34a053d5b73a7b6a4 /ld
parent8107ddcea1da07f1c4e902c17f045684beb78079 (diff)
downloadgdb-066f4018ae7822d81cb6747fd9494e5dd63bfecf.zip
gdb-066f4018ae7822d81cb6747fd9494e5dd63bfecf.tar.gz
gdb-066f4018ae7822d81cb6747fd9494e5dd63bfecf.tar.bz2
PowerPC64 GOT indirect to GOT relative optimisation
This implements an optimisation that converts sequences like addis r9,r2,sym@got@ha ld r3,sym@got@l(r9) to addis r9,r2,sym@toc@ha addi r3,r9,sym@toc@l when "sym" is locally defined and can't be overridden. bfd/ * elf64-ppc.c (struct ppc64_elf_obj_tdata): Add has_gotrel. (struct _ppc64_elf_section_data): Likewise. (ppc64_elf_check_relocs): Set above fields. (ppc64_elf_edit_toc): Add a pass over GOT relocs. (ppc64_elf_relocate_section): Edit GOT indirect to GOT relative when possible. ld/ * testsuite/ld-powerpc/elfv2exe.d: Update. * testsuite/ld-powerpc/elfv2so.d: Update. * testsuite/ld-powerpc/tocopt.d: Update. * testsuite/ld-powerpc/tocopt.s: Update. * testsuite/ld-powerpc/tocopt5.d: Update. * testsuite/ld-powerpc/tocopt5.s: Update. * testsuite/ld-powerpc/tocopt7.d: Update. * testsuite/ld-powerpc/tocopt7.s: Update. * testsuite/ld-powerpc/tocopt8.d: Update. * testsuite/ld-powerpc/tocopt8.s: Update.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/testsuite/ld-powerpc/elfv2exe.d2
-rw-r--r--ld/testsuite/ld-powerpc/elfv2so.d12
-rw-r--r--ld/testsuite/ld-powerpc/tocopt.d14
-rw-r--r--ld/testsuite/ld-powerpc/tocopt.s3
-rw-r--r--ld/testsuite/ld-powerpc/tocopt5.d11
-rw-r--r--ld/testsuite/ld-powerpc/tocopt5.s1
-rw-r--r--ld/testsuite/ld-powerpc/tocopt7.d2
-rw-r--r--ld/testsuite/ld-powerpc/tocopt7.s1
-rw-r--r--ld/testsuite/ld-powerpc/tocopt8.d24
-rw-r--r--ld/testsuite/ld-powerpc/tocopt8.s1
11 files changed, 47 insertions, 37 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 630e637..40b90fb 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,18 @@
2019-04-30 Alan Modra <amodra@gmail.com>
+ * testsuite/ld-powerpc/elfv2exe.d: Update.
+ * testsuite/ld-powerpc/elfv2so.d: Update.
+ * testsuite/ld-powerpc/tocopt.d: Update.
+ * testsuite/ld-powerpc/tocopt.s: Update.
+ * testsuite/ld-powerpc/tocopt5.d: Update.
+ * testsuite/ld-powerpc/tocopt5.s: Update.
+ * testsuite/ld-powerpc/tocopt7.d: Update.
+ * testsuite/ld-powerpc/tocopt7.s: Update.
+ * testsuite/ld-powerpc/tocopt8.d: Update.
+ * testsuite/ld-powerpc/tocopt8.s: Update.
+
+2019-04-30 Alan Modra <amodra@gmail.com>
+
* ld.texi (How GNU properties are merged): Avoid pod2man error.
Correct example.
diff --git a/ld/testsuite/ld-powerpc/elfv2exe.d b/ld/testsuite/ld-powerpc/elfv2exe.d
index a02a3ff..769f846 100644
--- a/ld/testsuite/ld-powerpc/elfv2exe.d
+++ b/ld/testsuite/ld-powerpc/elfv2exe.d
@@ -34,7 +34,7 @@ Disassembly of section \.text:
.*: (e8 62 80 08|08 80 62 e8) ld r3,-32760\(r2\)
.*: (4b .. .. ..|.. .. .. 4b) bl .*\.plt_branch\.f2>
.*: (60 00 00 00|00 00 00 60) nop
-.*: (e8 62 80 10|10 80 62 e8) ld r3,-32752\(r2\)
+.*: (38 62 80 10|10 80 62 38) addi r3,r2,-32752
.*: (48 .. .. ..|.. .. .. 48) bl 10008888 <f3>
.*: (60 00 00 00|00 00 00 60) nop
.*: (4b .. .. ..|.. .. .. 4b) bl .*\.plt_branch\.f4>
diff --git a/ld/testsuite/ld-powerpc/elfv2so.d b/ld/testsuite/ld-powerpc/elfv2so.d
index 0853f8a..081eb49 100644
--- a/ld/testsuite/ld-powerpc/elfv2so.d
+++ b/ld/testsuite/ld-powerpc/elfv2so.d
@@ -9,35 +9,35 @@ Disassembly of section \.text:
.* <.*\.plt_call\.f4>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
-.*: (e9 82 80 40|40 80 82 e9) ld r12,-32704\(r2\)
+.*: (e9 82 80 38|38 80 82 e9) ld r12,-32712\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f3>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
-.*: (e9 82 80 30|30 80 82 e9) ld r12,-32720\(r2\)
+.*: (e9 82 80 28|28 80 82 e9) ld r12,-32728\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f5>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
-.*: (e9 82 80 28|28 80 82 e9) ld r12,-32728\(r2\)
+.*: (e9 82 80 20|20 80 82 e9) ld r12,-32736\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f1>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
-.*: (e9 82 80 48|48 80 82 e9) ld r12,-32696\(r2\)
+.*: (e9 82 80 40|40 80 82 e9) ld r12,-32704\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f2>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
-.*: (e9 82 80 38|38 80 82 e9) ld r12,-32712\(r2\)
+.*: (e9 82 80 30|30 80 82 e9) ld r12,-32720\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
@@ -52,7 +52,7 @@ Disassembly of section \.text:
.*: (e8 62 80 08|08 80 62 e8) ld r3,-32760\(r2\)
.*: (4b .. .. ..|.. .. .. 4b) bl .*\.plt_call\.f2>
.*: (e8 41 00 18|18 00 41 e8) ld r2,24\(r1\)
-.*: (e8 62 80 10|10 80 62 e8) ld r3,-32752\(r2\)
+.*: (38 62 80 48|48 80 62 38) addi r3,r2,-32696
.*: (4b .. .. ..|.. .. .. 4b) bl .*\.plt_call\.f3>
.*: (e8 41 00 18|18 00 41 e8) ld r2,24\(r1\)
.*: (4b .. .. ..|.. .. .. 4b) bl .*\.plt_call\.f4>
diff --git a/ld/testsuite/ld-powerpc/tocopt.d b/ld/testsuite/ld-powerpc/tocopt.d
index 272f470..5980589 100644
--- a/ld/testsuite/ld-powerpc/tocopt.d
+++ b/ld/testsuite/ld-powerpc/tocopt.d
@@ -2,13 +2,13 @@
.*: file format .*
Contents of section \.text:
- 100000b0 (3d220000|0000223d) (e9298018|188029e9) (3c820000|0000823c) (38a48020|2080a438) .*
- 100000c0 (e8c50000|0000c5e8) (3fa00000|0000a03f) (3bbd8028|2880bd3b) (7c62e82a|2ae8627c) .*
- 100000d0 (3d220000|0000223d) (39298033|33802939) (3c820000|0000823c) (38a48008|0880a438) .*
+ 100000b0 (3d220000|0000223d) (39298028|28802939) (3c820000|0000823c) (38a48018|1880a438) .*
+ 100000c0 (e8c50000|0000c5e8) (3fa00000|0000a03f) (3bbd8020|2080bd3b) (7c62e82a|2ae8627c) .*
+ 100000d0 (3d220000|0000223d) (3929802b|2b802939) (3c820000|0000823c) (38a48008|0880a438) .*
100000e0 (e8c50000|0000c5e8) (3fa00000|0000a03f) (3bbd8010|1080bd3b) (7c62e82a|2ae8627c) .*
Contents of section \.got:
- 10010100 (00000000|00810110) (10018100|00000000) (00000000|34010110) (10010134|00000000) .*
- 10010110 (00000000|35010110) (10010135|00000000) (00000000|30010110) (10010130|00000000) .*
- 10010120 (00000000|31010110) (10010131|00000000) (00000000|32010110) (10010132|00000000) .*
+ 10010100 (00000000|00810110) (10018100|00000000) (00000000|2c010110) (1001012c|00000000) .*
+ 10010110 (00000000|2d010110) (1001012d|00000000) (00000000|29010110) (10010129|00000000) .*
+ 10010120 (00000000|2a010110) (1001012a|00000000) .*
Contents of section \.sdata:
- 10010130 01020304 0506 .*
+ 10010128 01020304 0506 .*
diff --git a/ld/testsuite/ld-powerpc/tocopt.s b/ld/testsuite/ld-powerpc/tocopt.s
index a2447ca..cb5cc3e 100644
--- a/ld/testsuite/ld-powerpc/tocopt.s
+++ b/ld/testsuite/ld-powerpc/tocopt.s
@@ -24,7 +24,8 @@ x6:
.text
_start:
# no need for got entry, optimise to nop,addi
-# note: ld doesn't yet do got optimisation, so we get nop,ld
+# note that due to unexpected toc/got insns the full optimisation is
+# not done. see tocopt5 for test without unexpected insns.
addis 9,2,x1@got@ha
ld 9,x1@got@l(9)
# must keep got entry, optimise to nop,addi,ld
diff --git a/ld/testsuite/ld-powerpc/tocopt5.d b/ld/testsuite/ld-powerpc/tocopt5.d
index 1c93674..39291d5 100644
--- a/ld/testsuite/ld-powerpc/tocopt5.d
+++ b/ld/testsuite/ld-powerpc/tocopt5.d
@@ -2,12 +2,11 @@
.*: file format .*
Contents of section \.text:
- 100000b0 (60000000|00000060) (e9228018|188022e9) (60000000|00000060) (38a28020|2080a238) .*
- 100000c0 (e8c50000|0000c5e8) (60000000|00000060) (3922802b|2b802239) (60000000|00000060) .*
+ 100000b0 (60000000|00000060) (39228020|20802239) (60000000|00000060) (38a28018|1880a238) .*
+ 100000c0 (e8c50000|0000c5e8) (60000000|00000060) (39228023|23802239) (60000000|00000060) .*
100000d0 (38a28008|0880a238) (e8c50000|0000c5e8) .*
Contents of section \.got:
- 10010100 (00000000|00810110) (10018100|00000000) (00000000|2c010110) (1001012c|00000000) .*
- 10010110 (00000000|2d010110) (1001012d|00000000) (00000000|28010110) (10010128|00000000) .*
- 10010120 (00000000|29010110) (10010129|00000000) .*
+ 10010100 (00000000|00810110) (10018100|00000000) (00000000|24010110) (10010124|00000000) .*
+ 10010110 (00000000|25010110) (10010125|00000000) (00000000|21010110) (10010121|00000000) .*
Contents of section \.sdata:
- 10010128 01020304 0506 .*
+ 10010120 01020304 0506 .*
diff --git a/ld/testsuite/ld-powerpc/tocopt5.s b/ld/testsuite/ld-powerpc/tocopt5.s
index 67da1a9..8eb0b9f 100644
--- a/ld/testsuite/ld-powerpc/tocopt5.s
+++ b/ld/testsuite/ld-powerpc/tocopt5.s
@@ -24,7 +24,6 @@ x6:
.text
_start:
# no need for got entry, optimise to nop,addi
-# note: ld doesn't yet do got optimisation, so we get nop,ld
addis 9,2,x1@got@ha
ld 9,x1@got@l(9)
# must keep got entry, optimise to nop,addi,ld
diff --git a/ld/testsuite/ld-powerpc/tocopt7.d b/ld/testsuite/ld-powerpc/tocopt7.d
index 7d4638f..baaf200 100644
--- a/ld/testsuite/ld-powerpc/tocopt7.d
+++ b/ld/testsuite/ld-powerpc/tocopt7.d
@@ -2,7 +2,7 @@
.*: file format .*
Contents of section \.text:
- 100000b0 (0000223d|3d220000) (288029e9|e9298028) (0000823c|3c820000) (3080a438|38a48030) .*
+ 100000b0 (0000223d|3d220000) (40802939|39298040) (0000823c|3c820000) (3080a438|38a48030) .*
100000c0 (0000c5e8|e8c50000) (0000823f|3f820000) (29803ce9|e93c8029) (0000223d|3d220000) .*
100000d0 (108029e9|e9298010) (0000823c|3c820000) (1880a438|38a48018) (0000c5e8|e8c50000) .*
100000e0 (0000823f|3f820000) (11803ce9|e93c8011) (0000823c|3c820000) (3080a438|38a48030) .*
diff --git a/ld/testsuite/ld-powerpc/tocopt7.s b/ld/testsuite/ld-powerpc/tocopt7.s
index dbd8eb1..e402ee7 100644
--- a/ld/testsuite/ld-powerpc/tocopt7.s
+++ b/ld/testsuite/ld-powerpc/tocopt7.s
@@ -26,7 +26,6 @@ x6:
.text
_start:
# no need for got entry, optimise to nop,addi
-# note: ld doesn't yet do got optimisation, so we get nop,ld
addis 9,2,x1@got@ha
ld 9,x1@got@l(9)
# must keep got entry, optimise to nop,addi,ld
diff --git a/ld/testsuite/ld-powerpc/tocopt8.d b/ld/testsuite/ld-powerpc/tocopt8.d
index c9eff5a..fe5923c 100644
--- a/ld/testsuite/ld-powerpc/tocopt8.d
+++ b/ld/testsuite/ld-powerpc/tocopt8.d
@@ -2,28 +2,28 @@
.*: file format .*
Contents of section \.text:
- 100000b0 (00000060|60000000) (108022e9|e9228010) (00000060|60000000) (1880a238|38a28018) .*
+ 100000b0 (00000060|60000000) (20802239|39228020) (00000060|60000000) (1080a238|38a28010) .*
100000c0 (0000c5e8|e8c50000) (00000060|60000000) (38802239|39228038) (00000060|60000000) .*
100000d0 (0880a238|38a28008) (0000c5e8|e8c50000) (00000060|60000000) (088022e9|e9228008) .*
- 100000e0 (00000060|60000000) (1880a238|38a28018) (0000c580|80c50000) (00000060|60000000) .*
+ 100000e0 (00000060|60000000) (1080a238|38a28010) (0000c580|80c50000) (00000060|60000000) .*
100000f0 (20802281|81228020) (00000060|60000000) (0880a238|38a28008) (0000c580|80c50000) .*
- 10000100 (00000060|60000000) (1880a238|38a28018) (0200c5e8|e8c50002) (00000060|60000000) .*
+ 10000100 (00000060|60000000) (1080a238|38a28010) (0200c5e8|e8c50002) (00000060|60000000) .*
10000110 (228022e9|e9228022) (00000060|60000000) (0880a238|38a28008) (0200c5e8|e8c50002) .*
- 10000120 (00000060|60000000) (1880a238|38a28018) (0000c5a0|a0c50000) (00000060|60000000) .*
+ 10000120 (00000060|60000000) (1080a238|38a28010) (0000c5a0|a0c50000) (00000060|60000000) .*
10000130 (208022a1|a1228020) (00000060|60000000) (0880a238|38a28008) (0000c5a0|a0c50000) .*
- 10000140 (00000060|60000000) (1880a238|38a28018) (0000c5a8|a8c50000) (00000060|60000000) .*
+ 10000140 (00000060|60000000) (1080a238|38a28010) (0000c5a8|a8c50000) (00000060|60000000) .*
10000150 (208022a9|a9228020) (00000060|60000000) (0880a238|38a28008) (0000c5a8|a8c50000) .*
- 10000160 (00000060|60000000) (1880a238|38a28018) (0000c588|88c50000) (00000060|60000000) .*
+ 10000160 (00000060|60000000) (1080a238|38a28010) (0000c588|88c50000) (00000060|60000000) .*
10000170 (20802289|89228020) (00000060|60000000) (0880a238|38a28008) (0000c588|88c50000) .*
- 10000180 (00000060|60000000) (1880a238|38a28018) (0000c5c0|c0c50000) (00000060|60000000) .*
+ 10000180 (00000060|60000000) (1080a238|38a28010) (0000c5c0|c0c50000) (00000060|60000000) .*
10000190 (208022c1|c1228020) (00000060|60000000) (0880a238|38a28008) (0000c5c0|c0c50000) .*
- 100001a0 (00000060|60000000) (1880a238|38a28018) (0000c5c8|c8c50000) (00000060|60000000) .*
+ 100001a0 (00000060|60000000) (1080a238|38a28010) (0000c5c8|c8c50000) (00000060|60000000) .*
100001b0 (208022c9|c9228020) (00000060|60000000) (0880a238|38a28008) (0000c5c8|c8c50000) .*
- 100001c0 (00000060|60000000) (1880a238|38a28018) (0100c5f4|f4c50001) (00000060|60000000) .*
+ 100001c0 (00000060|60000000) (1080a238|38a28010) (0100c5f4|f4c50001) (00000060|60000000) .*
100001d0 (218022f5|f5228021) (00000060|60000000) (2080a238|38a28020) (0100c5f4|f4c50001) .*
- 100001e0 (00000060|60000000) (1880a238|38a28018) (0200c5e4|e4c50002) (00000060|60000000) .*
+ 100001e0 (00000060|60000000) (1080a238|38a28010) (0200c5e4|e4c50002) (00000060|60000000) .*
100001f0 (228022e5|e5228022) (00000060|60000000) (0880a238|38a28008) (0200c5e4|e4c50002) .*
- 10000200 (00000060|60000000) (1880a238|38a28018) (0300c5e4|e4c50003) (00000060|60000000) .*
+ 10000200 (00000060|60000000) (1080a238|38a28010) (0300c5e4|e4c50003) (00000060|60000000) .*
10000210 (238022e5|e5228023) (00000060|60000000) (0880a238|38a28008) (0300c5e4|e4c50003) .*
10000220 (00000060|60000000) (208022f9|f9228020) (00000060|60000000) (0880a238|38a28008) .*
10000230 (0000c5f8|f8c50000) (00000060|60000000) (20802291|91228020) (00000060|60000000) .*
@@ -39,7 +39,7 @@ Contents of section \.text:
100002d0 (0300c5f4|f4c50003) .*
Contents of section \.got:
10010300 (00830110|00000000) (00000000|10018300) (40030110|00000000) (00000000|10010340) .*
- 10010310 (20030110|00000000) (00000000|10010320) (28030110|00000000) (00000000|10010328) .*
+ 10010310 (28030110|00000000) (00000000|10010328) .*
Contents of section \.sdata:
10010320 (01000000|00000000) (00000000|00000001) (02000000|00000000) (00000000|00000002) .*
10010330 (03000000|00000000) (00000000|00000003) (04000000|00000000) (00000000|00000004) .*
diff --git a/ld/testsuite/ld-powerpc/tocopt8.s b/ld/testsuite/ld-powerpc/tocopt8.s
index 219de5e..1d71b28 100644
--- a/ld/testsuite/ld-powerpc/tocopt8.s
+++ b/ld/testsuite/ld-powerpc/tocopt8.s
@@ -23,7 +23,6 @@ x6:
.text
_start:
# no need for got entry, optimise to nop,addi
-# note: ld doesn't yet do got optimisation, so we get nop,ld
addis 9,2,x1@got@ha
ld 9,x1@got@l(9)
# must keep got entry, optimise to nop,addi,ld