aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-sparc.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2018-02-06 18:15:56 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-02-06 18:17:39 +0100
commitc20c30f615756ddfccc4bb75c65ccfc1a399466e (patch)
tree9b5459a709bf72b5b53986110d56499cff9cdc52 /bfd/elfxx-sparc.c
parentbca65a2394ce11bb4a0b001b8a986961c2e84881 (diff)
downloadgdb-c20c30f615756ddfccc4bb75c65ccfc1a399466e.zip
gdb-c20c30f615756ddfccc4bb75c65ccfc1a399466e.tar.gz
gdb-c20c30f615756ddfccc4bb75c65ccfc1a399466e.tar.bz2
Fix PR ld/22263 on SPARC.
This is -fpie -pie generating dynamic relocations in the text section, simply because no TLS transitions are applied in PIE mode. The meat of the patch is to turn calls to bfd_link_pic (info) in TLS-related code into !bfd_link_executable (info) and there are quite a lot of them... bfd/ * elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic into call to !bfd_link_executable and tidy up. (_bfd_sparc_elf_check_relocs): Fix formatting and tidy up. <R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_TLS_IE_HI22>: Likewise. <GOT relocations>: Remove useless code, tidy and merge blocks. <R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_WPLT30>: Tidy up. (_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call to !bfd_link_executable. (allocate_dynrelocs): Likewise. (_bfd_sparc_elf_relocate_section): Fix formatting and tidy up. <R_SPARC_TLS_GD_HI22>: Merge into... <R_SPARC_TLS_GD_LO10>: ...this. Adjust 4th argument in call to sparc_elf_tls_transition and remove redundant code. <R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_TLS_LDO_HIX22>: Likewise. <R_SPARC_TLS_LE_HIX22>: Likewise. Tidy up. <R_SPARC_TLS_LDM_CALL>: Likewise. <R_SPARC_TLS_GD_CALL>: Likewise. Tidy up. <R_SPARC_TLS_GD_ADD>: Likewise. <R_SPARC_TLS_LDM_ADD>: Likewise. <R_SPARC_TLS_LDO_ADD>: Likewise. <R_SPARC_TLS_IE_LD>: Likewise. ld/ * testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC. (pr22263-1): Pass AFLAGS_PIC to the assembler. * testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions. * testsuite/ld-sparc/tlspie32.dd: Adjust to above. * testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions. * testsuite/ld-sparc/tlspie64.dd: Adjust to above.
Diffstat (limited to 'bfd/elfxx-sparc.c')
-rw-r--r--bfd/elfxx-sparc.c269
1 files changed, 109 insertions, 160 deletions
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 9f9feda..afd62d4 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1331,33 +1331,25 @@ sparc_elf_tls_transition (struct bfd_link_info *info, bfd *abfd,
if (! ABI_64_P (abfd)
&& r_type == R_SPARC_TLS_GD_HI22
&& ! _bfd_sparc_elf_tdata (abfd)->has_tlsgd)
- r_type = R_SPARC_REV32;
+ return R_SPARC_REV32;
- if (bfd_link_pic (info))
+ if (!bfd_link_executable (info))
return r_type;
switch (r_type)
{
case R_SPARC_TLS_GD_HI22:
- if (is_local)
- return R_SPARC_TLS_LE_HIX22;
- return R_SPARC_TLS_IE_HI22;
+ return is_local ? R_SPARC_TLS_LE_HIX22 : R_SPARC_TLS_IE_HI22;
case R_SPARC_TLS_GD_LO10:
- if (is_local)
- return R_SPARC_TLS_LE_LOX10;
- return R_SPARC_TLS_IE_LO10;
- case R_SPARC_TLS_IE_HI22:
- if (is_local)
- return R_SPARC_TLS_LE_HIX22;
- return r_type;
- case R_SPARC_TLS_IE_LO10:
- if (is_local)
- return R_SPARC_TLS_LE_LOX10;
- return r_type;
+ return is_local ? R_SPARC_TLS_LE_LOX10 : R_SPARC_TLS_IE_LO10;
case R_SPARC_TLS_LDM_HI22:
return R_SPARC_TLS_LE_HIX22;
case R_SPARC_TLS_LDM_LO10:
return R_SPARC_TLS_LE_LOX10;
+ case R_SPARC_TLS_IE_HI22:
+ return is_local ? R_SPARC_TLS_LE_HIX22 : r_type;
+ case R_SPARC_TLS_IE_LO10:
+ return is_local ? R_SPARC_TLS_LE_LOX10 : r_type;
}
return r_type;
@@ -1425,16 +1417,14 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (r_symndx < symtab_hdr->sh_info)
{
/* A local symbol. */
- isym = bfd_sym_from_r_symndx (&htab->sym_cache,
- abfd, r_symndx);
+ isym = bfd_sym_from_r_symndx (&htab->sym_cache, abfd, r_symndx);
if (isym == NULL)
return FALSE;
/* Check relocation against local STT_GNU_IFUNC symbol. */
if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
{
- h = elf_sparc_get_local_sym_hash (htab, abfd, rel,
- TRUE);
+ h = elf_sparc_get_local_sym_hash (htab, abfd, rel, TRUE);
if (h == NULL)
return FALSE;
@@ -1456,13 +1446,10 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
h = (struct elf_link_hash_entry *) h->root.u.i.link;
}
- if (h && h->type == STT_GNU_IFUNC)
+ if (h && h->type == STT_GNU_IFUNC && h->def_regular)
{
- if (h->def_regular)
- {
- h->ref_regular = 1;
- h->plt.refcount += 1;
- }
+ h->ref_regular = 1;
+ h->plt.refcount += 1;
}
/* Compatibility with old R_SPARC_REV32 reloc conflicting
@@ -1505,13 +1492,13 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_SPARC_TLS_LE_HIX22:
case R_SPARC_TLS_LE_LOX10:
- if (bfd_link_pic (info))
+ if (!bfd_link_executable (info))
goto r_sparc_plt32;
break;
case R_SPARC_TLS_IE_HI22:
case R_SPARC_TLS_IE_LO10:
- if (bfd_link_pic (info))
+ if (!bfd_link_executable (info))
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1530,14 +1517,6 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
switch (r_type)
{
- default:
- case R_SPARC_GOT10:
- case R_SPARC_GOT13:
- case R_SPARC_GOT22:
- case R_SPARC_GOTDATA_OP_HIX22:
- case R_SPARC_GOTDATA_OP_LOX10:
- tls_type = GOT_NORMAL;
- break;
case R_SPARC_TLS_GD_HI22:
case R_SPARC_TLS_GD_LO10:
tls_type = GOT_TLS_GD;
@@ -1546,6 +1525,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_SPARC_TLS_IE_LO10:
tls_type = GOT_TLS_IE;
break;
+ default:
+ tls_type = GOT_NORMAL;
+ break;
}
if (h != NULL)
@@ -1573,26 +1555,23 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
_bfd_sparc_elf_local_got_tls_type (abfd)
= (char *) (local_got_refcounts + symtab_hdr->sh_info);
}
- switch (r_type)
- {
- case R_SPARC_GOTDATA_OP_HIX22:
- case R_SPARC_GOTDATA_OP_LOX10:
- break;
- default:
- local_got_refcounts[r_symndx] += 1;
- break;
- }
+ if (r_type != R_SPARC_GOTDATA_OP_HIX22
+ && r_type != R_SPARC_GOTDATA_OP_LOX10)
+ local_got_refcounts[r_symndx] += 1;
+
old_tls_type = _bfd_sparc_elf_local_got_tls_type (abfd) [r_symndx];
}
- /* If a TLS symbol is accessed using IE at least once,
- there is no point to use dynamic model for it. */
- if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN
- && (old_tls_type != GOT_TLS_GD
- || tls_type != GOT_TLS_IE))
+ /* If a TLS symbol is accessed using IE at least once, there is no point
+ in using the dynamic model for it. */
+ if (old_tls_type != tls_type)
{
- if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD)
+ if (old_tls_type == GOT_UNKNOWN)
+ ;
+ else if (old_tls_type == GOT_TLS_GD && tls_type == GOT_TLS_IE)
+ ;
+ else if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD)
tls_type = old_tls_type;
else
{
@@ -1602,10 +1581,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
abfd, h ? h->root.root.string : "<local>");
return FALSE;
}
- }
- if (old_tls_type != tls_type)
- {
if (h != NULL)
_bfd_sparc_elf_hash_entry (h)->tls_type = tls_type;
else
@@ -1613,11 +1589,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
}
}
- if (htab->elf.sgot == NULL)
- {
- if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
- return FALSE;
- }
+ if (!htab->elf.sgot
+ && !_bfd_elf_create_got_section (htab->elf.dynobj, info))
+ return FALSE;
if (eh != NULL)
eh->has_got_reloc = 1;
@@ -1625,28 +1599,25 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_SPARC_TLS_GD_CALL:
case R_SPARC_TLS_LDM_CALL:
- if (bfd_link_pic (info))
- {
- /* These are basically R_SPARC_TLS_WPLT30 relocs against
- __tls_get_addr. */
- h = (struct elf_link_hash_entry *)
- bfd_link_hash_lookup (info->hash, "__tls_get_addr", TRUE,
- FALSE, TRUE);
- }
- else
+ if (bfd_link_executable (info))
break;
+
+ /* Essentially R_SPARC_WPLT30 relocs against __tls_get_addr. */
+ h = (struct elf_link_hash_entry *)
+ bfd_link_hash_lookup (info->hash, "__tls_get_addr", TRUE,
+ FALSE, TRUE);
/* Fall through */
- case R_SPARC_PLT32:
case R_SPARC_WPLT30:
+ case R_SPARC_PLT32:
+ case R_SPARC_PLT64:
case R_SPARC_HIPLT22:
case R_SPARC_LOPLT10:
case R_SPARC_PCPLT32:
case R_SPARC_PCPLT22:
case R_SPARC_PCPLT10:
- case R_SPARC_PLT64:
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in adjust_dynamic_symbol,
+ /* This symbol requires a procedure linkage table entry.
+ We actually build the entry in adjust_dynamic_symbol,
because this might be a case of linking PIC code without
linking in any dynamic objects, in which case we don't
need to generate a procedure linkage table after all. */
@@ -1659,7 +1630,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
reloc for a local symbol if you assemble a call from
one section to another when using -K pic. We treat
it as WDISP30. */
- if (ELF32_R_TYPE (rel->r_info) == R_SPARC_PLT32)
+ if (r_type == R_SPARC_PLT32)
goto r_sparc_plt32;
break;
}
@@ -1675,14 +1646,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
h->needs_plt = 1;
- {
- int this_r_type;
+ if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64)
+ goto r_sparc_plt32;
- this_r_type = SPARC_ELF_R_TYPE (rel->r_info);
- if (this_r_type == R_SPARC_PLT32
- || this_r_type == R_SPARC_PLT64)
- goto r_sparc_plt32;
- }
h->plt.refcount += 1;
eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
@@ -1886,9 +1852,7 @@ _bfd_sparc_elf_gc_mark_hook (asection *sec,
return NULL;
}
- /* FIXME: The test here, in check_relocs and in relocate_section
- dealing with TLS optimization, ought to be !bfd_link_executable (info). */
- if (bfd_link_pic (info))
+ if (!bfd_link_executable (info))
{
switch (SPARC_ELF_R_TYPE (rel->r_info))
{
@@ -2227,7 +2191,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
/* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary,
make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */
if (h->got.refcount > 0
- && !bfd_link_pic (info)
+ && bfd_link_executable (info)
&& h->dynindx == -1
&& _bfd_sparc_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
h->got.offset = (bfd_vma) -1;
@@ -2963,8 +2927,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
- howto = _bfd_sparc_elf_howto_table + r_type;
+ howto = _bfd_sparc_elf_howto_table + r_type;
r_symndx = SPARC_ELF_R_SYMNDX (htab, rel->r_info);
h = NULL;
sym = NULL;
@@ -3131,8 +3095,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
}
eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
- resolved_to_zero = (eh != NULL
- && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
+ resolved_to_zero = eh && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
switch (r_type)
{
@@ -3378,8 +3341,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
case R_SPARC_H34:
case R_SPARC_UA64:
r_sparc_plt32:
- if ((input_section->flags & SEC_ALLOC) == 0
- || is_vxworks_tls)
+ if ((input_section->flags & SEC_ALLOC) == 0 || is_vxworks_tls)
break;
/* Copy dynamic function pointer relocations. Don't generate
@@ -3551,40 +3513,19 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
break;
case R_SPARC_TLS_GD_HI22:
- if (! ABI_64_P (input_bfd)
- && ! _bfd_sparc_elf_tdata (input_bfd)->has_tlsgd)
- {
- /* R_SPARC_REV32 used the same reloc number as
- R_SPARC_TLS_GD_HI22. */
- r_type = R_SPARC_REV32;
- break;
- }
- /* Fall through */
-
case R_SPARC_TLS_GD_LO10:
case R_SPARC_TLS_IE_HI22:
case R_SPARC_TLS_IE_LO10:
- r_type = sparc_elf_tls_transition (info, input_bfd, r_type, h == NULL);
- tls_type = GOT_UNKNOWN;
- if (h == NULL && local_got_offsets)
+ r_type = sparc_elf_tls_transition (info, input_bfd, r_type,
+ h == NULL || h->dynindx == -1);
+ if (r_type == R_SPARC_REV32)
+ break;
+ if (h != NULL)
+ tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type;
+ else if (local_got_offsets)
tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx];
- else if (h != NULL)
- {
- tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type;
- if (!bfd_link_pic (info)
- && h->dynindx == -1
- && tls_type == GOT_TLS_IE)
- switch (SPARC_ELF_R_TYPE (rel->r_info))
- {
- case R_SPARC_TLS_GD_HI22:
- case R_SPARC_TLS_IE_HI22:
- r_type = R_SPARC_TLS_LE_HIX22;
- break;
- default:
- r_type = R_SPARC_TLS_LE_LOX10;
- break;
- }
- }
+ else
+ tls_type = GOT_UNKNOWN;
if (tls_type == GOT_TLS_IE)
switch (r_type)
{
@@ -3695,7 +3636,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
case R_SPARC_TLS_LDM_HI22:
case R_SPARC_TLS_LDM_LO10:
- if (! bfd_link_pic (info))
+ /* LD -> LE */
+ if (bfd_link_executable (info))
{
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
continue;
@@ -3706,43 +3648,42 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
case R_SPARC_TLS_LDO_HIX22:
case R_SPARC_TLS_LDO_LOX10:
- if (bfd_link_pic (info))
+ /* LD -> LE */
+ if (bfd_link_executable (info))
+ {
+ if (r_type == R_SPARC_TLS_LDO_HIX22)
+ r_type = R_SPARC_TLS_LE_HIX22;
+ else
+ r_type = R_SPARC_TLS_LE_LOX10;
+ }
+ else
{
relocation -= dtpoff_base (info);
break;
}
-
- r_type = (r_type == R_SPARC_TLS_LDO_HIX22
- ? R_SPARC_TLS_LE_HIX22 : R_SPARC_TLS_LE_LOX10);
/* Fall through. */
case R_SPARC_TLS_LE_HIX22:
case R_SPARC_TLS_LE_LOX10:
- if (bfd_link_pic (info))
+ if (!bfd_link_executable (info))
{
Elf_Internal_Rela outrel;
- bfd_boolean skip;
-
- BFD_ASSERT (sreloc != NULL);
- skip = FALSE;
- outrel.r_offset =
- _bfd_elf_section_offset (output_bfd, info, input_section,
- rel->r_offset);
- if (outrel.r_offset == (bfd_vma) -1)
- skip = TRUE;
- else if (outrel.r_offset == (bfd_vma) -2)
- skip = TRUE;
- outrel.r_offset += (input_section->output_section->vma
- + input_section->output_offset);
- if (skip)
+ bfd_vma offset
+ = _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset);
+ if (offset == (bfd_vma) -1 || offset == (bfd_vma) -2)
memset (&outrel, 0, sizeof outrel);
else
{
+ outrel.r_offset = offset
+ + input_section->output_section->vma
+ + input_section->output_offset;
outrel.r_info = SPARC_ELF_R_INFO (htab, NULL, 0, r_type);
- outrel.r_addend = relocation - dtpoff_base (info)
- + rel->r_addend;
+ outrel.r_addend
+ = relocation - dtpoff_base (info) + rel->r_addend;
}
+ BFD_ASSERT (sreloc != NULL);
sparc_elf_append_rela (output_bfd, sreloc, &outrel);
continue;
}
@@ -3750,7 +3691,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
break;
case R_SPARC_TLS_LDM_CALL:
- if (! bfd_link_pic (info))
+ /* LD -> LE */
+ if (bfd_link_executable (info))
{
/* mov %g0, %o0 */
bfd_put_32 (output_bfd, 0x90100000, contents + rel->r_offset);
@@ -3759,20 +3701,22 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
/* Fall through */
case R_SPARC_TLS_GD_CALL:
- tls_type = GOT_UNKNOWN;
- if (h == NULL && local_got_offsets)
+ if (h != NULL)
+ tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type;
+ else if (local_got_offsets)
tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx];
- else if (h != NULL)
- tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type;
- if (! bfd_link_pic (info)
+ else
+ tls_type = GOT_UNKNOWN;
+ /* GD -> IE or LE */
+ if (bfd_link_executable (info)
|| (r_type == R_SPARC_TLS_GD_CALL && tls_type == GOT_TLS_IE))
{
Elf_Internal_Rela *rel2;
bfd_vma insn;
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ /* GD -> LE */
+ if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1))
{
- /* GD -> LE */
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
continue;
}
@@ -3835,12 +3779,14 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
goto r_sparc_wplt30;
case R_SPARC_TLS_GD_ADD:
- tls_type = GOT_UNKNOWN;
- if (h == NULL && local_got_offsets)
+ if (h != NULL)
+ tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type;
+ else if (local_got_offsets)
tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx];
- else if (h != NULL)
- tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type;
- if (! bfd_link_pic (info) || tls_type == GOT_TLS_IE)
+ else
+ tls_type = GOT_UNKNOWN;
+ /* GD -> IE or LE */
+ if (bfd_link_executable (info) || tls_type == GOT_TLS_IE)
{
/* add %reg1, %reg2, %reg3, %tgd_add(foo)
changed into IE:
@@ -3848,21 +3794,23 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
or LE:
add %g7, %reg2, %reg3. */
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
- if ((h != NULL && h->dynindx != -1) || bfd_link_pic (info))
- relocation = insn | (ABI_64_P (output_bfd) ? 0xc0580000 : 0xc0000000);
- else
+ if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1))
relocation = (insn & ~0x7c000) | 0x1c000;
+ else
+ relocation = insn | (ABI_64_P (output_bfd) ? 0xc0580000 : 0xc0000000);
bfd_put_32 (output_bfd, relocation, contents + rel->r_offset);
}
continue;
case R_SPARC_TLS_LDM_ADD:
- if (! bfd_link_pic (info))
+ /* LD -> LE */
+ if (bfd_link_executable (info))
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
continue;
case R_SPARC_TLS_LDO_ADD:
- if (! bfd_link_pic (info))
+ /* LD -> LE */
+ if (bfd_link_executable (info))
{
/* Change rs1 into %g7. */
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
@@ -3873,7 +3821,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
case R_SPARC_TLS_IE_LD:
case R_SPARC_TLS_IE_LDX:
- if (! bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ /* IE -> LE */
+ if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1))
{
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
int rs2 = insn & 0x1f;