aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-10-04 08:48:41 +0930
committerAlan Modra <amodra@gmail.com>2019-10-04 22:53:56 +0930
commitf749f26eea052459c27e21d0d15f5fac060961dc (patch)
treea3f3e0e4355e7c712c31228440c20948c0e46e1b
parent9cb09e33e04feb12df2aaa6e81d61b82ad609ce5 (diff)
downloadgdb-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.
-rw-r--r--bfd/ChangeLog25
-rw-r--r--bfd/elf32-ppc.c63
-rw-r--r--bfd/elf64-ppc.c33
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.d18
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.g2
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.r6
-rw-r--r--ld/testsuite/ld-powerpc/tlsso32.d14
-rw-r--r--ld/testsuite/ld-powerpc/tlsso32.g3
-rw-r--r--ld/testsuite/ld-powerpc/tlsso32.r6
10 files changed, 94 insertions, 85 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a2e3bb0..09f34ed 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,28 @@
+2019-10-04 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2019-10-04 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/22263
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 9765a33..89d1e94 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -4455,11 +4455,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
h = (struct elf_link_hash_entry *) h->root.u.i.link;
}
- is_local = FALSE;
- if (h == NULL
- || !h->def_dynamic)
- is_local = TRUE;
-
+ is_local = SYMBOL_REFERENCES_LOCAL (info, h);
r_type = ELF32_R_TYPE (rel->r_info);
/* If this section has old-style __tls_get_addr calls
without marker relocs, then check that each
@@ -5049,24 +5045,6 @@ got_entries_needed (int tls_mask)
return need;
}
-/* Calculate size of relocs needed for symbol given its TLS_MASK and
- NEEDed GOT entries. KNOWN says a TPREL offset can be calculated at
- link time. */
-
-static inline unsigned int
-got_relocs_needed (int tls_mask, unsigned int need, bfd_boolean known)
-{
- /* All the entries we allocated need relocs.
- Except IE in executable with a local symbol. We could also omit
- the DTPREL reloc on the second word of a GD entry under the same
- condition as that for IE, but ld.so needs to differentiate
- LD and GD entries. */
- if (known && (tls_mask & TLS_TLS) != 0
- && (tls_mask & (TLS_TPREL | TLS_GDIE)) != 0)
- need -= 4;
- return need * sizeof (Elf32_External_Rela) / 4;
-}
-
/* If H is undefined, make it dynamic if that makes sense. */
static bfd_boolean
@@ -5119,7 +5097,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
need = 0;
if ((eh->tls_mask & (TLS_TLS | TLS_LD)) == (TLS_TLS | TLS_LD))
{
- if (!eh->elf.def_dynamic)
+ if (SYMBOL_REFERENCES_LOCAL (info, &eh->elf))
/* We'll just use htab->tlsld_got.offset. This should
always be the case. It's a little odd if we have
a local dynamic reloc against a non-local symbol. */
@@ -5133,20 +5111,19 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
else
{
eh->elf.got.offset = allocate_got (htab, need);
- if ((bfd_link_pic (info)
+ if (((bfd_link_pic (info)
+ && !((eh->tls_mask & TLS_TLS) != 0
+ && bfd_link_executable (info)
+ && SYMBOL_REFERENCES_LOCAL (info, &eh->elf)))
|| (htab->elf.dynamic_sections_created
&& eh->elf.dynindx != -1
&& !SYMBOL_REFERENCES_LOCAL (info, &eh->elf)))
&& !UNDEFWEAK_NO_DYNAMIC_RELOC (info, &eh->elf))
{
asection *rsec;
- bfd_boolean tprel_known = (bfd_link_executable (info)
- && SYMBOL_REFERENCES_LOCAL (info,
- &eh->elf));
- need = got_relocs_needed (eh->tls_mask, need, tprel_known);
- if ((eh->tls_mask & (TLS_TLS | TLS_LD)) == (TLS_TLS | TLS_LD)
- && eh->elf.def_dynamic)
+ need *= sizeof (Elf32_External_Rela) / 4;
+ if ((eh->tls_mask & (TLS_TLS | TLS_LD)) == (TLS_TLS | TLS_LD))
need -= sizeof (Elf32_External_Rela);
rsec = htab->elf.srelgot;
if (eh->elf.type == STT_GNU_IFUNC)
@@ -5594,12 +5571,13 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
else
{
*local_got = allocate_got (htab, need);
- if (bfd_link_pic (info))
+ if (bfd_link_pic (info)
+ && !((*lgot_masks & TLS_TLS) != 0
+ && bfd_link_executable (info)))
{
asection *srel;
- bfd_boolean tprel_known = bfd_link_executable (info);
- need = got_relocs_needed (*lgot_masks, need, tprel_known);
+ need *= sizeof (Elf32_External_Rela) / 4;
srel = htab->elf.srelgot;
if ((*lgot_masks & (TLS_TLS | PLT_IFUNC)) == PLT_IFUNC)
srel = htab->elf.irelplt;
@@ -5676,7 +5654,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
if (htab->tlsld_got.refcount > 0)
{
htab->tlsld_got.offset = allocate_got (htab, 8);
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
}
else
@@ -7749,8 +7727,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
indx = 0;
if (tls_type == (TLS_TLS | TLS_LD)
- && (h == NULL
- || !h->def_dynamic))
+ && SYMBOL_REFERENCES_LOCAL (info, h))
offp = &htab->tlsld_got.offset;
else if (h != NULL)
{
@@ -7792,8 +7769,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
if (offp == &htab->tlsld_got.offset)
tls_m = TLS_LD;
- else if (h == NULL
- || !h->def_dynamic)
+ else if ((tls_m & TLS_LD) != 0
+ && SYMBOL_REFERENCES_LOCAL (info, h))
tls_m &= ~TLS_LD;
/* We might have multiple got entries for this sym.
@@ -7827,9 +7804,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
if (indx != 0
|| (bfd_link_pic (info)
&& (h == NULL
- || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
- || offp == &htab->tlsld_got.offset)
- && !(tls_ty == (TLS_TLS | TLS_TPREL)
+ || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+ && !(tls_ty != 0
&& bfd_link_executable (info)
&& SYMBOL_REFERENCES_LOCAL (info, h))))
{
@@ -7939,8 +7915,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
if (tls_type != (TLS_TLS | TLS_LD))
{
if ((tls_mask & TLS_LD) != 0
- && !(h == NULL
- || !h->def_dynamic))
+ && !SYMBOL_REFERENCES_LOCAL (info, h))
off += 8;
if (tls_type != (TLS_TLS | TLS_GD))
{
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index d5a46db..30b0742 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -4543,8 +4543,6 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
sec->has_toc_reloc = 1;
}
- tls_type = 0;
- ifunc = NULL;
r_type = ELF64_R_TYPE (rel->r_info);
switch (r_type)
{
@@ -4597,6 +4595,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
break;
}
+ ifunc = NULL;
if (h != NULL)
{
if (h->type == STT_GNU_IFUNC)
@@ -4622,6 +4621,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
}
}
+ tls_type = 0;
switch (r_type)
{
case R_PPC64_TLSGD:
@@ -7803,11 +7803,9 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
value = sym->st_value;
ok_tprel = FALSE;
- is_local = FALSE;
- if (h == NULL
- || !h->def_dynamic)
+ is_local = SYMBOL_REFERENCES_LOCAL (info, h);
+ if (is_local)
{
- is_local = TRUE;
if (h != NULL
&& h->root.type == bfd_link_hash_undefweak)
ok_tprel = TRUE;
@@ -9278,7 +9276,7 @@ allocate_got (struct elf_link_hash_entry *h,
htab->got_reli_size += rentsize;
}
else if (((bfd_link_pic (info)
- && !((gent->tls_type & TLS_TPREL) != 0
+ && !(gent->tls_type != 0
&& bfd_link_executable (info)
&& SYMBOL_REFERENCES_LOCAL (info, h)))
|| (htab->elf.dynamic_sections_created
@@ -9384,7 +9382,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
if (gent->got.refcount > 0)
{
if ((gent->tls_type & TLS_LD) != 0
- && !h->def_dynamic)
+ && SYMBOL_REFERENCES_LOCAL (info, h))
{
ppc64_tlsld_got (gent->owner)->got.refcount += 1;
*pgent = gent->next;
@@ -9812,9 +9810,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd,
htab->elf.irelplt->size += rel_size;
htab->got_reli_size += rel_size;
}
- else if (bfd_link_pic (info)
- && !((ent->tls_type & TLS_TPREL) != 0
- && bfd_link_executable (info)))
+ else if (bfd_link_dll (info))
{
asection *srel = ppc64_elf_tdata (ibfd)->relgot;
srel->size += rel_size;
@@ -9890,7 +9886,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd,
ent->got.offset = s->size;
ent->owner = ibfd;
s->size += 16;
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
asection *srel = ppc64_elf_tdata (ibfd)->relgot;
srel->size += sizeof (Elf64_External_Rela);
@@ -12185,7 +12181,7 @@ ppc64_elf_layout_multitoc (struct bfd_link_info *info)
htab->got_reli_size += rel_size;
}
else if (bfd_link_pic (info)
- && !((ent->tls_type & TLS_TPREL) != 0
+ && !(ent->tls_type != 0
&& bfd_link_executable (info)))
{
asection *srel = ppc64_elf_tdata (ibfd)->relgot;
@@ -12211,7 +12207,7 @@ ppc64_elf_layout_multitoc (struct bfd_link_info *info)
asection *s = ppc64_elf_tdata (ibfd)->got;
ent->got.offset = s->size;
s->size += 16;
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
asection *srel = ppc64_elf_tdata (ibfd)->relgot;
srel->size += sizeof (Elf64_External_Rela);
@@ -15611,8 +15607,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
struct got_entry *ent;
if (tls_type == (TLS_TLS | TLS_LD)
- && (h == NULL
- || !h->elf.def_dynamic))
+ && SYMBOL_REFERENCES_LOCAL (info, &h->elf))
ent = ppc64_tlsld_got (input_bfd);
else
{
@@ -15687,10 +15682,8 @@ ppc64_elf_relocate_section (bfd *output_bfd,
else if (indx != 0
|| (bfd_link_pic (info)
&& (h == NULL
- || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, &h->elf)
- || (tls_type == (TLS_TLS | TLS_LD)
- && !h->elf.def_dynamic))
- && !(tls_type == (TLS_TLS | TLS_TPREL)
+ || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, &h->elf))
+ && !(tls_type != 0
&& bfd_link_executable (info)
&& SYMBOL_REFERENCES_LOCAL (info, &h->elf))))
relgot = ppc64_elf_tdata (ent->owner)->relgot;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 671776b..fd6ea67 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2019-10-04 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2019-10-04 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/25062
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