aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-01-29 11:09:55 +1030
committerAlan Modra <amodra@gmail.com>2015-01-29 13:13:02 +1030
commitb86ac8e3a5a3117696b1760003b8e09ed13f1de9 (patch)
tree62ef24abc3d0ef13113729ea6f1ae626e556e4af /ld/testsuite/ld-powerpc/tlsld32.d
parentAutomatic date update in version.in (diff)
downloadbinutils-gdb-b86ac8e3a5a3117696b1760003b8e09ed13f1de9.tar.gz
binutils-gdb-b86ac8e3a5a3117696b1760003b8e09ed13f1de9.tar.bz2
binutils-gdb-b86ac8e3a5a3117696b1760003b8e09ed13f1de9.zip
Correct PowerPC64 local-dynamic TLS linker optimization
The linker hardcoded r3 into a local-dynamic to local-exec TLS optimization sequence. This is normally the case since r3 is required as a parameter to (the optimized out) __tls_get_addr call. However, it is possible for a compiler, LLVM in this case, to set up the parameter value in another register then copy it to r3 before the call. When fixing this problem, I noticed that ppc32 had another bug when optimizing away one of the TLS insns to a nop. The patch also tidies a mask used by global-dynamic to initial-exec TLS optimization, to just select the fields needed. Leaving the offset in the instruction wasn't a bug since it will be overwritten anyway. bfd/ * elf64-ppc.c (ppc64_elf_relocate_section): Correct GOT_TLSLD optimization. Tidy mask for GOT_TLSGD optimization. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. Correct location of nop zapping high insn too. ld/testsuite/ * ld-powerpc/tlsld.d, * ld-powerpc/tlsld.s: New test. * ld-powerpc/tlsld32.d, * ld-powerpc/tlsld32.s: New test. * ld-powerpc/powerpc.exp: Run them. Move tocvar and tocnovar.
Diffstat (limited to 'ld/testsuite/ld-powerpc/tlsld32.d')
-rw-r--r--ld/testsuite/ld-powerpc/tlsld32.d44
1 files changed, 44 insertions, 0 deletions
diff --git a/ld/testsuite/ld-powerpc/tlsld32.d b/ld/testsuite/ld-powerpc/tlsld32.d
new file mode 100644
index 00000000000..b0fd657057c
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsld32.d
@@ -0,0 +1,44 @@
+#source: tlsld32.s
+#as: -a32
+#ld: -melf32ppc
+#objdump: -dr
+#target: powerpc*-*-*
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+.*:
+.* nop
+.* addis r29,r2,0
+.* mr r3,r29
+.* addi r3,r3,4096
+.* addis r3,r3,0
+.* lwz r3,-32768\(r3\)
+.* nop
+.* nop
+.* addis r29,r2,0
+.* mr r3,r29
+.* addi r3,r3,4096
+.* lwz r3,-32768\(r3\)
+.* nop
+.* nop
+.* nop
+.* nop
+.* nop
+.* addis r29,r2,0
+.* mr r3,r29
+.* addi r3,r3,-28672
+.* lwz r3,0\(r3\)
+.* nop
+.* nop
+.* nop
+.* addis r29,r2,0
+.* mr r3,r29
+.* addi r3,r3,-28672
+.* lwz r3,0\(r3\)
+.* nop
+.* nop
+.* nop
+.* nop
+#pass