diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-08 04:24:04 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-08 04:30:56 -0700 |
commit | 9bcc30e4178baac8307a52841ea9fef5cda8846d (patch) | |
tree | b55be2375cd10a5b9a55f5000458b730b8a3bed6 /bfd/elfnn-aarch64.c | |
parent | b37a7714400cdc264ed236f72668b8956477b2ed (diff) | |
download | binutils-9bcc30e4178baac8307a52841ea9fef5cda8846d.zip binutils-9bcc30e4178baac8307a52841ea9fef5cda8846d.tar.gz binutils-9bcc30e4178baac8307a52841ea9fef5cda8846d.tar.bz2 |
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.
Diffstat (limited to 'bfd/elfnn-aarch64.c')
-rw-r--r-- | bfd/elfnn-aarch64.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 64215f7..6857c4c 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -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. */ |