tilepro: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic, for TLS transition check. Not sure if it works correctly. All usages of bfd_link_pic should be audited. PR ld/22263 * elf32-tilepro.c (tilepro_elf_tls_transition): Replace bfd_link_pic with !bfd_link_executable, !bfd_link_pic with bfd_link_executable for TLS check. (tilepro_elf_check_relocs): Likewise. (allocate_dynrelocs): Likewise. (tilepro_elf_relocate_section): Likewise.
This commit is contained in:
parent
0fb7012e88
commit
1ba1f393fa
2 changed files with 23 additions and 11 deletions
|
@ -1,4 +1,14 @@
|
||||||
2017-10-18 H.J. Lu <hongjiu.lu@intel.com>
|
2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/22263
|
||||||
|
* elf32-tilepro.c (tilepro_elf_tls_transition): Replace
|
||||||
|
bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
|
||||||
|
bfd_link_executable for TLS check.
|
||||||
|
(tilepro_elf_check_relocs): Likewise.
|
||||||
|
(allocate_dynrelocs): Likewise.
|
||||||
|
(tilepro_elf_relocate_section): Likewise.
|
||||||
|
|
||||||
|
2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
PR ld/22263
|
PR ld/22263
|
||||||
* elfxx-sparc.c (sparc_elf_tls_transition): Replace
|
* elfxx-sparc.c (sparc_elf_tls_transition): Replace
|
||||||
|
|
|
@ -1433,7 +1433,7 @@ static int
|
||||||
tilepro_elf_tls_transition (struct bfd_link_info *info, int r_type,
|
tilepro_elf_tls_transition (struct bfd_link_info *info, int r_type,
|
||||||
int is_local)
|
int is_local)
|
||||||
{
|
{
|
||||||
if (bfd_link_pic (info))
|
if (!bfd_link_executable (info))
|
||||||
return r_type;
|
return r_type;
|
||||||
|
|
||||||
if (is_local)
|
if (is_local)
|
||||||
|
@ -1518,7 +1518,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
||||||
case R_TILEPRO_IMM16_X1_TLS_LE_HI:
|
case R_TILEPRO_IMM16_X1_TLS_LE_HI:
|
||||||
case R_TILEPRO_IMM16_X0_TLS_LE_HA:
|
case R_TILEPRO_IMM16_X0_TLS_LE_HA:
|
||||||
case R_TILEPRO_IMM16_X1_TLS_LE_HA:
|
case R_TILEPRO_IMM16_X1_TLS_LE_HA:
|
||||||
if (bfd_link_pic (info))
|
if (!bfd_link_executable (info))
|
||||||
goto r_tilepro_plt32;
|
goto r_tilepro_plt32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1543,7 +1543,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
||||||
case R_TILEPRO_IMM16_X0_TLS_IE_HA:
|
case R_TILEPRO_IMM16_X0_TLS_IE_HA:
|
||||||
case R_TILEPRO_IMM16_X1_TLS_IE_HA:
|
case R_TILEPRO_IMM16_X1_TLS_IE_HA:
|
||||||
tls_type = GOT_TLS_IE;
|
tls_type = GOT_TLS_IE;
|
||||||
if (bfd_link_pic (info))
|
if (!bfd_link_executable (info))
|
||||||
info->flags |= DF_STATIC_TLS;
|
info->flags |= DF_STATIC_TLS;
|
||||||
goto have_got_reference;
|
goto have_got_reference;
|
||||||
|
|
||||||
|
@ -1629,7 +1629,7 @@ tilepro_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_TILEPRO_TLS_GD_CALL:
|
case R_TILEPRO_TLS_GD_CALL:
|
||||||
if (bfd_link_pic (info))
|
if (!bfd_link_executable (info))
|
||||||
{
|
{
|
||||||
/* These are basically R_TILEPRO_JOFFLONG_X1_PLT relocs
|
/* These are basically R_TILEPRO_JOFFLONG_X1_PLT relocs
|
||||||
against __tls_get_addr. */
|
against __tls_get_addr. */
|
||||||
|
@ -2105,7 +2105,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||||
/* If a TLS_IE symbol is now local to the binary, make it a TLS_LE
|
/* If a TLS_IE symbol is now local to the binary, make it a TLS_LE
|
||||||
requiring no TLS entry. */
|
requiring no TLS entry. */
|
||||||
if (h->got.refcount > 0
|
if (h->got.refcount > 0
|
||||||
&& !bfd_link_pic (info)
|
&& bfd_link_executable (info)
|
||||||
&& h->dynindx == -1
|
&& h->dynindx == -1
|
||||||
&& tilepro_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
|
&& tilepro_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
|
||||||
h->got.offset = (bfd_vma) -1;
|
h->got.offset = (bfd_vma) -1;
|
||||||
|
@ -2786,8 +2786,8 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
||||||
else if (h != NULL)
|
else if (h != NULL)
|
||||||
tls_type = tilepro_elf_hash_entry(h)->tls_type;
|
tls_type = tilepro_elf_hash_entry(h)->tls_type;
|
||||||
|
|
||||||
is_tls_iele = (! bfd_link_pic (info) || tls_type == GOT_TLS_IE);
|
is_tls_iele = (bfd_link_executable (info) || tls_type == GOT_TLS_IE);
|
||||||
is_tls_le = is_tls_iele && (!bfd_link_pic (info)
|
is_tls_le = is_tls_iele && (bfd_link_executable (info)
|
||||||
&& (h == NULL || h->dynindx == -1));
|
&& (h == NULL || h->dynindx == -1));
|
||||||
|
|
||||||
if (r_type == R_TILEPRO_TLS_GD_CALL)
|
if (r_type == R_TILEPRO_TLS_GD_CALL)
|
||||||
|
@ -2864,7 +2864,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R_TILEPRO_TLS_IE_LOAD:
|
case R_TILEPRO_TLS_IE_LOAD:
|
||||||
if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
|
if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1))
|
||||||
/* IE -> LE */
|
/* IE -> LE */
|
||||||
tilepro_replace_insn (contents + rel->r_offset,
|
tilepro_replace_insn (contents + rel->r_offset,
|
||||||
insn_mask_X1_no_dest_no_srca,
|
insn_mask_X1_no_dest_no_srca,
|
||||||
|
@ -3191,7 +3191,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
||||||
case R_TILEPRO_IMM16_X1_TLS_LE_HI:
|
case R_TILEPRO_IMM16_X1_TLS_LE_HI:
|
||||||
case R_TILEPRO_IMM16_X0_TLS_LE_HA:
|
case R_TILEPRO_IMM16_X0_TLS_LE_HA:
|
||||||
case R_TILEPRO_IMM16_X1_TLS_LE_HA:
|
case R_TILEPRO_IMM16_X1_TLS_LE_HA:
|
||||||
if (bfd_link_pic (info))
|
if (!bfd_link_executable (info))
|
||||||
{
|
{
|
||||||
Elf_Internal_Rela outrel;
|
Elf_Internal_Rela outrel;
|
||||||
bfd_boolean skip;
|
bfd_boolean skip;
|
||||||
|
@ -3246,7 +3246,9 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
|
||||||
else if (h != NULL)
|
else if (h != NULL)
|
||||||
{
|
{
|
||||||
tls_type = tilepro_elf_hash_entry(h)->tls_type;
|
tls_type = tilepro_elf_hash_entry(h)->tls_type;
|
||||||
if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type == GOT_TLS_IE)
|
if (bfd_link_executable (info)
|
||||||
|
&& h->dynindx == -1
|
||||||
|
&& tls_type == GOT_TLS_IE)
|
||||||
r_type = tilepro_tls_translate_to_le (r_type);
|
r_type = tilepro_tls_translate_to_le (r_type);
|
||||||
}
|
}
|
||||||
if (tls_type == GOT_TLS_IE)
|
if (tls_type == GOT_TLS_IE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue