diff options
author | Alan Modra <amodra@gmail.com> | 2019-10-04 08:48:41 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-10-04 22:53:56 +0930 |
commit | f749f26eea052459c27e21d0d15f5fac060961dc (patch) | |
tree | a3f3e0e4355e7c712c31228440c20948c0e46e1b /ld/testsuite/ld-powerpc | |
parent | 9cb09e33e04feb12df2aaa6e81d61b82ad609ce5 (diff) | |
download | gdb-f749f26eea052459c27e21d0d15f5fac060961dc.zip gdb-f749f26eea052459c27e21d0d15f5fac060961dc.tar.gz gdb-f749f26eea052459c27e21d0d15f5fac060961dc.tar.bz2 |
PowerPC PIC vs. DLL TLS issues
1) GOT entries generated for any of the GOT TLS relocations don't need
dynamic relocations for locally defined symbols in PIEs. In the case
of a tls_index doubleword, the dtpmod entry is known to be 1, and the
dtprel entry is also known at link time and relative. Similarly,
dtprel and tprel words are known at link time and relative. (GOT
entries for other than TLS symbols are not relative and thus need
dynamic relocations in PIEs.)
2) Local dynamic TLS code is really only meant for accesses local to
the current binary. There was a cheapskate test for this before using
the common tlsld_got slot, but the test wasn't exactly correct and
might confuse anyone looking at the code. The proper test,
SYMBOL_REFERENCES_LOCAL isn't so expensive that it should be avoided.
3) The same cheap test for local syms when optimising TLS sequences
should be SYMBOL_REFERENCES_LOCAL too.
bfd/
* elf64-ppc.c (ppc64_elf_check_relocs): Move initialisation of vars.
(ppc64_elf_tls_optimize): Correct is_local condition.
(allocate_got): Don't reserve dynamic relocations for any of the
tls got relocs in PIEs when the symbol is local.
(allocate_dynrelocs): Correct validity test for local sym using
tlsld_got slot.
(ppc64_elf_size_dynamic_sections): Don't reserve dynamic relocations
for any of the tls got relocs in PIEs.
(ppc64_elf_layout_multitoc): Likewise.
(ppc64_elf_relocate_section): Correct validity test for local sym
using tlsld_got slot. Don't emit dynamic relocations for any of
the tls got relocs in PIEs when the symbol is local.
* elf32-ppc.c (ppc_elf_tls_optimize): Correct is_local condition.
(got_relocs_needed): Delete.
(allocate_dynrelocs): Correct validity test for local sym using
tlsld_got slot. Don't reserve dynamic relocations for any of the
tls got relocs in PIEs when the symbol is local.
(ppc_elf_size_dynamic_sections): Don't reserve dynamic relocations
for any of the tls got relocs in PIEs.
(ppc_elf_relocate_section): Correct validity test for local sym
using tlsld_got slot. Don't emit dynamic relocations for any of
the tls got relocs in PIEs when the symbol is local.
ld/
* testsuite/ld-powerpc/tlsso.d: Adjust to suit tlsld_got usage change.
* testsuite/ld-powerpc/tlsso.g: Likewise.
* testsuite/ld-powerpc/tlsso.r: Likewise.
* testsuite/ld-powerpc/tlsso32.d: Likewise.
* testsuite/ld-powerpc/tlsso32.g: Likewise.
* testsuite/ld-powerpc/tlsso32.r: Likewise.
Diffstat (limited to 'ld/testsuite/ld-powerpc')
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso.d | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso.g | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso.r | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso32.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso32.g | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/tlsso32.r | 6 |
6 files changed, 28 insertions, 21 deletions
diff --git a/ld/testsuite/ld-powerpc/tlsso.d b/ld/testsuite/ld-powerpc/tlsso.d index caebc49..4ef1f25 100644 --- a/ld/testsuite/ld-powerpc/tlsso.d +++ b/ld/testsuite/ld-powerpc/tlsso.d @@ -10,9 +10,9 @@ Disassembly of section \.text: .* <.*plt_call\.__tls_get_addr(|_opt)>: .* (f8 41 00 28|28 00 41 f8) std r2,40\(r1\) -.* (e9 82 80 78|78 80 82 e9) ld r12,-32648\(r2\) +.* (e9 82 80 98|98 80 82 e9) ld r12,-32616\(r2\) .* (7d 89 03 a6|a6 03 89 7d) mtctr r12 -.* (e8 42 80 80|80 80 42 e8) ld r2,-32640\(r2\) +.* (e8 42 80 a0|a0 80 42 e8) ld r2,-32608\(r2\) .* (28 22 00 00|00 00 22 28) cmpldi r2,0 .* (4c e2 04 20|20 04 e2 4c) bnectr\+ * .* (48 00 00 ..|.. 00 00 48) b .* <__tls_get_addr@plt> @@ -21,21 +21,21 @@ Disassembly of section \.text: .* (38 62 80 20|20 80 62 38) addi r3,r2,-32736 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) -.* (38 62 80 50|50 80 62 38) addi r3,r2,-32688 +.* (38 62 80 40|40 80 62 38) addi r3,r2,-32704 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) -.* (38 62 80 38|38 80 62 38) addi r3,r2,-32712 +.* (38 62 80 58|58 80 62 38) addi r3,r2,-32680 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) -.* (38 62 80 50|50 80 62 38) addi r3,r2,-32688 +.* (38 62 80 30|30 80 62 38) addi r3,r2,-32720 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) .* (39 23 80 40|40 80 23 39) addi r9,r3,-32704 .* (3d 23 00 00|00 00 23 3d) addis r9,r3,0 .* (81 49 80 48|48 80 49 81) lwz r10,-32696\(r9\) -.* (e9 22 80 30|30 80 22 e9) ld r9,-32720\(r2\) +.* (e9 22 80 50|50 80 22 e9) ld r9,-32688\(r2\) .* (7d 49 18 2a|2a 18 49 7d) ldx r10,r9,r3 -.* (e9 22 80 48|48 80 22 e9) ld r9,-32696\(r2\) +.* (e9 22 80 68|68 80 22 e9) ld r9,-32664\(r2\) .* (7d 49 6a 2e|2e 6a 49 7d) lhzx r10,r9,r13 .* (89 4d 00 00|00 00 4d 89) lbz r10,0\(r13\) .* (3d 2d 00 00|00 00 2d 3d) addis r9,r13,0 @@ -43,7 +43,7 @@ Disassembly of section \.text: .* (38 62 80 08|08 80 62 38) addi r3,r2,-32760 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) -.* (38 62 80 50|50 80 62 38) addi r3,r2,-32688 +.* (38 62 80 70|70 80 62 38) addi r3,r2,-32656 .* (4b ff ff ..|.. ff ff 4b) bl .*plt_call.__tls_get_addr.* .* (e8 41 00 28|28 00 41 e8) ld r2,40\(r1\) .* (f9 43 80 08|08 80 43 f9) std r10,-32760\(r3\) @@ -51,7 +51,7 @@ Disassembly of section \.text: .* (91 49 80 10|10 80 49 91) stw r10,-32752\(r9\) .* (e9 22 80 18|18 80 22 e9) ld r9,-32744\(r2\) .* (7d 49 19 2a|2a 19 49 7d) stdx r10,r9,r3 -.* (e9 22 80 48|48 80 22 e9) ld r9,-32696\(r2\) +.* (e9 22 80 68|68 80 22 e9) ld r9,-32664\(r2\) .* (7d 49 6b 2e|2e 6b 49 7d) sthx r10,r9,r13 .* (e9 4d 00 02|02 00 4d e9) lwa r10,0\(r13\) .* (3d 2d 00 00|00 00 2d 3d) addis r9,r13,0 diff --git a/ld/testsuite/ld-powerpc/tlsso.g b/ld/testsuite/ld-powerpc/tlsso.g index f8ac949..a263957 100644 --- a/ld/testsuite/ld-powerpc/tlsso.g +++ b/ld/testsuite/ld-powerpc/tlsso.g @@ -13,3 +13,5 @@ Contents of section \.got: .* 00000000 00000000 00000000 00000000 .* .* 00000000 00000000 00000000 00000000 .* .* 00000000 00000000 00000000 00000000 .* +.* 00000000 00000000 00000000 00000000 .* +.* 00000000 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-powerpc/tlsso.r b/ld/testsuite/ld-powerpc/tlsso.r index c1d889a..94b8c3c 100644 --- a/ld/testsuite/ld-powerpc/tlsso.r +++ b/ld/testsuite/ld-powerpc/tlsso.r @@ -44,9 +44,9 @@ Program Headers: +02 +\.dynamic * +03 +\.tdata \.tbss * -Relocation section '\.rela\.dyn' at offset .* contains 18 entries: +Relocation section '\.rela\.dyn' at offset .* contains 20 entries: +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend -[0-9a-f ]+R_PPC64_RELATIVE +4fc +[0-9a-f ]+R_PPC64_RELATIVE +51c [0-9a-f ]+R_PPC64_RELATIVE +18800 [0-9a-f ]+R_PPC64_TPREL16 +0+60 le0 \+ 0 [0-9a-f ]+R_PPC64_TPREL16_HA +0+68 le1 \+ 0 @@ -60,6 +60,8 @@ Relocation section '\.rela\.dyn' at offset .* contains 18 entries: [0-9a-f ]+R_PPC64_DTPMOD64 +0 [0-9a-f ]+R_PPC64_DTPMOD64 +0+ gd \+ 0 [0-9a-f ]+R_PPC64_DTPREL64 +0+ gd \+ 0 +[0-9a-f ]+R_PPC64_DTPMOD64 +0+40 ld0 \+ 0 +[0-9a-f ]+R_PPC64_DTPMOD64 +0+ ld \+ 0 [0-9a-f ]+R_PPC64_DTPREL64 +0+50 ld2 \+ 0 [0-9a-f ]+R_PPC64_DTPMOD64 +0+38 gd0 \+ 0 [0-9a-f ]+R_PPC64_DTPREL64 +0+38 gd0 \+ 0 diff --git a/ld/testsuite/ld-powerpc/tlsso32.d b/ld/testsuite/ld-powerpc/tlsso32.d index 3365eb3..c9a25d3 100644 --- a/ld/testsuite/ld-powerpc/tlsso32.d +++ b/ld/testsuite/ld-powerpc/tlsso32.d @@ -13,13 +13,13 @@ Disassembly of section \.text: .*: (7f c8 02 a6|a6 02 c8 7f) mflr r30 .*: (3f de 00 02|02 00 de 3f) addis r30,r30,2 .*: (3b de 80 e8|e8 80 de 3b) addi r30,r30,-32536 -.*: (38 7f ff e4|e4 ff 7f 38) addi r3,r31,-28 +.*: (38 7f ff d4|d4 ff 7f 38) addi r3,r31,-44 .*: (48 00 00 01|01 00 00 48) bl .* -.*: (38 7f ff f8|f8 ff 7f 38) addi r3,r31,-8 +.*: (38 7f ff e4|e4 ff 7f 38) addi r3,r31,-28 .*: (48 00 00 01|01 00 00 48) bl .* .*: (38 7f ff ec|ec ff 7f 38) addi r3,r31,-20 .*: (48 00 00 5d|5d 00 00 48) bl .*<0+8000\.got2\.plt_pic32\.__tls_get_addr> -.*: (38 7f ff f8|f8 ff 7f 38) addi r3,r31,-8 +.*: (38 7f ff dc|dc ff 7f 38) addi r3,r31,-36 .*: (48 00 00 55|55 00 00 48) bl .*<0+8000\.got2\.plt_pic32\.__tls_get_addr> .*: (39 23 80 20|20 80 23 39) addi r9,r3,-32736 .*: (3d 23 00 00|00 00 23 3d) addis r9,r3,0 @@ -29,7 +29,7 @@ Disassembly of section \.text: .*: (89 42 00 00|00 00 42 89) lbz r10,0\(r2\) .*: (3d 22 00 00|00 00 22 3d) addis r9,r2,0 .*: (99 49 00 00|00 00 49 99) stb r10,0\(r9\) -.*: (38 7e ff dc|dc ff 7e 38) addi r3,r30,-36 +.*: (38 7e ff cc|cc ff 7e 38) addi r3,r30,-52 .*: (48 00 00 01|01 00 00 48) bl .* .*: (38 7e ff f8|f8 ff 7e 38) addi r3,r30,-8 .*: (48 00 00 01|01 00 00 48) bl .* @@ -43,7 +43,7 @@ Disassembly of section \.text: .*: (a9 49 00 00|00 00 49 a9) lha r10,0\(r9\) .* <00008000.got2.plt_pic32.__tls_get_addr>: -.*: (81 7e 80 d8|d8 80 7e 81) lwz r11,-32552\(r30\) +.*: (81 7e 80 e8|e8 80 7e 81) lwz r11,-32536\(r30\) .*: (7d 69 03 a6|a6 03 69 7d) mtctr r11 .*: (4e 80 04 20|20 04 80 4e) bctr .*: (60 00 00 00|00 00 00 60) nop @@ -57,8 +57,8 @@ Disassembly of section \.text: .*: (7c 08 03 a6|a6 03 08 7c) mtlr r0 .*: (7d 6c 58 50|50 58 6c 7d) subf r11,r12,r11 .*: (3d 8c 00 01|01 00 8c 3d) addis r12,r12,1 -.*: (80 0c 01 20|20 01 0c 80) lwz r0,288\(r12\) -.*: (81 8c 01 24|24 01 8c 81) lwz r12,292\(r12\) +.*: (80 0c 01 30|30 01 0c 80) lwz r0,304\(r12\) +.*: (81 8c 01 34|34 01 8c 81) lwz r12,308\(r12\) .*: (7c 09 03 a6|a6 03 09 7c) mtctr r0 .*: (7c 0b 5a 14|14 5a 0b 7c) add r0,r11,r11 .*: (7d 60 5a 14|14 5a 60 7d) add r11,r0,r11 diff --git a/ld/testsuite/ld-powerpc/tlsso32.g b/ld/testsuite/ld-powerpc/tlsso32.g index 0e01e5d..bbeff7d 100644 --- a/ld/testsuite/ld-powerpc/tlsso32.g +++ b/ld/testsuite/ld-powerpc/tlsso32.g @@ -9,4 +9,5 @@ Contents of section \.got: .* 00000000 00000000 00000000 00000000 .* .* 00000000 00000000 00000000 00000000 .* -.* 00000000 (000103dc|dc030100) 00000000 00000000 .* +.* 00000000 00000000 00000000 00000000 .* +.* 00000000 (000103fc|fc030100) 00000000 00000000 .* diff --git a/ld/testsuite/ld-powerpc/tlsso32.r b/ld/testsuite/ld-powerpc/tlsso32.r index 56b87f3..08fe466 100644 --- a/ld/testsuite/ld-powerpc/tlsso32.r +++ b/ld/testsuite/ld-powerpc/tlsso32.r @@ -18,7 +18,7 @@ Section Headers: +\[[ 0-9]+\] \.tdata +PROGBITS .* 0+1c 0+ WAT +0 +0 +4 +\[[ 0-9]+\] \.tbss +NOBITS .* 0+1c 0+ WAT +0 +0 +4 +\[[ 0-9]+\] \.dynamic +DYNAMIC .* 08 +WA +3 +0 +4 - +\[[ 0-9]+\] \.got +PROGBITS .* 0+30 04 +WA +0 +0 +4 + +\[[ 0-9]+\] \.got +PROGBITS .* 0+40 04 +WA +0 +0 +4 +\[[ 0-9]+\] \.plt +PROGBITS .* 0+4 00 +WA +0 +0 +4 +\[[ 0-9]+\] \.symtab +.* +\[[ 0-9]+\] \.strtab +.* @@ -43,7 +43,7 @@ Program Headers: +02 +\.dynamic +03 +\.tdata \.tbss -Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 18 entries: +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 20 entries: Offset +Info +Type +Sym\. Value +Symbol's Name \+ Addend [0-9a-f ]+R_PPC_REL24 +0+ +__tls_get_addr \+ 0 [0-9a-f ]+R_PPC_REL24 +0+ +__tls_get_addr \+ 0 @@ -60,6 +60,8 @@ Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 18 entries: [0-9a-f ]+R_PPC_DTPMOD32 +0 [0-9a-f ]+R_PPC_DTPMOD32 +0+ +gd \+ 0 [0-9a-f ]+R_PPC_DTPREL32 +0+ +gd \+ 0 +[0-9a-f ]+R_PPC_DTPMOD32 +0+20 +ld0 \+ 0 +[0-9a-f ]+R_PPC_DTPMOD32 +0+ +ld \+ 0 [0-9a-f ]+R_PPC_DTPMOD32 +0+1c +gd0 \+ 0 [0-9a-f ]+R_PPC_DTPREL32 +0+1c +gd0 \+ 0 [0-9a-f ]+R_PPC_TPREL32 +0+2c +ie0 \+ 0 |