ELF: Move tlsdesc_plt/tlsdesc_got to elf_link_hash_table
All ELF backends with TLS descriptor support have /* 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; in symbol hash entry. Move tlsdesc_plt/tlsdesc_got to elf_link_hash_entry to reduce code duplication. * 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.
This commit is contained in:
parent
b37a771440
commit
9bcc30e417
@ -1,3 +1,32 @@
|
||||
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
|
||||
|
@ -650,6 +650,17 @@ struct elf_link_hash_table
|
||||
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;
|
||||
|
||||
|
@ -3380,16 +3380,6 @@ struct elf32_arm_link_hash_table
|
||||
/* 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;
|
||||
|
||||
@ -16971,12 +16961,14 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@ -17077,7 +17069,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
|
||||
|| !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;
|
||||
@ -17462,14 +17454,14 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info
|
||||
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;
|
||||
|
||||
@ -17580,7 +17572,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info
|
||||
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;
|
||||
@ -17590,18 +17582,18 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info
|
||||
= 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)
|
||||
@ -18374,14 +18366,15 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd,
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
@ -4405,12 +4405,14 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@ -4509,7 +4511,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
|
||||
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;
|
||||
@ -6435,14 +6437,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
|
||||
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;
|
||||
}
|
||||
@ -6505,14 +6507,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
|
||||
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] */
|
||||
@ -6525,7 +6527,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
|
||||
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));
|
||||
}
|
||||
|
@ -138,16 +138,6 @@ struct elf_nds32_link_hash_table
|
||||
/* 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;
|
||||
|
||||
|
@ -4667,12 +4667,12 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
||||
+ 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);
|
||||
|
||||
@ -4685,10 +4685,10 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
||||
+ 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
|
||||
@ -4696,13 +4696,13 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -2682,20 +2682,9 @@ struct elf_aarch64_link_hash_table
|
||||
/* 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;
|
||||
@ -2932,7 +2921,7 @@ elfNN_aarch64_link_hash_table_create (bfd *abfd)
|
||||
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)))
|
||||
@ -8682,7 +8671,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||
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)
|
||||
@ -8968,7 +8957,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
{
|
||||
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)
|
||||
@ -9011,19 +9000,21 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -9129,8 +9120,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
&& !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;
|
||||
@ -9639,14 +9629,14 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -9664,11 +9654,11 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
@ -9679,13 +9669,14 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
|
||||
@ -9697,10 +9688,10 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
|
||||
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. */
|
||||
|
@ -369,7 +369,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||
{
|
||||
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
|
||||
@ -1116,7 +1116,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1163,22 +1163,22 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1395,7 +1395,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
@ -1544,13 +1544,13 @@ _bfd_x86_elf_finish_dynamic_sections (bfd *output_bfd,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -478,10 +478,6 @@ struct elf_x86_link_hash_table
|
||||
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. */
|
||||
@ -499,12 +495,6 @@ struct elf_x86_link_hash_table
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user