GNU Binutils with patches for OS216
Revisión | 9bcc30e4178baac8307a52841ea9fef5cda8846d (tree) |
---|---|
Tiempo | 2020-06-08 20:30:56 |
Autor | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
ELF: Move tlsdesc_plt/tlsdesc_got to elf_link_hash_table
All ELF backends with TLS descriptor support have
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.
@@ -1,3 +1,32 @@ | ||
1 | +2020-06-08 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + * elf-bfd.h (elf_link_hash_entry): Add tlsdesc_plt and | |
4 | + tlsdesc_got. | |
5 | + * elf32-arm.c (elf32_arm_link_hash_table): Remove tlsdesc_plt | |
6 | + and dt_tlsdesc_got. | |
7 | + (elf32_arm_size_dynamic_sections): Updated. Clear | |
8 | + root.tlsdesc_plt for DF_BIND_NOW. | |
9 | + (elf32_arm_finish_dynamic_sections): Updated. | |
10 | + (elf32_arm_output_arch_local_syms): Likewise. | |
11 | + * elf32-nds32.c (nds32_elf_size_dynamic_sections): Updated. | |
12 | + Clear root.tlsdesc_plt for DF_BIND_NOW. | |
13 | + (nds32_elf_finish_dynamic_sections): Updated. | |
14 | + * elf32-nds32.h (elf_nds32_link_hash_table): Remove | |
15 | + dt_tlsdesc_plt and dt_tlsdesc_got. | |
16 | + * elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Updated. | |
17 | + * elfnn-aarch64.c (elf_aarch64_link_hash_table): Remove | |
18 | + tlsdesc_plt and dt_tlsdesc_got. | |
19 | + (elfNN_aarch64_allocate_dynrelocs): Updated. | |
20 | + (elfNN_aarch64_finish_dynamic_sections): Likewise. | |
21 | + (elfNN_aarch64_size_dynamic_sections): Updated. Clear | |
22 | + root.tlsdesc_plt for DF_BIND_NOW. Don't check DF_BIND_NOW | |
23 | + twice. | |
24 | + * elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated. | |
25 | + (_bfd_x86_elf_size_dynamic_sections): Likewise. | |
26 | + (_bfd_x86_elf_finish_dynamic_sections): Likewise. | |
27 | + * elfxx-x86.h (elf_x86_link_hash_table): Remove tlsdesc_plt and | |
28 | + tlsdesc_got. | |
29 | + | |
1 | 30 | 2020-06-07 H.J. Lu <hongjiu.lu@intel.com> |
2 | 31 | |
3 | 32 | * elf32-tic6x.c (elf32_bed): Defined the default to |
@@ -650,6 +650,17 @@ struct elf_link_hash_table | ||
650 | 650 | asection *tls_sec; |
651 | 651 | bfd_size_type tls_size; /* Bytes. */ |
652 | 652 | |
653 | + /* The offset into splt of the PLT entry for the TLS descriptor | |
654 | + resolver. Special values are 0, if not necessary (or not found | |
655 | + to be necessary yet), and -1 if needed but not determined | |
656 | + yet. */ | |
657 | + bfd_vma tlsdesc_plt; | |
658 | + | |
659 | + /* The GOT offset for the lazy trampoline. Communicated to the | |
660 | + loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1 | |
661 | + indicates an offset is not allocated. */ | |
662 | + bfd_vma tlsdesc_got; | |
663 | + | |
653 | 664 | /* Target OS for linker output. */ |
654 | 665 | enum elf_target_os target_os; |
655 | 666 |
@@ -3380,16 +3380,6 @@ struct elf32_arm_link_hash_table | ||
3380 | 3380 | /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */ |
3381 | 3381 | asection *srelplt2; |
3382 | 3382 | |
3383 | - /* The offset into splt of the PLT entry for the TLS descriptor | |
3384 | - resolver. Special values are 0, if not necessary (or not found | |
3385 | - to be necessary yet), and -1 if needed but not determined | |
3386 | - yet. */ | |
3387 | - bfd_vma dt_tlsdesc_plt; | |
3388 | - | |
3389 | - /* The offset into sgot of the GOT entry used by the PLT entry | |
3390 | - above. */ | |
3391 | - bfd_vma dt_tlsdesc_got; | |
3392 | - | |
3393 | 3383 | /* Offset in .plt section of tls_arm_trampoline. */ |
3394 | 3384 | bfd_vma tls_trampoline; |
3395 | 3385 |
@@ -16971,12 +16961,14 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, | ||
16971 | 16961 | |
16972 | 16962 | /* If we're not using lazy TLS relocations, don't generate the |
16973 | 16963 | PLT and GOT entries they require. */ |
16974 | - if (!(info->flags & DF_BIND_NOW)) | |
16964 | + if ((info->flags & DF_BIND_NOW)) | |
16965 | + htab->root.tlsdesc_plt = 0; | |
16966 | + else | |
16975 | 16967 | { |
16976 | - htab->dt_tlsdesc_got = htab->root.sgot->size; | |
16968 | + htab->root.tlsdesc_got = htab->root.sgot->size; | |
16977 | 16969 | htab->root.sgot->size += 4; |
16978 | 16970 | |
16979 | - htab->dt_tlsdesc_plt = htab->root.splt->size; | |
16971 | + htab->root.tlsdesc_plt = htab->root.splt->size; | |
16980 | 16972 | htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline); |
16981 | 16973 | } |
16982 | 16974 | } |
@@ -17077,7 +17069,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, | ||
17077 | 17069 | || !add_dynamic_entry (DT_JMPREL, 0)) |
17078 | 17070 | return FALSE; |
17079 | 17071 | |
17080 | - if (htab->dt_tlsdesc_plt | |
17072 | + if (htab->root.tlsdesc_plt | |
17081 | 17073 | && (!add_dynamic_entry (DT_TLSDESC_PLT,0) |
17082 | 17074 | || !add_dynamic_entry (DT_TLSDESC_GOT,0))) |
17083 | 17075 | return FALSE; |
@@ -17462,14 +17454,14 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info | ||
17462 | 17454 | case DT_TLSDESC_PLT: |
17463 | 17455 | s = htab->root.splt; |
17464 | 17456 | dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset |
17465 | - + htab->dt_tlsdesc_plt); | |
17457 | + + htab->root.tlsdesc_plt); | |
17466 | 17458 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
17467 | 17459 | break; |
17468 | 17460 | |
17469 | 17461 | case DT_TLSDESC_GOT: |
17470 | 17462 | s = htab->root.sgot; |
17471 | 17463 | dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset |
17472 | - + htab->dt_tlsdesc_got); | |
17464 | + + htab->root.tlsdesc_got); | |
17473 | 17465 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
17474 | 17466 | break; |
17475 | 17467 |
@@ -17580,7 +17572,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info | ||
17580 | 17572 | if (splt->output_section->owner == output_bfd) |
17581 | 17573 | elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; |
17582 | 17574 | |
17583 | - if (htab->dt_tlsdesc_plt) | |
17575 | + if (htab->root.tlsdesc_plt) | |
17584 | 17576 | { |
17585 | 17577 | bfd_vma got_address |
17586 | 17578 | = sgot->output_section->vma + sgot->output_offset; |
@@ -17590,18 +17582,18 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info | ||
17590 | 17582 | = splt->output_section->vma + splt->output_offset; |
17591 | 17583 | |
17592 | 17584 | arm_put_trampoline (htab, output_bfd, |
17593 | - splt->contents + htab->dt_tlsdesc_plt, | |
17585 | + splt->contents + htab->root.tlsdesc_plt, | |
17594 | 17586 | dl_tlsdesc_lazy_trampoline, 6); |
17595 | 17587 | |
17596 | 17588 | bfd_put_32 (output_bfd, |
17597 | - gotplt_address + htab->dt_tlsdesc_got | |
17598 | - - (plt_address + htab->dt_tlsdesc_plt) | |
17589 | + gotplt_address + htab->root.tlsdesc_got | |
17590 | + - (plt_address + htab->root.tlsdesc_plt) | |
17599 | 17591 | - dl_tlsdesc_lazy_trampoline[6], |
17600 | - splt->contents + htab->dt_tlsdesc_plt + 24); | |
17592 | + splt->contents + htab->root.tlsdesc_plt + 24); | |
17601 | 17593 | bfd_put_32 (output_bfd, |
17602 | - got_address - (plt_address + htab->dt_tlsdesc_plt) | |
17594 | + got_address - (plt_address + htab->root.tlsdesc_plt) | |
17603 | 17595 | - dl_tlsdesc_lazy_trampoline[7], |
17604 | - splt->contents + htab->dt_tlsdesc_plt + 24 + 4); | |
17596 | + splt->contents + htab->root.tlsdesc_plt + 24 + 4); | |
17605 | 17597 | } |
17606 | 17598 | |
17607 | 17599 | if (htab->tls_trampoline) |
@@ -18374,14 +18366,15 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, | ||
18374 | 18366 | } |
18375 | 18367 | } |
18376 | 18368 | } |
18377 | - if (htab->dt_tlsdesc_plt != 0) | |
18369 | + if (htab->root.tlsdesc_plt != 0) | |
18378 | 18370 | { |
18379 | 18371 | /* Mapping symbols for the lazy tls trampoline. */ |
18380 | - if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, htab->dt_tlsdesc_plt)) | |
18372 | + if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, | |
18373 | + htab->root.tlsdesc_plt)) | |
18381 | 18374 | return FALSE; |
18382 | 18375 | |
18383 | 18376 | if (!elf32_arm_output_map_sym (&osi, ARM_MAP_DATA, |
18384 | - htab->dt_tlsdesc_plt + 24)) | |
18377 | + htab->root.tlsdesc_plt + 24)) | |
18385 | 18378 | return FALSE; |
18386 | 18379 | } |
18387 | 18380 | if (htab->tls_trampoline != 0) |
@@ -4405,12 +4405,14 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
4405 | 4405 | |
4406 | 4406 | /* If we're not using lazy TLS relocations, don't generate the |
4407 | 4407 | PLT and GOT entries they require. */ |
4408 | - if (!(info->flags & DF_BIND_NOW)) | |
4408 | + if ((info->flags & DF_BIND_NOW)) | |
4409 | + htab->root.tlsdesc_plt = 0; | |
4410 | + else | |
4409 | 4411 | { |
4410 | - htab->dt_tlsdesc_got = htab->root.sgot->size; | |
4412 | + htab->root.tlsdesc_got = htab->root.sgot->size; | |
4411 | 4413 | htab->root.sgot->size += 4; |
4412 | 4414 | |
4413 | - htab->dt_tlsdesc_plt = htab->root.splt->size; | |
4415 | + htab->root.tlsdesc_plt = htab->root.splt->size; | |
4414 | 4416 | htab->root.splt->size += 4 * ARRAY_SIZE (dl_tlsdesc_lazy_trampoline); |
4415 | 4417 | } |
4416 | 4418 | } |
@@ -4509,7 +4511,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
4509 | 4511 | |
4510 | 4512 | if (htab->tls_desc_trampoline && plt) |
4511 | 4513 | { |
4512 | - if (htab->dt_tlsdesc_plt | |
4514 | + if (htab->root.tlsdesc_plt | |
4513 | 4515 | && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) |
4514 | 4516 | || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) |
4515 | 4517 | return FALSE; |
@@ -6435,14 +6437,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) | ||
6435 | 6437 | case DT_TLSDESC_PLT: |
6436 | 6438 | s = htab->root.splt; |
6437 | 6439 | dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset |
6438 | - + htab->dt_tlsdesc_plt); | |
6440 | + + htab->root.tlsdesc_plt); | |
6439 | 6441 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
6440 | 6442 | break; |
6441 | 6443 | |
6442 | 6444 | case DT_TLSDESC_GOT: |
6443 | 6445 | s = htab->root.sgot; |
6444 | 6446 | dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset |
6445 | - + htab->dt_tlsdesc_got); | |
6447 | + + htab->root.tlsdesc_got); | |
6446 | 6448 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
6447 | 6449 | break; |
6448 | 6450 | } |
@@ -6505,14 +6507,14 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) | ||
6505 | 6507 | PLT_ENTRY_SIZE; |
6506 | 6508 | } |
6507 | 6509 | |
6508 | - if (htab->dt_tlsdesc_plt) | |
6510 | + if (htab->root.tlsdesc_plt) | |
6509 | 6511 | { |
6510 | 6512 | /* Calculate addresses. */ |
6511 | 6513 | asection *sgot = sgot = ehtab->sgot; |
6512 | 6514 | bfd_vma pltgot = sgotplt->output_section->vma |
6513 | 6515 | + sgotplt->output_offset; |
6514 | 6516 | bfd_vma tlsdesc_got = sgot->output_section->vma + sgot->output_offset |
6515 | - + htab->dt_tlsdesc_got; | |
6517 | + + htab->root.tlsdesc_got; | |
6516 | 6518 | |
6517 | 6519 | /* Get GP offset. */ |
6518 | 6520 | 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) | ||
6525 | 6527 | dl_tlsdesc_lazy_trampoline[5] += 0xfff & pltgot; |
6526 | 6528 | |
6527 | 6529 | /* Insert .plt. */ |
6528 | - nds32_put_trampoline (splt->contents + htab->dt_tlsdesc_plt, | |
6530 | + nds32_put_trampoline (splt->contents + htab->root.tlsdesc_plt, | |
6529 | 6531 | dl_tlsdesc_lazy_trampoline, |
6530 | 6532 | ARRAY_SIZE (dl_tlsdesc_lazy_trampoline)); |
6531 | 6533 | } |
@@ -138,16 +138,6 @@ struct elf_nds32_link_hash_table | ||
138 | 138 | /* Disable if linking a dynamically linked executable. */ |
139 | 139 | int load_store_relax; |
140 | 140 | |
141 | - /* The offset into splt of the PLT entry for the TLS descriptor | |
142 | - resolver. Special values are 0, if not necessary (or not found | |
143 | - to be necessary yet), and -1 if needed but not determined | |
144 | - yet. */ | |
145 | - bfd_vma dt_tlsdesc_plt; | |
146 | - | |
147 | - /* The offset into sgot of the GOT entry used by the PLT entry | |
148 | - above. */ | |
149 | - bfd_vma dt_tlsdesc_got; | |
150 | - | |
151 | 141 | /* Offset in .plt section of tls_nds32_trampoline. */ |
152 | 142 | bfd_vma tls_trampoline; |
153 | 143 |
@@ -4667,12 +4667,12 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd, | ||
4667 | 4667 | + htab->lazy_plt->plt0_got2_offset)); |
4668 | 4668 | } |
4669 | 4669 | |
4670 | - if (htab->tlsdesc_plt) | |
4670 | + if (htab->elf.tlsdesc_plt) | |
4671 | 4671 | { |
4672 | 4672 | bfd_put_64 (output_bfd, (bfd_vma) 0, |
4673 | - htab->elf.sgot->contents + htab->tlsdesc_got); | |
4673 | + htab->elf.sgot->contents + htab->elf.tlsdesc_got); | |
4674 | 4674 | |
4675 | - memcpy (htab->elf.splt->contents + htab->tlsdesc_plt, | |
4675 | + memcpy (htab->elf.splt->contents + htab->elf.tlsdesc_plt, | |
4676 | 4676 | htab->lazy_plt->plt_tlsdesc_entry, |
4677 | 4677 | htab->lazy_plt->plt_tlsdesc_entry_size); |
4678 | 4678 |
@@ -4685,10 +4685,10 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd, | ||
4685 | 4685 | + 8 |
4686 | 4686 | - htab->elf.splt->output_section->vma |
4687 | 4687 | - htab->elf.splt->output_offset |
4688 | - - htab->tlsdesc_plt | |
4688 | + - htab->elf.tlsdesc_plt | |
4689 | 4689 | - htab->lazy_plt->plt_tlsdesc_got1_insn_end), |
4690 | 4690 | (htab->elf.splt->contents |
4691 | - + htab->tlsdesc_plt | |
4691 | + + htab->elf.tlsdesc_plt | |
4692 | 4692 | + htab->lazy_plt->plt_tlsdesc_got1_offset)); |
4693 | 4693 | /* Add offset for indirect branch via GOT+TDG, where TDG |
4694 | 4694 | stands for htab->tlsdesc_got, subtracting the offset |
@@ -4696,13 +4696,13 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd, | ||
4696 | 4696 | bfd_put_32 (output_bfd, |
4697 | 4697 | (htab->elf.sgot->output_section->vma |
4698 | 4698 | + htab->elf.sgot->output_offset |
4699 | - + htab->tlsdesc_got | |
4699 | + + htab->elf.tlsdesc_got | |
4700 | 4700 | - htab->elf.splt->output_section->vma |
4701 | 4701 | - htab->elf.splt->output_offset |
4702 | - - htab->tlsdesc_plt | |
4702 | + - htab->elf.tlsdesc_plt | |
4703 | 4703 | - htab->lazy_plt->plt_tlsdesc_got2_insn_end), |
4704 | 4704 | (htab->elf.splt->contents |
4705 | - + htab->tlsdesc_plt | |
4705 | + + htab->elf.tlsdesc_plt | |
4706 | 4706 | + htab->lazy_plt->plt_tlsdesc_got2_offset)); |
4707 | 4707 | } |
4708 | 4708 | } |
@@ -2682,20 +2682,9 @@ struct elf_aarch64_link_hash_table | ||
2682 | 2682 | /* JUMP_SLOT relocs for variant PCS symbols may be present. */ |
2683 | 2683 | int variant_pcs; |
2684 | 2684 | |
2685 | - /* The offset into splt of the PLT entry for the TLS descriptor | |
2686 | - resolver. Special values are 0, if not necessary (or not found | |
2687 | - to be necessary yet), and -1 if needed but not determined | |
2688 | - yet. */ | |
2689 | - bfd_vma tlsdesc_plt; | |
2690 | - | |
2691 | 2685 | /* The number of bytes in the PLT enty for the TLS descriptor. */ |
2692 | 2686 | bfd_size_type tlsdesc_plt_entry_size; |
2693 | 2687 | |
2694 | - /* The GOT offset for the lazy trampoline. Communicated to the | |
2695 | - loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1 | |
2696 | - indicates an offset is not allocated. */ | |
2697 | - bfd_vma dt_tlsdesc_got; | |
2698 | - | |
2699 | 2688 | /* Used by local STT_GNU_IFUNC symbols. */ |
2700 | 2689 | htab_t loc_hash_table; |
2701 | 2690 | void * loc_hash_memory; |
@@ -2932,7 +2921,7 @@ elfNN_aarch64_link_hash_table_create (bfd *abfd) | ||
2932 | 2921 | ret->plt_entry = elfNN_aarch64_small_plt_entry; |
2933 | 2922 | ret->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE; |
2934 | 2923 | ret->obfd = abfd; |
2935 | - ret->dt_tlsdesc_got = (bfd_vma) - 1; | |
2924 | + ret->root.tlsdesc_got = (bfd_vma) - 1; | |
2936 | 2925 | |
2937 | 2926 | if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc, |
2938 | 2927 | sizeof (struct elf_aarch64_stub_hash_entry))) |
@@ -8682,7 +8671,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) | ||
8682 | 8671 | type. */ |
8683 | 8672 | |
8684 | 8673 | /* TLSDESC PLT is now needed, but not yet determined. */ |
8685 | - htab->tlsdesc_plt = (bfd_vma) - 1; | |
8674 | + htab->root.tlsdesc_plt = (bfd_vma) - 1; | |
8686 | 8675 | } |
8687 | 8676 | |
8688 | 8677 | if (got_type & GOT_TLS_GD) |
@@ -8968,7 +8957,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
8968 | 8957 | { |
8969 | 8958 | htab->root.srelplt->size += RELOC_SIZE (htab); |
8970 | 8959 | /* Note RELOC_COUNT not incremented here! */ |
8971 | - htab->tlsdesc_plt = (bfd_vma) - 1; | |
8960 | + htab->root.tlsdesc_plt = (bfd_vma) - 1; | |
8972 | 8961 | } |
8973 | 8962 | |
8974 | 8963 | if (got_type & GOT_TLS_GD) |
@@ -9011,19 +9000,21 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
9011 | 9000 | if (htab->root.srelplt) |
9012 | 9001 | htab->sgotplt_jump_table_size = aarch64_compute_jump_table_size (htab); |
9013 | 9002 | |
9014 | - if (htab->tlsdesc_plt) | |
9003 | + if (htab->root.tlsdesc_plt) | |
9015 | 9004 | { |
9016 | 9005 | if (htab->root.splt->size == 0) |
9017 | 9006 | htab->root.splt->size += htab->plt_header_size; |
9018 | 9007 | |
9019 | 9008 | /* If we're not using lazy TLS relocations, don't generate the |
9020 | 9009 | GOT and PLT entry required. */ |
9021 | - if (!(info->flags & DF_BIND_NOW)) | |
9010 | + if ((info->flags & DF_BIND_NOW)) | |
9011 | + htab->root.tlsdesc_plt = 0; | |
9012 | + else | |
9022 | 9013 | { |
9023 | - htab->tlsdesc_plt = htab->root.splt->size; | |
9014 | + htab->root.tlsdesc_plt = htab->root.splt->size; | |
9024 | 9015 | htab->root.splt->size += htab->tlsdesc_plt_entry_size; |
9025 | 9016 | |
9026 | - htab->dt_tlsdesc_got = htab->root.sgot->size; | |
9017 | + htab->root.tlsdesc_got = htab->root.sgot->size; | |
9027 | 9018 | htab->root.sgot->size += GOT_ENTRY_SIZE; |
9028 | 9019 | } |
9029 | 9020 | } |
@@ -9129,8 +9120,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
9129 | 9120 | && !add_dynamic_entry (DT_AARCH64_VARIANT_PCS, 0)) |
9130 | 9121 | return FALSE; |
9131 | 9122 | |
9132 | - if (htab->tlsdesc_plt | |
9133 | - && !(info->flags & DF_BIND_NOW) | |
9123 | + if (htab->root.tlsdesc_plt | |
9134 | 9124 | && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) |
9135 | 9125 | || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) |
9136 | 9126 | return FALSE; |
@@ -9639,14 +9629,14 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, | ||
9639 | 9629 | case DT_TLSDESC_PLT: |
9640 | 9630 | s = htab->root.splt; |
9641 | 9631 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset |
9642 | - + htab->tlsdesc_plt; | |
9632 | + + htab->root.tlsdesc_plt; | |
9643 | 9633 | break; |
9644 | 9634 | |
9645 | 9635 | case DT_TLSDESC_GOT: |
9646 | 9636 | s = htab->root.sgot; |
9647 | - BFD_ASSERT (htab->dt_tlsdesc_got != (bfd_vma)-1); | |
9637 | + BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1); | |
9648 | 9638 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset |
9649 | - + htab->dt_tlsdesc_got; | |
9639 | + + htab->root.tlsdesc_got; | |
9650 | 9640 | break; |
9651 | 9641 | } |
9652 | 9642 |
@@ -9664,11 +9654,11 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, | ||
9664 | 9654 | this_hdr.sh_entsize = htab->plt_entry_size; |
9665 | 9655 | |
9666 | 9656 | |
9667 | - if (htab->tlsdesc_plt && !(info->flags & DF_BIND_NOW)) | |
9657 | + if (htab->root.tlsdesc_plt && !(info->flags & DF_BIND_NOW)) | |
9668 | 9658 | { |
9669 | - BFD_ASSERT (htab->dt_tlsdesc_got != (bfd_vma)-1); | |
9659 | + BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1); | |
9670 | 9660 | bfd_put_NN (output_bfd, (bfd_vma) 0, |
9671 | - htab->root.sgot->contents + htab->dt_tlsdesc_got); | |
9661 | + htab->root.sgot->contents + htab->root.tlsdesc_got); | |
9672 | 9662 | |
9673 | 9663 | const bfd_byte *entry = elfNN_aarch64_tlsdesc_small_plt_entry; |
9674 | 9664 | htab->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE; |
@@ -9679,13 +9669,14 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, | ||
9679 | 9669 | entry = elfNN_aarch64_tlsdesc_small_plt_bti_entry; |
9680 | 9670 | } |
9681 | 9671 | |
9682 | - memcpy (htab->root.splt->contents + htab->tlsdesc_plt, | |
9672 | + memcpy (htab->root.splt->contents + htab->root.tlsdesc_plt, | |
9683 | 9673 | entry, htab->tlsdesc_plt_entry_size); |
9684 | 9674 | |
9685 | 9675 | { |
9686 | 9676 | bfd_vma adrp1_addr = |
9687 | 9677 | htab->root.splt->output_section->vma |
9688 | - + htab->root.splt->output_offset + htab->tlsdesc_plt + 4; | |
9678 | + + htab->root.splt->output_offset | |
9679 | + + htab->root.tlsdesc_plt + 4; | |
9689 | 9680 | |
9690 | 9681 | bfd_vma adrp2_addr = adrp1_addr + 4; |
9691 | 9682 |
@@ -9697,10 +9688,10 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, | ||
9697 | 9688 | htab->root.sgotplt->output_section->vma |
9698 | 9689 | + htab->root.sgotplt->output_offset; |
9699 | 9690 | |
9700 | - bfd_vma dt_tlsdesc_got = got_addr + htab->dt_tlsdesc_got; | |
9691 | + bfd_vma dt_tlsdesc_got = got_addr + htab->root.tlsdesc_got; | |
9701 | 9692 | |
9702 | 9693 | bfd_byte *plt_entry = |
9703 | - htab->root.splt->contents + htab->tlsdesc_plt; | |
9694 | + htab->root.splt->contents + htab->root.tlsdesc_plt; | |
9704 | 9695 | |
9705 | 9696 | /* First instruction in BTI enabled PLT stub is a BTI |
9706 | 9697 | instruction so skip it. */ |
@@ -369,7 +369,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) | ||
369 | 369 | { |
370 | 370 | htab->elf.srelplt->size += htab->sizeof_reloc; |
371 | 371 | if (bed->target_id == X86_64_ELF_DATA) |
372 | - htab->tlsdesc_plt = (bfd_vma) -1; | |
372 | + htab->elf.tlsdesc_plt = (bfd_vma) -1; | |
373 | 373 | } |
374 | 374 | } |
375 | 375 | else |
@@ -1116,7 +1116,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, | ||
1116 | 1116 | { |
1117 | 1117 | htab->elf.srelplt->size += htab->sizeof_reloc; |
1118 | 1118 | if (bed->target_id == X86_64_ELF_DATA) |
1119 | - htab->tlsdesc_plt = (bfd_vma) -1; | |
1119 | + htab->elf.tlsdesc_plt = (bfd_vma) -1; | |
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | } |
@@ -1163,22 +1163,22 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, | ||
1163 | 1163 | else if (htab->elf.irelplt) |
1164 | 1164 | htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1; |
1165 | 1165 | |
1166 | - if (htab->tlsdesc_plt) | |
1166 | + if (htab->elf.tlsdesc_plt) | |
1167 | 1167 | { |
1168 | 1168 | /* NB: tlsdesc_plt is set only for x86-64. If we're not using |
1169 | 1169 | lazy TLS relocations, don't generate the PLT and GOT entries |
1170 | 1170 | they require. */ |
1171 | 1171 | if ((info->flags & DF_BIND_NOW)) |
1172 | - htab->tlsdesc_plt = 0; | |
1172 | + htab->elf.tlsdesc_plt = 0; | |
1173 | 1173 | else |
1174 | 1174 | { |
1175 | - htab->tlsdesc_got = htab->elf.sgot->size; | |
1175 | + htab->elf.tlsdesc_got = htab->elf.sgot->size; | |
1176 | 1176 | htab->elf.sgot->size += htab->got_entry_size; |
1177 | 1177 | /* Reserve room for the initial entry. |
1178 | 1178 | FIXME: we could probably do away with it in this case. */ |
1179 | 1179 | if (htab->elf.splt->size == 0) |
1180 | 1180 | htab->elf.splt->size = htab->plt.plt_entry_size; |
1181 | - htab->tlsdesc_plt = htab->elf.splt->size; | |
1181 | + htab->elf.tlsdesc_plt = htab->elf.splt->size; | |
1182 | 1182 | htab->elf.splt->size += htab->plt.plt_entry_size; |
1183 | 1183 | } |
1184 | 1184 | } |
@@ -1395,7 +1395,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, | ||
1395 | 1395 | return FALSE; |
1396 | 1396 | } |
1397 | 1397 | |
1398 | - if (htab->tlsdesc_plt | |
1398 | + if (htab->elf.tlsdesc_plt | |
1399 | 1399 | && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) |
1400 | 1400 | || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) |
1401 | 1401 | return FALSE; |
@@ -1544,13 +1544,13 @@ _bfd_x86_elf_finish_dynamic_sections (bfd *output_bfd, | ||
1544 | 1544 | case DT_TLSDESC_PLT: |
1545 | 1545 | s = htab->elf.splt; |
1546 | 1546 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset |
1547 | - + htab->tlsdesc_plt; | |
1547 | + + htab->elf.tlsdesc_plt; | |
1548 | 1548 | break; |
1549 | 1549 | |
1550 | 1550 | case DT_TLSDESC_GOT: |
1551 | 1551 | s = htab->elf.sgot; |
1552 | 1552 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset |
1553 | - + htab->tlsdesc_got; | |
1553 | + + htab->elf.tlsdesc_got; | |
1554 | 1554 | break; |
1555 | 1555 | } |
1556 | 1556 |
@@ -478,10 +478,6 @@ struct elf_x86_link_hash_table | ||
478 | 478 | htab_t loc_hash_table; |
479 | 479 | void * loc_hash_memory; |
480 | 480 | |
481 | - /* The offset into sgot of the GOT entry used by the PLT entry | |
482 | - above. */ | |
483 | - bfd_vma tlsdesc_got; | |
484 | - | |
485 | 481 | /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */ |
486 | 482 | bfd_vma next_jump_slot_index; |
487 | 483 | /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */ |
@@ -499,12 +495,6 @@ struct elf_x86_link_hash_table | ||
499 | 495 | is only used for i386. */ |
500 | 496 | bfd_vma next_tls_desc_index; |
501 | 497 | |
502 | - /* The offset into splt of the PLT entry for the TLS descriptor | |
503 | - resolver. Special values are 0, if not necessary (or not found | |
504 | - to be necessary yet), and -1 if needed but not determined | |
505 | - yet. This is only used for x86-64. */ | |
506 | - bfd_vma tlsdesc_plt; | |
507 | - | |
508 | 498 | /* Value used to fill the unused bytes of the first PLT entry. This |
509 | 499 | is only used for i386. */ |
510 | 500 | bfd_byte plt0_pad_byte; |