aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-20 12:33:29 +1030
committerAlan Modra <amodra@gmail.com>2020-01-20 18:58:05 +1030
commitb9ca1af69e097b8dc15b23a4e12194f9567c4ad7 (patch)
treefd79a39913d96fc6411b90855e94fb103d1604af /bfd/elf64-ppc.c
parented7007c18a83d0d654c366d507fcf053985c698b (diff)
downloadgdb-b9ca1af69e097b8dc15b23a4e12194f9567c4ad7.zip
gdb-b9ca1af69e097b8dc15b23a4e12194f9567c4ad7.tar.gz
gdb-b9ca1af69e097b8dc15b23a4e12194f9567c4ad7.tar.bz2
Don't touch r11 in __tls_get_addr stub
This modifies the special __tls_get_addr stub that checks for a tlsdesc style __tls_index entry and returns early. Not using r11 isn't much benefit at the moment but a followup patch will preserve regs around the first call to __tls_get_addr when the __tls_index entry isn't yet set up for an early return. bfd/ * elf64-ppc.c (LD_R11_0R3, CMPDI_R11_0, STD_R11_0R1, LD_R11_0R1), (MTLR_R11): Don't define. (LD_R0_0R3, CMPDI_R0_0): Define. (build_tls_get_addr_stub): Don't use r11 in stub. ld/ * testsuite/ld-powerpc/tlsexe.d: Match new __tls_get_addr stub. * testsuite/ld-powerpc/tlsexeno.d: Likewise. * testsuite/ld-powerpc/tlsexetoc.d: Likewise. * testsuite/ld-powerpc/tlsexetocno.d: Likewise. * testsuite/ld-powerpc/tlsopt5.d: Likewise.
Diffstat (limited to 'bfd/elf64-ppc.c')
-rw-r--r--bfd/elf64-ppc.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 0e906cb..3ae294b 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -10885,17 +10885,14 @@ build_plt_stub (struct ppc_link_hash_table *htab,
/* Build a special .plt call stub for __tls_get_addr. */
-#define LD_R11_0R3 0xe9630000
+#define LD_R0_0R3 0xe8030000
#define LD_R12_0R3 0xe9830000
#define MR_R0_R3 0x7c601b78
-#define CMPDI_R11_0 0x2c2b0000
+#define CMPDI_R0_0 0x2c200000
#define ADD_R3_R12_R13 0x7c6c6a14
#define BEQLR 0x4d820020
#define MR_R3_R0 0x7c030378
-#define STD_R11_0R1 0xf9610000
#define BCTRL 0x4e800421
-#define LD_R11_0R1 0xe9610000
-#define MTLR_R11 0x7d6803a6
static inline bfd_byte *
build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
@@ -10905,10 +10902,10 @@ build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
bfd *obfd = htab->params->stub_bfd;
bfd_byte *loc = p;
- bfd_put_32 (obfd, LD_R11_0R3 + 0, p), p += 4;
+ bfd_put_32 (obfd, LD_R0_0R3 + 0, p), p += 4;
bfd_put_32 (obfd, LD_R12_0R3 + 8, p), p += 4;
+ bfd_put_32 (obfd, CMPDI_R0_0, p), p += 4;
bfd_put_32 (obfd, MR_R0_R3, p), p += 4;
- bfd_put_32 (obfd, CMPDI_R11_0, p), p += 4;
bfd_put_32 (obfd, ADD_R3_R12_R13, p), p += 4;
bfd_put_32 (obfd, BEQLR, p), p += 4;
bfd_put_32 (obfd, MR_R3_R0, p), p += 4;
@@ -10917,8 +10914,8 @@ build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
if (stub_entry->stub_type != ppc_stub_plt_call_r2save)
return build_plt_stub (htab, stub_entry, p, offset, r);
- bfd_put_32 (obfd, MFLR_R11, p), p += 4;
- bfd_put_32 (obfd, STD_R11_0R1 + STK_LINKER (htab), p), p += 4;
+ bfd_put_32 (obfd, MFLR_R0, p), p += 4;
+ bfd_put_32 (obfd, STD_R0_0R1 + STK_LINKER (htab), p), p += 4;
if (r != NULL)
r[0].r_offset += 2 * 4;
@@ -10926,8 +10923,8 @@ build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
bfd_put_32 (obfd, BCTRL, p - 4);
bfd_put_32 (obfd, LD_R2_0R1 + STK_TOC (htab), p), p += 4;
- bfd_put_32 (obfd, LD_R11_0R1 + STK_LINKER (htab), p), p += 4;
- bfd_put_32 (obfd, MTLR_R11, p), p += 4;
+ bfd_put_32 (obfd, LD_R0_0R1 + STK_LINKER (htab), p), p += 4;
+ bfd_put_32 (obfd, MTLR_R0, p), p += 4;
bfd_put_32 (obfd, BLR, p), p += 4;
if (htab->glink_eh_frame != NULL