aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-11-23 15:06:34 +1030
committerAlan Modra <amodra@gmail.com>2016-11-23 15:34:01 +1030
commitce558b89b15a18fd67fdc02a4d410a6d92d2ba63 (patch)
tree719d633d149ea7c456cb9eb1995e7db37265f3d2 /bfd/elf32-ppc.c
parent3ae0486cdce5d2ed4c922c598a3258fcbd9c8f29 (diff)
Delete duplicate target short-cuts to dynamic sections
We'd like to have the elf_link_hash_table srelplt field rather than some private target field used to save short-cuts to a PLT relocation section. This save a little space but mainly is so that the generic ELF code can access the field. Ditto for other dynamic sections. * elf-m10300.c (mn10300_elf_check_relocs): Use elf htab shortcuts to dynamic sections. (mn10300_elf_final_link_relocate): Likewise. (_bfd_mn10300_elf_adjust_dynamic_symbol): Likewise. (_bfd_mn10300_elf_size_dynamic_sections): Likewise. (_bfd_mn10300_elf_finish_dynamic_symbol): Likewise. (_bfd_mn10300_elf_finish_dynamic_sections): Likewise. * elf32-bfin.c (bfin_check_relocs): Likewise. (bfin_relocate_section): Likewise. (bfin_gc_sweep_hook): Likewise. (struct bfinfdpic_elf_link_hash_table): Delete sgot, sgotrel, splt and spltrel. (bfinfdpic_got_section, bfinfdpic_gotrel_section, bfinfdpic_plt_section, bfinfdpic_pltrel_section): Define using elf shortcut sections. (_bfin_create_got_section): Use elf htab shortcuts to dyn sections. Delete dead code. (bfin_finish_dynamic_symbol): Use elf htab shortcuts to dyn sections. (bfin_size_dynamic_sections): Likewise. * elf32-cr16.c (_bfd_cr16_elf_create_got_section): Likewise. (cr16_elf_check_relocs): Likewise. (cr16_elf_final_link_relocate): Likewise. (_bfd_cr16_elf_create_dynamic_sections): Likewise. (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise. (_bfd_cr16_elf_size_dynamic_sections): Likewise. (_bfd_cr16_elf_finish_dynamic_symbol): Likewise. (_bfd_cr16_elf_finish_dynamic_sections): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. (elf_cris_finish_dynamic_symbol): Likewise. (elf_cris_finish_dynamic_sections): Likewise. (cris_elf_gc_sweep_hook): Likewise. (elf_cris_adjust_gotplt_to_got): Likewise. (elf_cris_adjust_dynamic_symbol): Likewise. (cris_elf_check_relocs): Likewise. Delete dead code. (elf_cris_size_dynamic_sections): Use elf htab shortcuts to dynamic sections. (elf_cris_discard_excess_program_dynamics): Likewise. * elf32-frv.c (struct frvfdpic_elf_link_hash_table): Delete sgot, sgotrel, splt and spltrel. (frvfdpic_got_section, frvfdpic_gotrel_section, frvfdpic_plt_section, frvfdpic_pltrel_section): Define using elf shortcut sections. (_frv_create_got_section): Likewise. * elf32-hppa.c (struct elf32_hppa_link_hash_table): Delete sgot, srelgot, splt and srelplt. (hppa_build_one_stub): Use elf htab shortcuts to dynamic sections. (elf32_hppa_create_dynamic_sections): Likewise. (elf32_hppa_check_relocs): Likewise. (allocate_plt_static): Likewise. (allocate_dynrelocs): Likewise. (elf32_hppa_size_dynamic_sections): Likewise. (elf32_hppa_relocate_section): Likewise. (elf32_hppa_finish_dynamic_symbol): Likewise. (elf32_hppa_finish_dynamic_sections): Likewise. * elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise. * elf32-lm32.c (struct elf_lm32_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. (lm32fdpic_got_section, lm32fdpic_gotrel_section): Define using elf shortcut sections. (create_got_section): Delete. Use _bfd_elf_create_got_section instead. (lm32_elf_relocate_section): Use elf htab shortcuts to dyn sections. (lm32_elf_check_relocs): Likewise. (lm32_elf_finish_dynamic_sections): Likewise. (lm32_elf_finish_dynamic_symbol): Likewise. (allocate_dynrelocs): Likewise. (lm32_elf_size_dynamic_sections): Likewise. (lm32_elf_create_dynamic_sections): Likewise. * elf32-m32c.c (m32c_elf_relocate_section): Likewise. (m32c_elf_check_relocs): Likewise. (m32c_elf_finish_dynamic_sections): Likewise. (m32c_elf_always_size_sections): Likewise. * elf32-m32r.c (struct elf_m32r_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. (create_got_section): Delete. Use _bfd_elf_create_got_section instead. (m32r_elf_create_dynamic_sections): Use elf htab shortcuts to dynamic sections. (allocate_dynrelocs): Likewise. (m32r_elf_size_dynamic_sections): Likewise. (m32r_elf_relocate_section): Likewise. (m32r_elf_finish_dynamic_symbol): Likewise. (m32r_elf_finish_dynamic_sections): Likewise. (m32r_elf_check_relocs): Likewise. * elf32-m68k.c (elf_m68k_partition_multi_got): Likewise. (elf_m68k_check_relocs): Likewise. (elf_m68k_adjust_dynamic_symbol): Likewise. (elf_m68k_size_dynamic_sections): Likewise. (elf_m68k_relocate_section): Likewise. (elf_m68k_finish_dynamic_symbol): Likewise. (elf_m68k_finish_dynamic_sections): Likewise. * elf32-metag.c (struct elf_metag_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. (elf_metag_relocate_section): Use elf htab shortcuts to dynamic sections. (elf_metag_create_dynamic_sections): Likewise. Allocate got header here in .got. (elf_metag_check_relocs): Use elf htab shortcuts to dynamic sections. (allocate_dynrelocs): Likewise. (elf_metag_size_dynamic_sections): Likewise. (elf_metag_finish_dynamic_symbol): Likewise. (elf_metag_finish_dynamic_sections): Likewise. (elf_metag_size_stubs): Likewise. (elf_backend_got_header_size): Don't define. (elf_backend_want_got_plt): Define. * elf32-microblaze.c (struct elf32_mb_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelpl. (microblaze_elf_relocate_section): Use elf htab shortcuts to dynamic sections. (create_got_section): Delete. Use _bfd_elf_create_got_section instead. (microblaze_elf_check_relocs): Use elf htab shortcuts to dyn sections. (microblaze_elf_create_dynamic_sections): Likewise. (allocate_dynrelocs): Likewise. (microblaze_elf_size_dynamic_sections): Likewise. (microblaze_elf_finish_dynamic_symbol): Likewise. (microblaze_elf_finish_dynamic_sections): Likewise. * elf32-nds32.c (nds32_elf_link_hash_table_create): Don't NULL already zero fields. (create_got_section): Delete. Use _bfd_elf_create_got_section instead. (nds32_elf_create_dynamic_sections): Use elf htab shortcuts to dynamic sections. (allocate_dynrelocs): Likewise. (nds32_elf_size_dynamic_sections): Likewise. (nds32_elf_relocate_section): Likewise. (nds32_elf_finish_dynamic_symbol): Likewise. (nds32_elf_finish_dynamic_sections): Likewise. (nds32_elf_check_relocs): Likewise. (calculate_plt_memory_address): Likewise. (calculate_got_memory_address): Likewise. * elf32-nds32.h (struct elf_nds32_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. * elf32-or1k.c (struct elf_or1k_link_hash_table): Likewise. (or1k_elf_relocate_section): Use elf htab shortcuts to dyn sections. (create_got_section): Delete. Use _bfd_elf_create_got_section instead. (or1k_elf_check_relocs): Use elf htab shortcuts to dynamic sections. (or1k_elf_finish_dynamic_sections): Likewise. (or1k_elf_finish_dynamic_symbol): Likewise. (allocate_dynrelocs): Likewise. (or1k_elf_size_dynamic_sections): Likewise. (or1k_elf_create_dynamic_sections): Likewise. * elf32-ppc.c (struct ppc_elf_link_hash_table): Delete got, relgot, plt, relplt, iplt, reliplt and sgotplt. (ppc_elf_create_got): Use elf htab shortcuts to dynamic sections. (ppc_elf_create_glink): Likewise. (ppc_elf_create_dynamic_sections): Likewise. (ppc_elf_check_relocs): Likewise. (ppc_elf_select_plt_layout): Likewise. (ppc_elf_tls_setup): Likewise. (allocate_got): Likewise. (allocate_dynrelocs): Likewise. (ppc_elf_size_dynamic_sections): Likewise. (ppc_elf_relax_section): Likewise. (ppc_elf_relocate_section): Likewise. (ppc_elf_finish_dynamic_symbol): Likewise. (ppc_elf_reloc_type_class): Likewise. (ppc_elf_finish_dynamic_sections): Likewise. * elf32-rl78.c (rl78_elf_relocate_section): Likewise. (rl78_elf_check_relocs): Likewise. (rl78_elf_finish_dynamic_sections): Likewise. (rl78_elf_always_size_sections): Likewise. * elf32-s390.c (create_got_section): Delete. (elf_s390_create_dynamic_sections): Use _bfd_elf_create_got_section. (elf_s390_check_relocs): Likewise. * elf32-score.c (score_elf_create_got_section): Set elf shortcuts. (s3_bfd_score_elf_finish_dynamic_sections): Use elf shortcuts. * elf32-score7.c (score_elf_create_got_section): As above. (s7_bfd_score_elf_finish_dynamic_sections): As above. * elf32-sh.c (struct elf_sh_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. (create_got_section): Don't set them. (sh_elf_create_dynamic_sections): Use elf htab shortcuts to dynamic sections. (allocate_dynrelocs): Likewise. (sh_elf_size_dynamic_sections): Likewise. (sh_elf_add_rofixup): Likewise. (sh_elf_relocate_section): Likewise. (sh_elf_check_relocs): Likewise. (sh_elf_finish_dynamic_symbol): Likewise. (sh_elf_finish_dynamic_sections): Likewise. * elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise. * elf32-tilepro.c (tilepro_elf_create_got_section): Likewise. * elf32-vax.c (elf_vax_check_relocs): Likewise. (elf_vax_adjust_dynamic_symbol): Likewise. (elf_vax_always_size_sections): Likewise. (elf_vax_instantiate_got_entries): Likewise. (elf_vax_relocate_section): Likewise. (elf_vax_finish_dynamic_symbol): Likewise. (elf_vax_finish_dynamic_sections): Likewise. * elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise. (xstormy16_elf_always_size_sections): Likewise. (xstormy16_elf_relocate_section): Likewise. (xstormy16_elf_finish_dynamic_sections): Likewise. * elf32-xtensa.c (struct elf_xtensa_link_hash_table): Delete sgot, sgotplt, srelgot, splt and srelplt. (elf_xtensa_create_dynamic_sections): Use elf htab shortcuts to dynamic sections. (elf_xtensa_allocate_dynrelocs): Likewise. (elf_xtensa_allocate_local_got_size): Likewise. (elf_xtensa_size_dynamic_sections): Likewise. (elf_xtensa_relocate_section): Likewise. (elf_xtensa_finish_dynamic_sections): Likewise. (shrink_dynamic_reloc_sections): Likewise. (elf_xtensa_get_plt_section): Likewise. (elf_xtensa_get_gotplt_section): Likewise. (xtensa_callback_required_dependence): Likewise. * elf64-alpha.c (elf64_alpha_create_dynamic_sections): Set elf htab shortcuts to dynamic sections. (elf64_alpha_adjust_dynamic_symbol): Use elf htab shortcuts to dynamic sections. (elf64_alpha_size_plt_section): Likewise. (elf64_alpha_size_rela_got_1): Likewise. (elf64_alpha_size_rela_got_section): Likewise. (elf64_alpha_relocate_section): Likewise. (elf64_alpha_finish_dynamic_symbol): Likewise. (elf64_alpha_finish_dynamic_sections): Likewise. * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise. * elf64-s390.c (create_got_section): Delete. (elf_s390_create_dynamic_sections): Use _bfd_elf_create_got_section. (elf_s390_check_relocs): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Use elf htab shortcuts to dynamic sections. (sh_elf64_check_relocs): Likewise. (sh64_elf64_adjust_dynamic_symbol): Likewise. (sh64_elf64_size_dynamic_sections): Likewise. (sh64_elf64_finish_dynamic_symbol): Likewise. (sh64_elf64_finish_dynamic_sections): Likewise. * elflink.c (_bfd_elf_create_got_section): Likewise. * elfnn-aarch64.c (aarch64_elf_create_got_section): Likewise. * elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise. (elfNN_ia64_finish_dynamic_sections): Likewise. * elfnn-riscv.c (riscv_elf_create_got_section): Likewise. * elfxx-mips.c (struct mips_elf_link_hash_table): Delete srellt, sgotplt, splt and sgot. (mips_elf_initialize_tls_slots): Use elf htab shortcuts to dynamic sections. (mips_elf_gotplt_index): Likewise. (mips_elf_primary_global_got_index): Likewise. (mips_elf_global_got_index): Likewise. (mips_elf_got_offset_from_index): Likewise. (mips_elf_create_local_got_entry): Likewise. (mips_elf_create_got_section): Likewise. (mips_elf_calculate_relocation): Likewise. (_bfd_mips_elf_create_dynamic_sections): Likewise. (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. (mips_elf_lay_out_got): Likewise. (mips_elf_set_plt_sym_value): Likewise. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_elf_finish_dynamic_symbol): Likewise. (_bfd_mips_vxworks_finish_dynamic_symbol): Likewise. (mips_finish_exec_plt): Likewise. (mips_vxworks_finish_exec_plt): Likewise. (mips_vxworks_finish_shared_plt): Likewise. (_bfd_mips_elf_finish_dynamic_sections): Likewise. * elfxx-sparc.c (sparc_finish_dyn): Likewise. * elfxx-tilegx.c (tilegx_elf_create_got_section): Likewise.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r--bfd/elf32-ppc.c276
1 files changed, 124 insertions, 152 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index efe7f69b83..35a505c4bc 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -3275,13 +3275,7 @@ struct ppc_elf_link_hash_table
struct ppc_elf_params *params;
/* Short-cuts to get to dynamic linker sections. */
- asection *got;
- asection *relgot;
asection *glink;
- asection *plt;
- asection *relplt;
- asection *iplt;
- asection *reliplt;
asection *dynbss;
asection *relbss;
asection *dynsbss;
@@ -3293,9 +3287,6 @@ struct ppc_elf_link_hash_table
/* The (unloaded but important) .rela.plt.unloaded on VxWorks. */
asection *srelplt2;
- /* The .got.plt section (VxWorks only)*/
- asection *sgotplt;
-
/* Shortcut to __tls_get_addr. */
struct elf_link_hash_entry *tls_get_addr;
@@ -3440,37 +3431,21 @@ static bfd_boolean
ppc_elf_create_got (bfd *abfd, struct bfd_link_info *info)
{
struct ppc_elf_link_hash_table *htab;
- asection *s;
- flagword flags;
if (!_bfd_elf_create_got_section (abfd, info))
return FALSE;
htab = ppc_elf_hash_table (info);
- htab->got = s = bfd_get_linker_section (abfd, ".got");
- if (s == NULL)
- abort ();
-
- if (htab->is_vxworks)
- {
- htab->sgotplt = bfd_get_linker_section (abfd, ".got.plt");
- if (!htab->sgotplt)
- abort ();
- }
- else
+ if (!htab->is_vxworks)
{
/* The powerpc .got has a blrl instruction in it. Mark it
executable. */
- flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY | SEC_LINKER_CREATED);
- if (!bfd_set_section_flags (abfd, s, flags))
+ flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ if (!bfd_set_section_flags (abfd, htab->elf.sgot, flags))
return FALSE;
}
- htab->relgot = bfd_get_linker_section (abfd, ".rela.got");
- if (!htab->relgot)
- abort ();
-
return TRUE;
}
@@ -3533,7 +3508,7 @@ ppc_elf_create_glink (bfd *abfd, struct bfd_link_info *info)
flags = SEC_ALLOC | SEC_LINKER_CREATED;
s = bfd_make_section_anyway_with_flags (abfd, ".iplt", flags);
- htab->iplt = s;
+ htab->elf.iplt = s;
if (s == NULL
|| !bfd_set_section_alignment (abfd, s, 4))
return FALSE;
@@ -3541,7 +3516,7 @@ ppc_elf_create_glink (bfd *abfd, struct bfd_link_info *info)
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
s = bfd_make_section_anyway_with_flags (abfd, ".rela.iplt", flags);
- htab->reliplt = s;
+ htab->elf.irelplt = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
return FALSE;
@@ -3570,7 +3545,7 @@ ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
htab = ppc_elf_hash_table (info);
- if (htab->got == NULL
+ if (htab->elf.sgot == NULL
&& !ppc_elf_create_got (abfd, info))
return FALSE;
@@ -3604,11 +3579,7 @@ ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
&& !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
return FALSE;
- htab->relplt = bfd_get_linker_section (abfd, ".rela.plt");
- htab->plt = s = bfd_get_linker_section (abfd, ".plt");
- if (s == NULL)
- abort ();
-
+ s = htab->elf.splt;
flags = SEC_ALLOC | SEC_CODE | SEC_LINKER_CREATED;
if (htab->plt_type == PLT_VXWORKS)
/* The VxWorks PLT is a loaded section with contents. */
@@ -4066,7 +4037,7 @@ ppc_elf_check_relocs (bfd *abfd,
This shows up in particular in an R_PPC_ADDR32 in the eabi
startup code. */
if (h != NULL
- && htab->got == NULL
+ && htab->elf.sgot == NULL
&& strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
{
if (htab->elf.dynobj == NULL)
@@ -4175,7 +4146,7 @@ ppc_elf_check_relocs (bfd *abfd,
case R_PPC_GOT16_HI:
case R_PPC_GOT16_HA:
/* This symbol requires a global offset table entry. */
- if (htab->got == NULL)
+ if (htab->elf.sgot == NULL)
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
@@ -5058,13 +5029,13 @@ ppc_elf_select_plt_layout (bfd *output_bfd ATTRIBUTE_UNUSED,
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
/* The new PLT is a loaded section. */
- if (htab->plt != NULL
- && !bfd_set_section_flags (htab->elf.dynobj, htab->plt, flags))
+ if (htab->elf.splt != NULL
+ && !bfd_set_section_flags (htab->elf.dynobj, htab->elf.splt, flags))
return -1;
/* The new GOT is not executable. */
- if (htab->got != NULL
- && !bfd_set_section_flags (htab->elf.dynobj, htab->got, flags))
+ if (htab->elf.sgot != NULL
+ && !bfd_set_section_flags (htab->elf.dynobj, htab->elf.sgot, flags))
return -1;
}
else
@@ -5337,11 +5308,11 @@ ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
htab->params->no_tls_get_addr_opt = TRUE;
}
if (htab->plt_type == PLT_NEW
- && htab->plt != NULL
- && htab->plt->output_section != NULL)
+ && htab->elf.splt != NULL
+ && htab->elf.splt->output_section != NULL)
{
- elf_section_type (htab->plt->output_section) = SHT_PROGBITS;
- elf_section_flags (htab->plt->output_section) = SHF_ALLOC + SHF_WRITE;
+ elf_section_type (htab->elf.splt->output_section) = SHT_PROGBITS;
+ elf_section_flags (htab->elf.splt->output_section) = SHF_ALLOC + SHF_WRITE;
}
return _bfd_elf_tls_setup (obfd, info);
@@ -5927,8 +5898,8 @@ allocate_got (struct ppc_elf_link_hash_table *htab, unsigned int need)
if (htab->plt_type == PLT_VXWORKS)
{
- where = htab->got->size;
- htab->got->size += need;
+ where = htab->elf.sgot->size;
+ htab->elf.sgot->size += need;
}
else
{
@@ -5940,14 +5911,14 @@ allocate_got (struct ppc_elf_link_hash_table *htab, unsigned int need)
}
else
{
- if (htab->got->size + need > max_before_header
- && htab->got->size <= max_before_header)
+ if (htab->elf.sgot->size + need > max_before_header
+ && htab->elf.sgot->size <= max_before_header)
{
- htab->got_gap = max_before_header - htab->got->size;
- htab->got->size = max_before_header + htab->got_header_size;
+ htab->got_gap = max_before_header - htab->elf.sgot->size;
+ htab->elf.sgot->size = max_before_header + htab->got_header_size;
}
- where = htab->got->size;
- htab->got->size += need;
+ where = htab->elf.sgot->size;
+ htab->elf.sgot->size += need;
}
}
return where;
@@ -5993,9 +5964,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|| h->type == STT_GNU_IFUNC
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
{
- asection *s = htab->plt;
+ asection *s = htab->elf.splt;
if (!dyn || h->dynindx == -1)
- s = htab->iplt;
+ s = htab->elf.iplt;
if (htab->plt_type == PLT_NEW || !dyn || h->dynindx == -1)
{
@@ -6081,10 +6052,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
if (!htab->elf.dynamic_sections_created
|| h->dynindx == -1)
- htab->reliplt->size += sizeof (Elf32_External_Rela);
+ htab->elf.irelplt->size += sizeof (Elf32_External_Rela);
else
{
- htab->relplt->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
if (htab->plt_type == PLT_VXWORKS)
{
@@ -6107,7 +6078,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* Every PLT entry has an associated GOT entry in
.got.plt. */
- htab->sgotplt->size += 4;
+ htab->elf.sgotplt->size += 4;
}
}
doneone = TRUE;
@@ -6186,10 +6157,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
&& (ELF_ST_VISIBILITY (eh->elf.other) == STV_DEFAULT
|| eh->elf.root.type != bfd_link_hash_undefweak))
{
- asection *rsec = htab->relgot;
+ asection *rsec = htab->elf.srelgot;
if (eh->elf.type == STT_GNU_IFUNC)
- rsec = htab->reliplt;
+ rsec = htab->elf.irelplt;
/* All the entries we allocated need relocs.
Except LD only needs one. */
if ((eh->tls_mask & TLS_LD) != 0
@@ -6312,7 +6283,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
if (eh->elf.type == STT_GNU_IFUNC)
- sreloc = htab->reliplt;
+ sreloc = htab->elf.irelplt;
sreloc->size += p->count * sizeof (Elf32_External_Rela);
}
@@ -6430,7 +6401,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
if (p->ifunc)
- sreloc = htab->reliplt;
+ sreloc = htab->elf.irelplt;
sreloc->size += p->count * sizeof (Elf32_External_Rela);
if ((p->sec->output_section->flags
& (SEC_READONLY | SEC_ALLOC))
@@ -6475,9 +6446,9 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
*local_got = allocate_got (htab, need);
if (bfd_link_pic (info))
{
- asection *srel = htab->relgot;
+ asection *srel = htab->elf.srelgot;
if ((*lgot_masks & PLT_IFUNC) != 0)
- srel = htab->reliplt;
+ srel = htab->elf.irelplt;
srel->size += need * (sizeof (Elf32_External_Rela) / 4);
}
}
@@ -6498,7 +6469,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
for (ent = *local_plt; ent != NULL; ent = ent->next)
if (ent->plt.refcount > 0)
{
- s = htab->iplt;
+ s = htab->elf.iplt;
if (!doneone)
{
@@ -6517,7 +6488,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
if (!doneone)
{
- htab->reliplt->size += sizeof (Elf32_External_Rela);
+ htab->elf.irelplt->size += sizeof (Elf32_External_Rela);
doneone = TRUE;
}
}
@@ -6533,12 +6504,12 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
{
htab->tlsld_got.offset = allocate_got (htab, 8);
if (bfd_link_pic (info))
- htab->relgot->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
}
else
htab->tlsld_got.offset = (bfd_vma) -1;
- if (htab->got != NULL && htab->plt_type != PLT_VXWORKS)
+ if (htab->elf.sgot != NULL && htab->plt_type != PLT_VXWORKS)
{
unsigned int g_o_t = 32768;
@@ -6546,12 +6517,12 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
for old plt/got the got size will be 0 to 32764 (not allocated),
or 32780 to 65536 (header allocated). For new plt/got, the
corresponding ranges are 0 to 32768 and 32780 to 65536. */
- if (htab->got->size <= 32768)
+ if (htab->elf.sgot->size <= 32768)
{
- g_o_t = htab->got->size;
+ g_o_t = htab->elf.sgot->size;
if (htab->plt_type == PLT_OLD)
g_o_t += 4;
- htab->got->size += htab->got_header_size;
+ htab->elf.sgot->size += htab->got_header_size;
}
htab->elf.hgot->root.u.def.value = g_o_t;
@@ -6652,8 +6623,8 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
- if (s == htab->plt
- || s == htab->got)
+ if (s == htab->elf.splt
+ || s == htab->elf.sgot)
{
/* We'd like to strip these sections if they aren't needed, but if
we've exported dynamic symbols from them we must leave them.
@@ -6663,10 +6634,10 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
/* Strip this section if we don't need it; see the
comment below. */
}
- else if (s == htab->iplt
+ else if (s == htab->elf.iplt
|| s == htab->glink
|| s == htab->glink_eh_frame
- || s == htab->sgotplt
+ || s == htab->elf.sgotplt
|| s == htab->sbss
|| s == htab->dynbss
|| s == htab->dynsbss)
@@ -6737,7 +6708,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
return FALSE;
}
- if (htab->plt != NULL && htab->plt->size != 0)
+ if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
{
if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -7236,7 +7207,7 @@ ppc_elf_relax_section (bfd *abfd,
}
else
{
- tsec = htab->plt;
+ tsec = htab->elf.splt;
toff = ent->plt.offset;
}
}
@@ -7339,7 +7310,7 @@ ppc_elf_relax_section (bfd *abfd,
insn_offset = 0;
}
stub_rtype = R_PPC_RELAX;
- if (tsec == htab->plt
+ if (tsec == htab->elf.splt
|| tsec == htab->glink)
{
stub_rtype = R_PPC_RELAX_PLT;
@@ -8279,8 +8250,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
bfd_put_32 (input_bfd, B | off,
contents + rel->r_offset - d_offset);
- got_addr = (htab->got->output_section->vma
- + htab->got->output_offset
+ got_addr = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ (h->got.offset & ~1));
wrel->r_offset = (p - contents) + d_offset;
wrel->r_info = ELF32_R_INFO (0, R_PPC_ADDR16_HA);
@@ -8413,13 +8384,13 @@ ppc_elf_relocate_section (bfd *output_bfd,
Elf_Internal_Rela rela;
bfd_byte *loc;
- rela.r_offset = (htab->iplt->output_section->vma
- + htab->iplt->output_offset
+ rela.r_offset = (htab->elf.iplt->output_section->vma
+ + htab->elf.iplt->output_offset
+ ent->plt.offset);
rela.r_info = ELF32_R_INFO (0, R_PPC_IRELATIVE);
rela.r_addend = relocation;
- loc = htab->reliplt->contents;
- loc += (htab->reliplt->reloc_count++
+ loc = htab->elf.irelplt->contents;
+ loc += (htab->elf.irelplt->reloc_count++
* sizeof (Elf32_External_Rela));
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
@@ -8429,7 +8400,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
{
unsigned char *p = ((unsigned char *) htab->glink->contents
+ ent->glink_offset);
- write_glink_stub (ent, htab->iplt, p, info);
+ write_glink_stub (ent, htab->elf.iplt, p, info);
ent->glink_offset |= 1;
}
@@ -8442,8 +8413,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
+ htab->glink->output_offset
+ (ent->glink_offset & ~1));
else
- relocation = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset);
}
}
@@ -8519,7 +8490,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
bfd_vma *offp;
unsigned long indx;
- if (htab->got == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
indx = 0;
@@ -8606,13 +8577,13 @@ ppc_elf_relocate_section (bfd *output_bfd,
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
{
- asection *rsec = htab->relgot;
+ asection *rsec = htab->elf.srelgot;
bfd_byte * loc;
if (ifunc != NULL)
- rsec = htab->reliplt;
- outrel.r_offset = (htab->got->output_section->vma
- + htab->got->output_offset
+ rsec = htab->elf.irelplt;
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ off);
outrel.r_addend = 0;
if (tls_ty & (TLS_LD | TLS_GD))
@@ -8679,12 +8650,12 @@ ppc_elf_relocate_section (bfd *output_bfd,
if (tls_ty == (TLS_TLS | TLS_GD))
{
bfd_put_32 (input_bfd, value,
- htab->got->contents + off + 4);
+ htab->elf.sgot->contents + off + 4);
value = 1;
}
}
bfd_put_32 (input_bfd, value,
- htab->got->contents + off);
+ htab->elf.sgot->contents + off);
}
off += 4;
@@ -8725,8 +8696,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
if (r_type != ELF32_R_TYPE (rel->r_info))
goto copy_reloc;
- relocation = (htab->got->output_section->vma
- + htab->got->output_offset
+ relocation = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ off
- SYM_VAL (htab->elf.hgot));
@@ -8909,7 +8880,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
time. */
sreloc = elf_section_data (input_section)->sreloc;
if (ifunc)
- sreloc = htab->reliplt;
+ sreloc = htab->elf.irelplt;
if (sreloc == NULL)
return FALSE;
@@ -9046,8 +9017,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
+ htab->glink->output_offset
+ ent->glink_offset);
else
- relocation = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset);
}
/* Fall through. */
@@ -9169,7 +9140,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
ent = find_plt_ent (&h->plt.plist, got2,
bfd_link_pic (info) ? addend : 0);
if (ent == NULL
- || htab->plt == NULL)
+ || htab->elf.splt == NULL)
{
/* We didn't make a PLT entry for this symbol. This
happens when statically linking PIC code, or when
@@ -9185,8 +9156,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
+ htab->glink->output_offset
+ ent->glink_offset);
else
- relocation = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset);
}
}
@@ -10137,10 +10108,10 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
{
bfd_put_32 (output_bfd,
plt_entry[0] | PPC_HA (got_offset),
- htab->plt->contents + ent->plt.offset + 0);
+ htab->elf.splt->contents + ent->plt.offset + 0);
bfd_put_32 (output_bfd,
plt_entry[1] | PPC_LO (got_offset),
- htab->plt->contents + ent->plt.offset + 4);
+ htab->elf.splt->contents + ent->plt.offset + 4);
}
else
{
@@ -10148,16 +10119,16 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
bfd_put_32 (output_bfd,
plt_entry[0] | PPC_HA (got_loc),
- htab->plt->contents + ent->plt.offset + 0);
+ htab->elf.splt->contents + ent->plt.offset + 0);
bfd_put_32 (output_bfd,
plt_entry[1] | PPC_LO (got_loc),
- htab->plt->contents + ent->plt.offset + 4);
+ htab->elf.splt->contents + ent->plt.offset + 4);
}
bfd_put_32 (output_bfd, plt_entry[2],
- htab->plt->contents + ent->plt.offset + 8);
+ htab->elf.splt->contents + ent->plt.offset + 8);
bfd_put_32 (output_bfd, plt_entry[3],
- htab->plt->contents + ent->plt.offset + 12);
+ htab->elf.splt->contents + ent->plt.offset + 12);
/* This instruction is an immediate load. The value loaded is
the byte offset of the R_PPC_JMP_SLOT relocation from the
@@ -10167,7 +10138,7 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
prescaled offset. */
bfd_put_32 (output_bfd,
plt_entry[4] | reloc_index,
- htab->plt->contents + ent->plt.offset + 16);
+ htab->elf.splt->contents + ent->plt.offset + 16);
/* This instruction is a PC-relative branch whose target is
the start of the PLT section. The address of this branch
instruction is 20 bytes beyond the start of this PLT entry.
@@ -10177,19 +10148,19 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
bfd_put_32 (output_bfd,
(plt_entry[5]
| (-(ent->plt.offset + 20) & 0x03fffffc)),
- htab->plt->contents + ent->plt.offset + 20);
+ htab->elf.splt->contents + ent->plt.offset + 20);
bfd_put_32 (output_bfd, plt_entry[6],
- htab->plt->contents + ent->plt.offset + 24);
+ htab->elf.splt->contents + ent->plt.offset + 24);
bfd_put_32 (output_bfd, plt_entry[7],
- htab->plt->contents + ent->plt.offset + 28);
+ htab->elf.splt->contents + ent->plt.offset + 28);
/* Fill in the GOT entry corresponding to this PLT slot with
the address immediately after the "bctr" instruction
in this PLT entry. */
- bfd_put_32 (output_bfd, (htab->plt->output_section->vma
- + htab->plt->output_offset
+ bfd_put_32 (output_bfd, (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset + 16),
- htab->sgotplt->contents + got_offset);
+ htab->elf.sgotplt->contents + got_offset);
if (!bfd_link_pic (info))
{
@@ -10200,8 +10171,8 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
* sizeof (Elf32_External_Rela));
/* Provide the @ha relocation for the first instruction. */
- rela.r_offset = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ rela.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset + 2);
rela.r_info = ELF32_R_INFO (htab->elf.hgot->indx,
R_PPC_ADDR16_HA);
@@ -10210,8 +10181,8 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
loc += sizeof (Elf32_External_Rela);
/* Provide the @l relocation for the second instruction. */
- rela.r_offset = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ rela.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ ent->plt.offset + 6);
rela.r_info = ELF32_R_INFO (htab->elf.hgot->indx,
R_PPC_ADDR16_LO);
@@ -10221,8 +10192,8 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
/* Provide a relocation for the GOT entry corresponding to this
PLT slot. Point it at the middle of the .plt entry. */
- rela.r_offset = (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ rela.r_offset = (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ got_offset);
rela.r_info = ELF32_R_INFO (htab->elf.hplt->indx,
R_PPC_ADDR32);
@@ -10235,17 +10206,17 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
address of the PLT entry for this function, as specified
by the ABI. Instead, the offset is set to the address of
the GOT slot for this function. See EABI 4.4.4.1. */
- rela.r_offset = (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ rela.r_offset = (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ got_offset);
}
else
{
- asection *splt = htab->plt;
+ asection *splt = htab->elf.splt;
if (!htab->elf.dynamic_sections_created
|| h->dynindx == -1)
- splt = htab->iplt;
+ splt = htab->elf.iplt;
rela.r_offset = (splt->output_section->vma
+ splt->output_offset
@@ -10284,11 +10255,11 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
if (!htab->elf.dynamic_sections_created
|| h->dynindx == -1)
- loc = (htab->reliplt->contents
- + (htab->reliplt->reloc_count++
+ loc = (htab->elf.irelplt->contents
+ + (htab->elf.irelplt->reloc_count++
* sizeof (Elf32_External_Rela)));
else
- loc = (htab->relplt->contents
+ loc = (htab->elf.srelplt->contents
+ reloc_index * sizeof (Elf32_External_Rela));
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
@@ -10336,10 +10307,10 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
|| h->dynindx == -1)
{
unsigned char *p;
- asection *splt = htab->plt;
+ asection *splt = htab->elf.splt;
if (!htab->elf.dynamic_sections_created
|| h->dynindx == -1)
- splt = htab->iplt;
+ splt = htab->elf.iplt;
p = (unsigned char *) htab->glink->contents + ent->glink_offset;
@@ -10414,7 +10385,7 @@ ppc_elf_reloc_type_class (const struct bfd_link_info *info,
{
struct ppc_elf_link_hash_table *htab = ppc_elf_hash_table (info);
- if (rel_sec == htab->reliplt)
+ if (rel_sec == htab->elf.irelplt)
return reloc_class_ifunc;
switch (ELF32_R_TYPE (rela->r_info))
@@ -10448,10 +10419,10 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
#endif
htab = ppc_elf_hash_table (info);
- dynobj = elf_hash_table (info)->dynobj;
+ dynobj = htab->elf.dynobj;
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (htab->is_vxworks)
- splt = bfd_get_linker_section (dynobj, ".plt");
+ splt = htab->elf.splt;
else
splt = NULL;
@@ -10463,7 +10434,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
{
Elf32_External_Dyn *dyncon, *dynconend;
- BFD_ASSERT (htab->plt != NULL && sdyn != NULL);
+ BFD_ASSERT (htab->elf.splt != NULL && sdyn != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -10478,18 +10449,18 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
{
case DT_PLTGOT:
if (htab->is_vxworks)
- s = htab->sgotplt;
+ s = htab->elf.sgotplt;
else
- s = htab->plt;
+ s = htab->elf.splt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
- dyn.d_un.d_val = htab->relplt->size;
+ dyn.d_un.d_val = htab->elf.srelplt->size;
break;
case DT_JMPREL:
- s = htab->relplt;
+ s = htab->elf.srelplt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
@@ -10500,8 +10471,8 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
case DT_RELASZ:
if (htab->is_vxworks)
{
- if (htab->relplt)
- dyn.d_un.d_ptr -= htab->relplt->size;
+ if (htab->elf.srelplt)
+ dyn.d_un.d_ptr -= htab->elf.srelplt->size;
break;
}
continue;
@@ -10517,10 +10488,10 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
}
}
- if (htab->got != NULL)
+ if (htab->elf.sgot != NULL)
{
- if (htab->elf.hgot->root.u.def.section == htab->got
- || htab->elf.hgot->root.u.def.section == htab->sgotplt)
+ if (htab->elf.hgot->root.u.def.section == htab->elf.sgot
+ || htab->elf.hgot->root.u.def.section == htab->elf.sgotplt)
{
unsigned char *p = htab->elf.hgot->root.u.def.section->contents;
@@ -10548,13 +10519,14 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
/* xgettext:c-format */
info->callbacks->einfo (_("%P: %s not defined in linker created %s\n"),
htab->elf.hgot->root.root.string,
- (htab->sgotplt != NULL
- ? htab->sgotplt->name : htab->got->name));
+ (htab->elf.sgotplt != NULL
+ ? htab->elf.sgotplt->name
+ : htab->elf.sgot->name));
bfd_set_error (bfd_error_bad_value);
ret = FALSE;
}
- elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 4;
}
/* Fill in the first entry in the VxWorks procedure linkage table. */
@@ -10594,8 +10566,8 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
loc = htab->srelplt2->contents;
/* Output the @ha relocation for the first instruction. */
- rela.r_offset = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ rela.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ 2);
rela.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_PPC_ADDR16_HA);
rela.r_addend = 0;
@@ -10603,8 +10575,8 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
loc += sizeof (Elf32_External_Rela);
/* Output the @l relocation for the second instruction. */
- rela.r_offset = (htab->plt->output_section->vma
- + htab->plt->output_offset
+ rela.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ 6);
rela.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_PPC_ADDR16_LO);
rela.r_addend = 0;