+2020-06-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf-bfd.h (elf_link_hash_entry): Add tlsdesc_plt and
+ tlsdesc_got.
+ * elf32-arm.c (elf32_arm_link_hash_table): Remove tlsdesc_plt
+ and dt_tlsdesc_got.
+ (elf32_arm_size_dynamic_sections): Updated. Clear
+ root.tlsdesc_plt for DF_BIND_NOW.
+ (elf32_arm_finish_dynamic_sections): Updated.
+ (elf32_arm_output_arch_local_syms): Likewise.
+ * elf32-nds32.c (nds32_elf_size_dynamic_sections): Updated.
+ Clear root.tlsdesc_plt for DF_BIND_NOW.
+ (nds32_elf_finish_dynamic_sections): Updated.
+ * elf32-nds32.h (elf_nds32_link_hash_table): Remove
+ dt_tlsdesc_plt and dt_tlsdesc_got.
+ * elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Updated.
+ * elfnn-aarch64.c (elf_aarch64_link_hash_table): Remove
+ tlsdesc_plt and dt_tlsdesc_got.
+ (elfNN_aarch64_allocate_dynrelocs): Updated.
+ (elfNN_aarch64_finish_dynamic_sections): Likewise.
+ (elfNN_aarch64_size_dynamic_sections): Updated. Clear
+ root.tlsdesc_plt for DF_BIND_NOW. Don't check DF_BIND_NOW
+ twice.
+ * elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated.
+ (_bfd_x86_elf_size_dynamic_sections): Likewise.
+ (_bfd_x86_elf_finish_dynamic_sections): Likewise.
+ * elfxx-x86.h (elf_x86_link_hash_table): Remove tlsdesc_plt and
+ tlsdesc_got.
+
2020-06-07 H.J. Lu <hongjiu.lu@intel.com>
* elf32-tic6x.c (elf32_bed): Defined the default to
asection *tls_sec;
bfd_size_type tls_size; /* Bytes. */
+ /* The offset into splt of the PLT entry for the TLS descriptor
+ resolver. Special values are 0, if not necessary (or not found
+ to be necessary yet), and -1 if needed but not determined
+ yet. */
+ bfd_vma tlsdesc_plt;
+
+ /* The GOT offset for the lazy trampoline. Communicated to the
+ loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1
+ indicates an offset is not allocated. */
+ bfd_vma tlsdesc_got;
+
/* Target OS for linker output. */
enum elf_target_os target_os;
/* The (unloaded but important) VxWorks .rela.plt.unloaded section. */
asection *srelplt2;
- /* The offset into splt of the PLT entry for the TLS descriptor
- resolver. Special values are 0, if not necessary (or not found
- to be necessary yet), and -1 if needed but not determined
- yet. */
- bfd_vma dt_tlsdesc_plt;
-
- /* The offset into sgot of the GOT entry used by the PLT entry
- above. */
- bfd_vma dt_tlsdesc_got;
-
/* Offset in .plt section of tls_arm_trampoline. */
bfd_vma tls_trampoline;
/* If we're not using lazy TLS relocations, don't generate the
PLT and GOT entries they require. */
- if (!(info->flags & DF_BIND_NOW))
+ if ((info->flags & DF_BIND_NOW))
+ htab->root.tlsdesc_plt = 0;
+ else
{
- htab->dt_tlsdesc_got = htab->root.sgot->size;
+ htab->root.tlsdesc_got = htab->root.sgot->size;
htab->root.sgot->size += 4;
- htab->dt_tlsdesc_plt = htab->root.splt->size;
+ htab->root.tlsdesc_plt = htab->root.splt->size;
htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline);
}
}
|| !add_dynamic_entry (DT_JMPREL, 0))
return FALSE;
- if (htab->dt_tlsdesc_plt
+ if (htab->root.tlsdesc_plt
&& (!add_dynamic_entry (DT_TLSDESC_PLT,0)
|| !add_dynamic_entry (DT_TLSDESC_GOT,0)))
return FALSE;
case DT_TLSDESC_PLT:
s = htab->root.splt;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_plt);
+ + htab->root.tlsdesc_plt);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_TLSDESC_GOT:
s = htab->root.sgot;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_got);
+ + htab->root.tlsdesc_got);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
if (splt->output_section->owner == output_bfd)
elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
- if (htab->dt_tlsdesc_plt)
+ if (htab->root.tlsdesc_plt)
{
bfd_vma got_address
= sgot->output_section->vma + sgot->output_offset;
= splt->output_section->vma + splt->output_offset;
arm_put_trampoline (htab, output_bfd,
- splt->contents + htab->dt_tlsdesc_plt,
+ splt->contents + htab->root.tlsdesc_plt,
dl_tlsdesc_lazy_trampoline, 6);
bfd_put_32 (output_bfd,
- gotplt_address + htab->dt_tlsdesc_got
- - (plt_address + htab->dt_tlsdesc_plt)
+ gotplt_address + htab->root.tlsdesc_got
+ - (plt_address + htab->root.tlsdesc_plt)
- dl_tlsdesc_lazy_trampoline[6],
- splt->contents + htab->dt_tlsdesc_plt + 24);
+ splt->contents + htab->root.tlsdesc_plt + 24);
bfd_put_32 (output_bfd,
- got_address - (plt_address + htab->dt_tlsdesc_plt)
+ got_address - (plt_address + htab->root.tlsdesc_plt)
- dl_tlsdesc_lazy_trampoline[7],
- splt->contents + htab->dt_tlsdesc_plt + 24 + 4);
+ splt->contents + htab->root.tlsdesc_plt + 24 + 4);
}
if (htab->tls_trampoline)
}
}
}
- if (htab->dt_tlsdesc_plt != 0)
+ if (htab->root.tlsdesc_plt != 0)
{
/* Mapping symbols for the lazy tls trampoline. */
- if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, htab->dt_tlsdesc_plt))
+ if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM,
+ htab->root.tlsdesc_plt))
return FALSE;
if (!elf32_arm_output_map_sym (&osi, ARM_MAP_DATA,
- htab->dt_tlsdesc_plt + 24))
+ htab->root.tlsdesc_plt + 24))
return FALSE;
}
if (htab->tls_trampoline != 0)
/* If we're not using lazy TLS relocations, don't generate the
PLT and GOT entries they require. */
- if (!(info->flags & DF_BIND_NOW))
+ if ((info->flags & DF_BIND_NOW))
+ htab->root.tlsdesc_plt = 0;
+ else
{
- htab->dt_tlsdesc_got = htab->root.sgot->size;
+ htab->root.tlsdesc_got = htab->root.sgot->size;
htab->root.sgot->size += 4;
- htab->dt_tlsdesc_plt = htab->root.splt->size;
+ htab->root.tlsdesc_plt = htab->root.splt->size;
htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline);
}
}
if (htab->tls_desc_trampoline && plt)
{
- if (htab->dt_tlsdesc_plt
+ if (htab->root.tlsdesc_plt
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
return FALSE;
case DT_TLSDESC_PLT:
s = htab->root.splt;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_plt);
+ + htab->root.tlsdesc_plt);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_TLSDESC_GOT:
s = htab->root.sgot;
dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_got);
+ + htab->root.tlsdesc_got);
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
}
PLT_ENTRY_SIZE;
}
- if (htab->dt_tlsdesc_plt)
+ if (htab->root.tlsdesc_plt)
{
/* Calculate addresses. */
asection *sgot = sgot = ehtab->sgot;
bfd_vma pltgot = sgotplt->output_section->vma
+ sgotplt->output_offset;
bfd_vma tlsdesc_got = sgot->output_section->vma + sgot->output_offset
- + htab->dt_tlsdesc_got;
+ + htab->root.tlsdesc_got;
/* Get GP offset. */
pltgot -= elf_gp (output_bfd) - 4; /* PLTGOT[1] */
dl_tlsdesc_lazy_trampoline[5] += 0xfff & pltgot;
/* Insert .plt. */
- nds32_put_trampoline (splt->contents + htab->dt_tlsdesc_plt,
+ nds32_put_trampoline (splt->contents + htab->root.tlsdesc_plt,
dl_tlsdesc_lazy_trampoline,
ARRAY_SIZE (dl_tlsdesc_lazy_trampoline));
}
/* Disable if linking a dynamically linked executable. */
int load_store_relax;
- /* The offset into splt of the PLT entry for the TLS descriptor
- resolver. Special values are 0, if not necessary (or not found
- to be necessary yet), and -1 if needed but not determined
- yet. */
- bfd_vma dt_tlsdesc_plt;
-
- /* The offset into sgot of the GOT entry used by the PLT entry
- above. */
- bfd_vma dt_tlsdesc_got;
-
/* Offset in .plt section of tls_nds32_trampoline. */
bfd_vma tls_trampoline;
+ htab->lazy_plt->plt0_got2_offset));
}
- if (htab->tlsdesc_plt)
+ if (htab->elf.tlsdesc_plt)
{
bfd_put_64 (output_bfd, (bfd_vma) 0,
- htab->elf.sgot->contents + htab->tlsdesc_got);
+ htab->elf.sgot->contents + htab->elf.tlsdesc_got);
- memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
+ memcpy (htab->elf.splt->contents + htab->elf.tlsdesc_plt,
htab->lazy_plt->plt_tlsdesc_entry,
htab->lazy_plt->plt_tlsdesc_entry_size);
+ 8
- htab->elf.splt->output_section->vma
- htab->elf.splt->output_offset
- - htab->tlsdesc_plt
+ - htab->elf.tlsdesc_plt
- htab->lazy_plt->plt_tlsdesc_got1_insn_end),
(htab->elf.splt->contents
- + htab->tlsdesc_plt
+ + htab->elf.tlsdesc_plt
+ htab->lazy_plt->plt_tlsdesc_got1_offset));
/* Add offset for indirect branch via GOT+TDG, where TDG
stands for htab->tlsdesc_got, subtracting the offset
bfd_put_32 (output_bfd,
(htab->elf.sgot->output_section->vma
+ htab->elf.sgot->output_offset
- + htab->tlsdesc_got
+ + htab->elf.tlsdesc_got
- htab->elf.splt->output_section->vma
- htab->elf.splt->output_offset
- - htab->tlsdesc_plt
+ - htab->elf.tlsdesc_plt
- htab->lazy_plt->plt_tlsdesc_got2_insn_end),
(htab->elf.splt->contents
- + htab->tlsdesc_plt
+ + htab->elf.tlsdesc_plt
+ htab->lazy_plt->plt_tlsdesc_got2_offset));
}
}
/* JUMP_SLOT relocs for variant PCS symbols may be present. */
int variant_pcs;
- /* The offset into splt of the PLT entry for the TLS descriptor
- resolver. Special values are 0, if not necessary (or not found
- to be necessary yet), and -1 if needed but not determined
- yet. */
- bfd_vma tlsdesc_plt;
-
/* The number of bytes in the PLT enty for the TLS descriptor. */
bfd_size_type tlsdesc_plt_entry_size;
- /* The GOT offset for the lazy trampoline. Communicated to the
- loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1
- indicates an offset is not allocated. */
- bfd_vma dt_tlsdesc_got;
-
/* Used by local STT_GNU_IFUNC symbols. */
htab_t loc_hash_table;
void * loc_hash_memory;
ret->plt_entry = elfNN_aarch64_small_plt_entry;
ret->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE;
ret->obfd = abfd;
- ret->dt_tlsdesc_got = (bfd_vma) - 1;
+ ret->root.tlsdesc_got = (bfd_vma) - 1;
if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
sizeof (struct elf_aarch64_stub_hash_entry)))
type. */
/* TLSDESC PLT is now needed, but not yet determined. */
- htab->tlsdesc_plt = (bfd_vma) - 1;
+ htab->root.tlsdesc_plt = (bfd_vma) - 1;
}
if (got_type & GOT_TLS_GD)
{
htab->root.srelplt->size += RELOC_SIZE (htab);
/* Note RELOC_COUNT not incremented here! */
- htab->tlsdesc_plt = (bfd_vma) - 1;
+ htab->root.tlsdesc_plt = (bfd_vma) - 1;
}
if (got_type & GOT_TLS_GD)
if (htab->root.srelplt)
htab->sgotplt_jump_table_size = aarch64_compute_jump_table_size (htab);
- if (htab->tlsdesc_plt)
+ if (htab->root.tlsdesc_plt)
{
if (htab->root.splt->size == 0)
htab->root.splt->size += htab->plt_header_size;
/* If we're not using lazy TLS relocations, don't generate the
GOT and PLT entry required. */
- if (!(info->flags & DF_BIND_NOW))
+ if ((info->flags & DF_BIND_NOW))
+ htab->root.tlsdesc_plt = 0;
+ else
{
- htab->tlsdesc_plt = htab->root.splt->size;
+ htab->root.tlsdesc_plt = htab->root.splt->size;
htab->root.splt->size += htab->tlsdesc_plt_entry_size;
- htab->dt_tlsdesc_got = htab->root.sgot->size;
+ htab->root.tlsdesc_got = htab->root.sgot->size;
htab->root.sgot->size += GOT_ENTRY_SIZE;
}
}
&& !add_dynamic_entry (DT_AARCH64_VARIANT_PCS, 0))
return FALSE;
- if (htab->tlsdesc_plt
- && !(info->flags & DF_BIND_NOW)
+ if (htab->root.tlsdesc_plt
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
return FALSE;
case DT_TLSDESC_PLT:
s = htab->root.splt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
- + htab->tlsdesc_plt;
+ + htab->root.tlsdesc_plt;
break;
case DT_TLSDESC_GOT:
s = htab->root.sgot;
- BFD_ASSERT (htab->dt_tlsdesc_got != (bfd_vma)-1);
+ BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1);
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
- + htab->dt_tlsdesc_got;
+ + htab->root.tlsdesc_got;
break;
}
this_hdr.sh_entsize = htab->plt_entry_size;
- if (htab->tlsdesc_plt && !(info->flags & DF_BIND_NOW))
+ if (htab->root.tlsdesc_plt && !(info->flags & DF_BIND_NOW))
{
- BFD_ASSERT (htab->dt_tlsdesc_got != (bfd_vma)-1);
+ BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1);
bfd_put_NN (output_bfd, (bfd_vma) 0,
- htab->root.sgot->contents + htab->dt_tlsdesc_got);
+ htab->root.sgot->contents + htab->root.tlsdesc_got);
const bfd_byte *entry = elfNN_aarch64_tlsdesc_small_plt_entry;
htab->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE;
entry = elfNN_aarch64_tlsdesc_small_plt_bti_entry;
}
- memcpy (htab->root.splt->contents + htab->tlsdesc_plt,
+ memcpy (htab->root.splt->contents + htab->root.tlsdesc_plt,
entry, htab->tlsdesc_plt_entry_size);
{
bfd_vma adrp1_addr =
htab->root.splt->output_section->vma
- + htab->root.splt->output_offset + htab->tlsdesc_plt + 4;
+ + htab->root.splt->output_offset
+ + htab->root.tlsdesc_plt + 4;
bfd_vma adrp2_addr = adrp1_addr + 4;
htab->root.sgotplt->output_section->vma
+ htab->root.sgotplt->output_offset;
- bfd_vma dt_tlsdesc_got = got_addr + htab->dt_tlsdesc_got;
+ bfd_vma dt_tlsdesc_got = got_addr + htab->root.tlsdesc_got;
bfd_byte *plt_entry =
- htab->root.splt->contents + htab->tlsdesc_plt;
+ htab->root.splt->contents + htab->root.tlsdesc_plt;
/* First instruction in BTI enabled PLT stub is a BTI
instruction so skip it. */
{
htab->elf.srelplt->size += htab->sizeof_reloc;
if (bed->target_id == X86_64_ELF_DATA)
- htab->tlsdesc_plt = (bfd_vma) -1;
+ htab->elf.tlsdesc_plt = (bfd_vma) -1;
}
}
else
{
htab->elf.srelplt->size += htab->sizeof_reloc;
if (bed->target_id == X86_64_ELF_DATA)
- htab->tlsdesc_plt = (bfd_vma) -1;
+ htab->elf.tlsdesc_plt = (bfd_vma) -1;
}
}
}
else if (htab->elf.irelplt)
htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1;
- if (htab->tlsdesc_plt)
+ if (htab->elf.tlsdesc_plt)
{
/* NB: tlsdesc_plt is set only for x86-64. If we're not using
lazy TLS relocations, don't generate the PLT and GOT entries
they require. */
if ((info->flags & DF_BIND_NOW))
- htab->tlsdesc_plt = 0;
+ htab->elf.tlsdesc_plt = 0;
else
{
- htab->tlsdesc_got = htab->elf.sgot->size;
+ htab->elf.tlsdesc_got = htab->elf.sgot->size;
htab->elf.sgot->size += htab->got_entry_size;
/* Reserve room for the initial entry.
FIXME: we could probably do away with it in this case. */
if (htab->elf.splt->size == 0)
htab->elf.splt->size = htab->plt.plt_entry_size;
- htab->tlsdesc_plt = htab->elf.splt->size;
+ htab->elf.tlsdesc_plt = htab->elf.splt->size;
htab->elf.splt->size += htab->plt.plt_entry_size;
}
}
return FALSE;
}
- if (htab->tlsdesc_plt
+ if (htab->elf.tlsdesc_plt
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
|| !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
return FALSE;
case DT_TLSDESC_PLT:
s = htab->elf.splt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
- + htab->tlsdesc_plt;
+ + htab->elf.tlsdesc_plt;
break;
case DT_TLSDESC_GOT:
s = htab->elf.sgot;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
- + htab->tlsdesc_got;
+ + htab->elf.tlsdesc_got;
break;
}
htab_t loc_hash_table;
void * loc_hash_memory;
- /* The offset into sgot of the GOT entry used by the PLT entry
- above. */
- bfd_vma tlsdesc_got;
-
/* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */
bfd_vma next_jump_slot_index;
/* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */
is only used for i386. */
bfd_vma next_tls_desc_index;
- /* The offset into splt of the PLT entry for the TLS descriptor
- resolver. Special values are 0, if not necessary (or not found
- to be necessary yet), and -1 if needed but not determined
- yet. This is only used for x86-64. */
- bfd_vma tlsdesc_plt;
-
/* Value used to fill the unused bytes of the first PLT entry. This
is only used for i386. */
bfd_byte plt0_pad_byte;