diff options
author | Alan Modra <amodra@gmail.com> | 2021-01-19 19:26:11 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-01-19 21:18:51 +1030 |
commit | 30845f113a3b01640c46f9b07549b080cb83bc81 (patch) | |
tree | 5d2750c6be95c1f4250e93e44ef87c86e81d571c /bfd/elf32-ppc.c | |
parent | a75a6a416477915b7d236537c9170ced3064df11 (diff) | |
download | gdb-30845f113a3b01640c46f9b07549b080cb83bc81.zip gdb-30845f113a3b01640c46f9b07549b080cb83bc81.tar.gz gdb-30845f113a3b01640c46f9b07549b080cb83bc81.tar.bz2 |
PowerPC use_local_plt
Put the logic to select local vs. usual .plt section in one place.
* elf64-ppc.c (elf_hash_entry): New inline function. Use
throughout to replace casts.
(branch_reloc_hash_match): Remove const from params.
(use_local_plt): New function.
(allocate_dynrelocs, ppc_build_one_stub, ppc_size_one_stub),
(build_global_entry_stubs_and_plt, ppc64_elf_relocate_section):
Use use_local_plt.
* elf32-ppc.c (use_local_plt): New function.
(allocate_dynrelocs, ppc_elf_relocate_section),
(write_global_sym_plt): Use use_local_plt.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r-- | bfd/elf32-ppc.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index fd88f3d..a8da304 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -5094,6 +5094,18 @@ ensure_undef_dynamic (struct bfd_link_info *info, return TRUE; } +/* Choose whether to use htab->iplt or htab->pltlocal rather than the + usual htab->elf.splt section for a PLT entry. */ + +static inline +bfd_boolean use_local_plt (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + return (h == NULL + || h->dynindx == -1 + || !elf_hash_table (info)->dynamic_sections_created); +} + /* Allocate space in associated reloc sections for dynamic relocs. */ static bfd_boolean @@ -5103,7 +5115,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) struct ppc_elf_link_hash_entry *eh; struct ppc_elf_link_hash_table *htab; struct elf_dyn_relocs *p; - bfd_boolean dyn; if (h->root.type == bfd_link_hash_indirect) return TRUE; @@ -5271,8 +5282,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) b) is an ifunc, or c) has plt16 relocs and has been processed by adjust_dynamic_symbol, or d) has plt16 relocs and we are linking statically. */ - dyn = htab->elf.dynamic_sections_created && h->dynindx != -1; - if (dyn + if ((htab->elf.dynamic_sections_created && h->dynindx != -1) || h->type == STT_GNU_IFUNC || (h->needs_plt && h->dynamic_adjusted) || (h->needs_plt @@ -5290,6 +5300,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (ent->plt.refcount > 0) { asection *s = htab->elf.splt; + bfd_boolean dyn = !use_local_plt (info, h); if (!dyn) { @@ -8373,9 +8384,7 @@ ppc_elf_relocate_section (bfd *output_bfd, unresolved_reloc = FALSE; plt = htab->elf.splt; - if (!htab->elf.dynamic_sections_created - || h == NULL - || h->dynindx == -1) + if (use_local_plt (info, h)) { if (ifunc != NULL) plt = htab->elf.iplt; @@ -9351,6 +9360,8 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) for (ent = h->plt.plist; ent != NULL; ent = ent->next) if (ent->plt.offset != (bfd_vma) -1) { + bfd_boolean dyn = !use_local_plt (info, h); + if (!doneone) { Elf_Internal_Rela rela; @@ -9359,9 +9370,7 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) asection *plt = htab->elf.splt; asection *relplt = htab->elf.srelplt; - if (htab->plt_type == PLT_NEW - || !htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (htab->plt_type == PLT_NEW || !dyn) reloc_index = ent->plt.offset / 4; else { @@ -9374,9 +9383,7 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) /* This symbol has an entry in the procedure linkage table. Set it up. */ - if (htab->plt_type == PLT_VXWORKS - && htab->elf.dynamic_sections_created - && h->dynindx != -1) + if (htab->plt_type == PLT_VXWORKS && dyn) { bfd_vma got_offset; const bfd_vma *plt_entry; @@ -9499,8 +9506,7 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) else { rela.r_addend = 0; - if (!htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (!dyn) { if (h->type == STT_GNU_IFUNC) { @@ -9529,9 +9535,7 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) + plt->output_offset + ent->plt.offset); - if (htab->plt_type == PLT_OLD - || !htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (htab->plt_type == PLT_OLD || !dyn) { /* We don't need to fill in the .plt. The ppc dynamic linker will fill it in. */ @@ -9550,8 +9554,7 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) if (relplt != NULL) { /* Fill in the entry in the .rela.plt section. */ - if (!htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (!dyn) { if (h->type == STT_GNU_IFUNC) rela.r_info = ELF32_R_INFO (0, R_PPC_IRELATIVE); @@ -9574,15 +9577,12 @@ write_global_sym_plt (struct elf_link_hash_entry *h, void *inf) doneone = TRUE; } - if (htab->plt_type == PLT_NEW - || !htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (htab->plt_type == PLT_NEW || !dyn) { unsigned char *p; asection *plt = htab->elf.splt; - if (!htab->elf.dynamic_sections_created - || h->dynindx == -1) + if (!dyn) { if (h->type == STT_GNU_IFUNC) plt = htab->elf.iplt; |