]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Delete duplicate target short-cuts to dynamic sections
authorAlan Modra <amodra@gmail.com>
Wed, 23 Nov 2016 04:36:34 +0000 (15:06 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 23 Nov 2016 05:04:01 +0000 (15:34 +1030)
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.

39 files changed:
bfd/ChangeLog
bfd/elf-m10300.c
bfd/elf32-bfin.c
bfd/elf32-cr16.c
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-lm32.c
bfd/elf32-m32c.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-metag.c
bfd/elf32-microblaze.c
bfd/elf32-nds32.c
bfd/elf32-nds32.h
bfd/elf32-or1k.c
bfd/elf32-ppc.c
bfd/elf32-rl78.c
bfd/elf32-s390.c
bfd/elf32-score.c
bfd/elf32-score7.c
bfd/elf32-sh.c
bfd/elf32-tic6x.c
bfd/elf32-tilepro.c
bfd/elf32-vax.c
bfd/elf32-xstormy16.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elflink.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfnn-riscv.c
bfd/elfxx-mips.c
bfd/elfxx-sparc.c
bfd/elfxx-tilegx.c

index 77d97e8f9e26c2a77c6a1efdce07c1cb0a22780f..3f43a5a3857751d3e73b1212d87cbeebf137b4eb 100644 (file)
@@ -1,3 +1,259 @@
+2016-11-23  Alan Modra  <amodra@gmail.com>
+
+       * 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.
+
 2016-11-23  Alan Modra  <amodra@gmail.com>
 
        * po/BLD-POTFILES.in: Regenerate.
index 688a270525c3055cd5cf8d6849c8002920fe269c..0b62fa9cc4828f34763b4b82805c4804de26b068 100644 (file)
@@ -1174,29 +1174,9 @@ mn10300_elf_check_relocs (bfd *abfd,
            default:                  tls_type = GOT_NORMAL; break;
            }
 
-         if (sgot == NULL)
-           {
-             sgot = htab->root.sgot;
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || ! bfd_set_section_alignment (dynobj, srelgot, 2))
-                   goto fail;
-               }
-           }
+         sgot = htab->root.sgot;
+         srelgot = htab->root.srelgot;
+         BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
          if (r_type == R_MN10300_TLS_LD)
            {
@@ -1819,7 +1799,7 @@ mn10300_elf_final_link_relocate (reloc_howto_type *howto,
 
       if (!htab->tls_ldm_got.rel_emitted)
        {
-         asection * srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+         asection *srelgot = htab->root.srelgot;
          Elf_Internal_Rela rel;
 
          BFD_ASSERT (srelgot != NULL);
@@ -1896,10 +1876,9 @@ mn10300_elf_final_link_relocate (reloc_howto_type *howto,
 
              if (bfd_link_pic (info))
                {
-                 asection * srelgot;
+                 asection *srelgot = htab->root.srelgot;;
                  Elf_Internal_Rela outrel;
 
-                 srelgot = bfd_get_linker_section (dynobj, ".rela.got");
                  BFD_ASSERT (srelgot != NULL);
 
                  outrel.r_offset = (sgot->output_section->vma
@@ -4973,7 +4952,7 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (struct bfd_link_info * info,
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = htab->root.srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -5078,7 +5057,7 @@ _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd,
 
   if (htab->tls_ldm_got.refcount > 0)
     {
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = htab->root.srelgot;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
     }
@@ -5242,7 +5221,7 @@ _bfd_mn10300_elf_finish_dynamic_symbol (bfd * output_bfd,
 
       splt = htab->root.splt;
       sgot = htab->root.sgotplt;
-      srel = bfd_get_linker_section (dynobj, ".rela.plt");
+      srel = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -5320,7 +5299,7 @@ _bfd_mn10300_elf_finish_dynamic_symbol (bfd * output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
       sgot = htab->root.sgot;
-      srel = bfd_get_linker_section (dynobj, ".rela.got");
+      srel = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -5449,7 +5428,6 @@ _bfd_mn10300_elf_finish_dynamic_sections (bfd * output_bfd,
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char * name;
          asection * s;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -5460,19 +5438,18 @@ _bfd_mn10300_elf_finish_dynamic_sections (bfd * output_bfd,
              break;
 
            case DT_PLTGOT:
-             name = ".got";
+             s = htab->root.sgot;
              goto get_vma;
 
            case DT_JMPREL:
-             name = ".rela.plt";
+             s = htab->root.srelplt;
            get_vma:
-             s = bfd_get_linker_section (dynobj, name);
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = htab->root.srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -5487,7 +5464,7 @@ _bfd_mn10300_elf_finish_dynamic_sections (bfd * output_bfd,
                 the linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = htab->root.srelplt;
              if (s != NULL)
                dyn.d_un.d_val -= s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
index fdf02997b4b1b17fec3852935b455aae28a9f882..3076ec99f880ef0335f296af6eea84a049d391b8 100644 (file)
@@ -1226,28 +1226,9 @@ bfin_check_relocs (bfd * abfd,
                return FALSE;
            }
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
+         sgot = elf_hash_table (info)->sgot;
+         srelgot = elf_hash_table (info)->srelgot;
+         BFD_ASSERT (sgot != NULL);
 
          if (h != NULL)
            {
@@ -1480,20 +1461,17 @@ bfin_relocate_section (bfd * output_bfd,
          {
            bfd_vma off;
 
-         if (dynobj == NULL)
-           {
-             /* Create the .got section.  */
-             elf_hash_table (info)->dynobj = dynobj = output_bfd;
-             if (!_bfd_elf_create_got_section (dynobj, info))
-               return FALSE;
-           }
-
-           if (sgot == NULL)
+           if (dynobj == NULL)
              {
-               sgot = bfd_get_linker_section (dynobj, ".got");
-               BFD_ASSERT (sgot != NULL);
+               /* Create the .got section.  */
+               elf_hash_table (info)->dynobj = dynobj = output_bfd;
+               if (!_bfd_elf_create_got_section (dynobj, info))
+                 return FALSE;
              }
 
+           sgot = elf_hash_table (info)->sgot;
+           BFD_ASSERT (sgot != NULL);
+
            if (h != NULL)
              {
                bfd_boolean dyn;
@@ -1556,7 +1534,7 @@ bfin_relocate_section (bfd * output_bfd,
                        Elf_Internal_Rela outrel;
                        bfd_byte *loc;
 
-                       s = bfd_get_linker_section (dynobj, ".rela.got");
+                       s = elf_hash_table (info)->srelgot;
                        BFD_ASSERT (s != NULL);
 
                        outrel.r_offset = (sgot->output_section->vma
@@ -1684,8 +1662,8 @@ bfin_gc_sweep_hook (bfd * abfd,
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  sgot = bfd_get_linker_section (dynobj, ".got");
-  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  sgot = elf_hash_table (info)->sgot;
+  srelgot = elf_hash_table (info)->srelgot;
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -1742,16 +1720,8 @@ struct bfinfdpic_elf_link_hash_table
 {
   struct elf_link_hash_table elf;
 
-  /* A pointer to the .got section.  */
-  asection *sgot;
-  /* A pointer to the .rel.got section.  */
-  asection *sgotrel;
   /* A pointer to the .rofixup section.  */
   asection *sgotfixup;
-  /* A pointer to the .plt section.  */
-  asection *splt;
-  /* A pointer to the .rel.plt section.  */
-  asection *spltrel;
   /* GOT base offset.  */
   bfd_vma got0;
   /* Location of the first non-lazy PLT entry, i.e., the number of
@@ -1772,15 +1742,15 @@ struct bfinfdpic_elf_link_hash_table
   == BFIN_ELF_DATA ? ((struct bfinfdpic_elf_link_hash_table *) ((info)->hash)) : NULL)
 
 #define bfinfdpic_got_section(info) \
-  (bfinfdpic_hash_table (info)->sgot)
+  (bfinfdpic_hash_table (info)->elf.sgot)
 #define bfinfdpic_gotrel_section(info) \
-  (bfinfdpic_hash_table (info)->sgotrel)
+  (bfinfdpic_hash_table (info)->elf.srelgot)
 #define bfinfdpic_gotfixup_section(info) \
   (bfinfdpic_hash_table (info)->sgotfixup)
 #define bfinfdpic_plt_section(info) \
-  (bfinfdpic_hash_table (info)->splt)
+  (bfinfdpic_hash_table (info)->elf.splt)
 #define bfinfdpic_pltrel_section(info) \
-  (bfinfdpic_hash_table (info)->spltrel)
+  (bfinfdpic_hash_table (info)->elf.srelplt)
 #define bfinfdpic_relocs_info(info) \
   (bfinfdpic_hash_table (info)->relocs_info)
 #define bfinfdpic_got_initial_offset(info) \
@@ -3395,7 +3365,7 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
   int ptralign;
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
+  s = elf_hash_table (info)->sgot;
   if (s != NULL)
     return TRUE;
 
@@ -3410,18 +3380,11 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
   pltflags = flags;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
+  elf_hash_table (info)->sgot = s;
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (bed->want_got_plt)
-    {
-      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
-      if (s == NULL
-         || !bfd_set_section_alignment (abfd, s, ptralign))
-       return FALSE;
-    }
-
   if (bed->want_got_sym)
     {
       /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
@@ -3446,7 +3409,6 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
      data for the got.  */
   if (IS_FDPIC (abfd))
     {
-      bfinfdpic_got_section (info) = s;
       bfinfdpic_relocs_info (info) = htab_try_create (1,
                                                      bfinfdpic_relocs_info_hash,
                                                      bfinfdpic_relocs_info_eq,
@@ -5129,10 +5091,6 @@ bfin_finish_dynamic_symbol (bfd * output_bfd,
                            struct elf_link_hash_entry *h,
                            Elf_Internal_Sym * sym)
 {
-  bfd *dynobj;
-
-  dynobj = elf_hash_table (info)->dynobj;
-
   if (h->got.offset != (bfd_vma) - 1)
     {
       asection *sgot;
@@ -5143,8 +5101,8 @@ bfin_finish_dynamic_symbol (bfd * output_bfd,
       /* This symbol has an entry in the global offset table.
          Set it up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srela = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -5395,7 +5353,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
          not actually use these entries.  Reset the size of .rela.got,
          which will cause it to get stripped from the output file
          below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = 0;
     }
index 8fbe2ab5933a20cb25d60d29befaae202da04729..631445d58c9c090c177e2ddf471fefd4072f3137 100644 (file)
@@ -582,10 +582,11 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info)
   asection * s;
   struct elf_link_hash_entry * h;
   const struct elf_backend_data * bed = get_elf_backend_data (abfd);
+  struct elf_link_hash_table *htab = elf_hash_table (info);
   int ptralign;
 
   /* This function may be called more than once.  */
-  if (bfd_get_linker_section (abfd, ".got") != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   switch (bed->s->arch_size)
@@ -607,6 +608,7 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info)
            | SEC_LINKER_CREATED);
 
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
+  htab->sgot= s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
@@ -614,6 +616,7 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info)
   if (bed->want_got_plt)
     {
       s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
+      htab->sgotplt = s;
       if (s == NULL
           || ! bfd_set_section_alignment (abfd, s, ptralign))
         return FALSE;
@@ -624,7 +627,7 @@ _bfd_cr16_elf_create_got_section (bfd * abfd, struct bfd_link_info * info)
      because we don't want to define the symbol if we are not creating
      a global offset table.  */
   h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
-  elf_hash_table (info)->hgot = h;
+  htab->hgot = h;
   if (h == NULL)
     return FALSE;
 
@@ -761,29 +764,9 @@ cr16_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
         case R_CR16_GOTC_REGREL20:
           /* This symbol requires a global offset table entry.  */
 
-          if (sgot == NULL)
-            {
-              sgot = bfd_get_linker_section (dynobj, ".got");
-              BFD_ASSERT (sgot != NULL);
-            }
-
-          if (srelgot == NULL
-              && (h != NULL || bfd_link_executable (info)))
-            {
-              srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-              if (srelgot == NULL)
-                {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                  if (srelgot == NULL
-                      || ! bfd_set_section_alignment (dynobj, srelgot, 2))
-                    goto fail;
-                }
-            }
+         sgot = elf_hash_table (info)->sgot;
+         srelgot = elf_hash_table (info)->srelgot;
+         BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
           if (h != NULL)
             {
@@ -870,9 +853,6 @@ cr16_elf_final_link_relocate (reloc_howto_type *howto,
   unsigned short r_type = howto->type;
   bfd_byte *hit_data = contents + offset;
   bfd_vma reloc_bits, check, Rvalue1;
-  bfd *      dynobj;
-
-  dynobj = elf_hash_table (info)->dynobj;
 
   switch (r_type)
     {
@@ -1056,7 +1036,7 @@ cr16_elf_final_link_relocate (reloc_howto_type *howto,
           }
         else if (r_type == R_CR16_GOT_REGREL20)
           {
-            asection * sgot = bfd_get_linker_section (dynobj, ".got");
+            asection *sgot = elf_hash_table (info)->sgot;
 
             if (h != NULL)
               {
@@ -1104,8 +1084,7 @@ cr16_elf_final_link_relocate (reloc_howto_type *howto,
           }
         else if (r_type == R_CR16_GOTC_REGREL20)
           {
-             asection * sgot;
-             sgot = bfd_get_linker_section (dynobj, ".got");
+             asection *sgot = elf_hash_table (info)->sgot;
 
              if (h != NULL)
                {
@@ -2248,6 +2227,7 @@ _bfd_cr16_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   flagword   flags;
   asection * s;
   const struct elf_backend_data * bed = get_elf_backend_data (abfd);
+  struct elf_link_hash_table *htab = elf_hash_table (info);
   int ptralign = 0;
 
   switch (bed->s->arch_size)
@@ -2275,6 +2255,7 @@ _bfd_cr16_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                                          (bed->default_use_rela_p
                                           ? ".rela.plt" : ".rel.plt"),
                                          flags | SEC_READONLY);
+  htab->srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
@@ -2373,13 +2354,13 @@ _bfd_cr16_elf_adjust_dynamic_symbol (struct bfd_link_info * info,
       /* We also need to make an entry in the .got.plt section, which
          will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = elf_hash_table (info)->sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = elf_hash_table (info)->srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -2478,7 +2459,7 @@ _bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd,
          not actually use these entries.  Reset the size of .rela.got,
          which will cause it to get stripped from the output file
          below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
         s->size = 0;
     }
@@ -2633,8 +2614,8 @@ _bfd_cr16_elf_finish_dynamic_symbol (bfd * output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srel = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srel = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -2712,7 +2693,7 @@ _bfd_cr16_elf_finish_dynamic_sections (bfd * output_bfd,
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -2729,7 +2710,6 @@ _bfd_cr16_elf_finish_dynamic_sections (bfd * output_bfd,
       for (; dyncon < dynconend; dyncon++)
         {
           Elf_Internal_Dyn dyn;
-          const char * name;
           asection * s;
 
           bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -2740,19 +2720,18 @@ _bfd_cr16_elf_finish_dynamic_sections (bfd * output_bfd,
               break;
 
             case DT_PLTGOT:
-              name = ".got.plt";
+              s = elf_hash_table (info)->sgotplt;
               goto get_vma;
 
             case DT_JMPREL:
-              name = ".rela.plt";
+              s = elf_hash_table (info)->srelplt;
             get_vma:
-              s = bfd_get_linker_section (dynobj, name);
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
 
             case DT_PLTRELSZ:
-              s = bfd_get_linker_section (dynobj, ".rela.plt");
+              s = elf_hash_table (info)->srelplt;
               dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
@@ -2767,7 +2746,7 @@ _bfd_cr16_elf_finish_dynamic_sections (bfd * output_bfd,
                  the linker script arranges for .rela.plt to follow all
                  other relocation sections, we don't have to worry
                  about changing the DT_RELA entry.  */
-              s = bfd_get_linker_section (dynobj, ".rela.plt");
+              s = elf_hash_table (info)->srelplt;
               if (s != NULL)
                 dyn.d_un.d_val -= s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
index 9d6d0c424cd6750f7f6d1f397c2d8d84a7f20e10..7d388018d3796a121ef90d3c91b76554cf15d043 100644 (file)
@@ -990,7 +990,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -1003,8 +1003,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (dynobj != NULL)
     {
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgot = bfd_get_linker_section (dynobj, ".got");
+      splt = htab->root.splt;
+      sgot = htab->root.sgot;
     }
 
   for (rel = relocs; rel < relend; rel ++)
@@ -1142,8 +1142,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          if (h != NULL
              && ((struct elf_cris_link_hash_entry *) h)->gotplt_offset != 0)
            {
-             asection *sgotplt
-               = bfd_get_linker_section (dynobj, ".got.plt");
+             asection *sgotplt = htab->root.sgotplt;
              bfd_vma got_offset;
 
              BFD_ASSERT (h->dynindx != -1);
@@ -1275,9 +1274,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                        Elf_Internal_Rela outrel;
                        bfd_byte *loc;
 
-                       if (srelgot == NULL)
-                         srelgot
-                           = bfd_get_linker_section (dynobj, ".rela.got");
+                       srelgot = htab->root.srelgot;
                        BFD_ASSERT (srelgot != NULL);
 
                        outrel.r_offset = (sgot->output_section->vma
@@ -1599,7 +1596,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          if (htab->dtpmod_refcount > 0
              && (input_section->flags & SEC_ALLOC) != 0)
            {
-             asection *sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+             asection *sgotplt = htab->root.sgotplt;
              BFD_ASSERT (sgotplt != NULL);
 
              if (bfd_link_pic (info))
@@ -1607,8 +1604,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  Elf_Internal_Rela outrel;
                  bfd_byte *loc;
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
                  loc = srelgot->contents;
                  loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
@@ -1752,8 +1748,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  bfd_put_32 (output_bfd, 0, sgot->contents + off);
                  bfd_put_32 (output_bfd, 0, sgot->contents + off + 4);
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
 
                  if (h != NULL && h->dynindx != -1)
@@ -1885,8 +1880,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  else
                    local_got_offsets[r_symndx] |= 1;
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
 
                  if (h != NULL && h->dynindx != -1)
@@ -2095,7 +2089,7 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
       plt_pic_entry = elf_cris_pic_plt_entry_v32;
     }
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   if (h->plt.offset != (bfd_vma) -1)
     {
@@ -2139,9 +2133,9 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-      srela = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = htab->root.splt;
+      sgotplt = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgotplt != NULL
                  && (! has_gotplt || srela != NULL));
 
@@ -2238,8 +2232,8 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -2318,7 +2312,7 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -2327,7 +2321,7 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -2352,14 +2346,14 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
            case DT_JMPREL:
              /* Yes, we *can* have a .plt and no .plt.rela, for instance
                 if all symbols are found in the .got (not .got.plt).  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              dyn.d_un.d_ptr = s != NULL ? (s->output_section->vma
                                            + s->output_offset) : 0;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s == NULL)
                dyn.d_un.d_val = 0;
              else
@@ -2375,7 +2369,7 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
                 linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s != NULL)
                dyn.d_un.d_val -= s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -2504,8 +2498,8 @@ cris_elf_gc_sweep_hook (bfd *abfd,
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  sgot = bfd_get_linker_section (dynobj, ".got");
-  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  sgot = htab->root.sgot;
+  srelgot = htab->root.srelgot;
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -2755,13 +2749,11 @@ elf_cris_adjust_gotplt_to_got (struct elf_cris_link_hash_entry *h, void * p)
   else
     {
       /* No GOT entry for this symbol.  We need to create one.  */
-      bfd *dynobj = elf_hash_table (info)->dynobj;
       asection *sgot;
       asection *srelgot;
 
-      BFD_ASSERT (dynobj != NULL);
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srelgot = elf_hash_table (info)->srelgot;
 
       /* Put accurate refcounts there.  */
       h->root.got.refcount += h->gotplt_refcount;
@@ -2868,7 +2860,7 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
@@ -2936,7 +2928,7 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
            return FALSE;
        }
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = htab->root.splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -2995,13 +2987,13 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
        = htab->next_gotplt_entry;
       htab->next_gotplt_entry += 4;
 
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = htab->root.sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = htab->root.srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -3260,7 +3252,8 @@ cris_elf_check_relocs (bfd *abfd,
              if (!_bfd_elf_create_got_section (dynobj, info))
                return FALSE;
 
-             sgot = bfd_get_linker_section (dynobj, ".got");
+             sgot = elf_hash_table (info)->sgot;
+             srelgot = elf_hash_table (info)->srelgot;
            }
 
          if (local_got_refcounts == NULL)
@@ -3285,62 +3278,6 @@ cris_elf_check_relocs (bfd *abfd,
          break;
        }
 
-      /* Some relocs require a global offset table (but perhaps not a
-        specific GOT entry).  */
-      switch (r_type)
-       {
-       case R_CRIS_16_DTPREL:
-       case R_CRIS_32_DTPREL:
-         /* Not requesting .got.rela for an executable: the contents
-            of the first entry is constant there.  For a shared
-            library, we need .got.rela for the R_CRIS_DTPMOD
-            relocation at index 3.  */
-         if (!bfd_link_pic (info))
-           break;
-         /* Fall through.  */
-
-       case R_CRIS_32_IE:
-       case R_CRIS_32_GD:
-       case R_CRIS_16_GOT_GD:
-       case R_CRIS_32_GOT_GD:
-       case R_CRIS_32_GOT_TPREL:
-       case R_CRIS_16_GOT_TPREL:
-         /* Fall through.  */
-
-         /* For R_CRIS_16_GOTPLT and R_CRIS_32_GOTPLT, we need a GOT
-            entry only for local symbols.  Unfortunately, we don't know
-            until later on if there's a version script that forces the
-            symbol local.  We must have the .rela.got section in place
-            before we know if the symbol looks global now, so we need
-            to treat the reloc just like for R_CRIS_16_GOT and
-            R_CRIS_32_GOT.  */
-       case R_CRIS_16_GOTPLT:
-       case R_CRIS_32_GOTPLT:
-       case R_CRIS_16_GOT:
-       case R_CRIS_32_GOT:
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
-         break;
-
-       default:
-         break;
-       }
-
       /* Warn and error for invalid input.  */
       switch (r_type)
        {
@@ -3769,10 +3706,10 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
   BFD_ASSERT (dynobj != NULL);
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
@@ -3794,7 +3731,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         not actually use these entries.  Reset the size of .rela.got,
         which will cause it to get stripped from the output file
         below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = htab->root.srelgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -4029,12 +3966,9 @@ elf_cris_discard_excess_program_dynamics (struct elf_cris_link_hash_entry *h,
          && elf_hash_table (info)->dynamic_sections_created)
        {
          bfd *dynobj = elf_hash_table (info)->dynobj;
-         asection *srelgot;
+         asection *srelgot = elf_hash_table (info)->srelgot;
 
          BFD_ASSERT (dynobj != NULL);
-
-         srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-
          BFD_ASSERT (srelgot != NULL);
 
          srelgot->size -= sizeof (Elf32_External_Rela);
index a84ca7acc96b2d2b33ca969722b13181f2e68d20..fa585433fb4cc424f6c08613d52255236e699343 100644 (file)
@@ -805,16 +805,8 @@ struct frvfdpic_elf_link_hash_table
 {
   struct elf_link_hash_table elf;
 
-  /* A pointer to the .got section.  */
-  asection *sgot;
-  /* A pointer to the .rel.got section.  */
-  asection *sgotrel;
   /* A pointer to the .rofixup section.  */
   asection *sgotfixup;
-  /* A pointer to the .plt section.  */
-  asection *splt;
-  /* A pointer to the .rel.plt section.  */
-  asection *spltrel;
   /* GOT base offset.  */
   bfd_vma got0;
   /* Location of the first non-lazy PLT entry, i.e., the number of
@@ -837,15 +829,15 @@ struct frvfdpic_elf_link_hash_table
   == FRV_ELF_DATA ? ((struct frvfdpic_elf_link_hash_table *) ((p)->hash)) : NULL)
 
 #define frvfdpic_got_section(info) \
-  (frvfdpic_hash_table (info)->sgot)
+  (frvfdpic_hash_table (info)->elf.sgot)
 #define frvfdpic_gotrel_section(info) \
-  (frvfdpic_hash_table (info)->sgotrel)
+  (frvfdpic_hash_table (info)->elf.srelgot)
 #define frvfdpic_gotfixup_section(info) \
   (frvfdpic_hash_table (info)->sgotfixup)
 #define frvfdpic_plt_section(info) \
-  (frvfdpic_hash_table (info)->splt)
+  (frvfdpic_hash_table (info)->elf.splt)
 #define frvfdpic_pltrel_section(info) \
-  (frvfdpic_hash_table (info)->spltrel)
+  (frvfdpic_hash_table (info)->elf.srelplt)
 #define frvfdpic_relocs_info(info) \
   (frvfdpic_hash_table (info)->relocs_info)
 #define frvfdpic_got_initial_offset(info) \
@@ -4175,7 +4167,7 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
   int offset;
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
+  s = elf_hash_table (info)->sgot;
   if (s != NULL)
     return TRUE;
 
@@ -4190,18 +4182,11 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
   pltflags = flags;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
+  elf_hash_table (info)->sgot = s;
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (bed->want_got_plt)
-    {
-      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
-      if (s == NULL
-         || !bfd_set_section_alignment (abfd, s, ptralign))
-       return FALSE;
-    }
-
   if (bed->want_got_sym)
     {
       /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
@@ -4226,7 +4211,6 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
      data for the got.  */
   if (IS_FDPIC (abfd))
     {
-      frvfdpic_got_section (info) = s;
       frvfdpic_relocs_info (info) = htab_try_create (1,
                                                     frvfdpic_relocs_info_hash,
                                                     frvfdpic_relocs_info_eq,
@@ -4236,12 +4220,11 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
 
       s = bfd_make_section_anyway_with_flags (abfd, ".rel.got",
                                              (flags | SEC_READONLY));
+      elf_hash_table (info)->srelgot = s;
       if (s == NULL
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
-      frvfdpic_gotrel_section (info) = s;
-
       /* Machine-specific.  */
       s = bfd_make_section_anyway_with_flags (abfd, ".rofixup",
                                              (flags | SEC_READONLY));
index 55aec83831efced6c299e4f8796984c862abf4c5..63e9e69bea04397607b82fb5c4826629d2c8147b 100644 (file)
@@ -275,10 +275,6 @@ struct elf32_hppa_link_hash_table
   Elf_Internal_Sym **all_local_syms;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -780,9 +776,9 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
 
       off &= ~ (bfd_vma) 1;
       sym_value = (off
-                  + htab->splt->output_offset
-                  + htab->splt->output_section->vma
-                  - elf_gp (htab->splt->output_section->owner));
+                  + htab->etab.splt->output_offset
+                  + htab->etab.splt->output_section->vma
+                  - elf_gp (htab->etab.splt->output_section->owner));
 
       insn = ADDIL_DP;
 #if R19_STUBS
@@ -995,19 +991,13 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   htab = hppa_link_hash_table (info);
   if (htab == NULL)
     return FALSE;
-  if (htab->splt != NULL)
+  if (htab->etab.splt != NULL)
     return TRUE;
 
   /* Call the generic code to do most of the work.  */
   if (! _bfd_elf_create_dynamic_sections (abfd, info))
     return FALSE;
 
-  htab->splt = bfd_get_linker_section (abfd, ".plt");
-  htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
-
-  htab->sgot = bfd_get_linker_section (abfd, ".got");
-  htab->srelgot = bfd_get_linker_section (abfd, ".rela.got");
-
   htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
   htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
 
@@ -1359,7 +1349,7 @@ elf32_hppa_check_relocs (bfd *abfd,
 
          /* Allocate space for a GOT entry, as well as a dynamic
             relocation for this entry.  */
-         if (htab->sgot == NULL)
+         if (htab->etab.sgot == NULL)
            {
              if (!elf32_hppa_create_dynamic_sections (htab->etab.dynobj, info))
                return FALSE;
@@ -1973,7 +1963,7 @@ allocate_plt_static (struct elf_link_hash_entry *eh, void *inf)
        {
          /* Make an entry in the .plt section for plabel references
             that won't have a .plt entry for other reasons.  */
-         sec = htab->splt;
+         sec = htab->etab.splt;
          eh->plt.offset = sec->size;
          sec->size += PLT_ENTRY_SIZE;
        }
@@ -2021,12 +2011,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
       && eh->plt.refcount > 0)
     {
       /* Make an entry in the .plt section.  */
-      sec = htab->splt;
+      sec = htab->etab.splt;
       eh->plt.offset = sec->size;
       sec->size += PLT_ENTRY_SIZE;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      htab->srelplt->size += sizeof (Elf32_External_Rela);
+      htab->etab.srelplt->size += sizeof (Elf32_External_Rela);
       htab->need_plt_stub = 1;
     }
 
@@ -2042,7 +2032,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
            return FALSE;
        }
 
-      sec = htab->sgot;
+      sec = htab->etab.sgot;
       eh->got.offset = sec->size;
       sec->size += GOT_ENTRY_SIZE;
       /* R_PARISC_TLS_GD* needs two GOT entries */
@@ -2055,11 +2045,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
              || (eh->dynindx != -1
                  && !eh->forced_local)))
        {
-         htab->srelgot->size += sizeof (Elf32_External_Rela);
+         htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
          if ((hh->tls_type & (GOT_TLS_GD | GOT_TLS_IE)) == (GOT_TLS_GD | GOT_TLS_IE))
-           htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+           htab->etab.srelgot->size += 2 * sizeof (Elf32_External_Rela);
          else if ((hh->tls_type & GOT_TLS_GD) == GOT_TLS_GD)
-           htab->srelgot->size += sizeof (Elf32_External_Rela);
+           htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
        }
     }
   else
@@ -2290,8 +2280,8 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
       local_tls_type = hppa_elf_local_got_tls_type (ibfd);
-      sec = htab->sgot;
-      srel = htab->srelgot;
+      sec = htab->etab.sgot;
+      srel = htab->etab.srelgot;
       for (; local_got < end_local_got; ++local_got)
        {
          if (*local_got > 0)
@@ -2327,8 +2317,8 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
       else
        {
-         sec = htab->splt;
-         srel = htab->srelplt;
+         sec = htab->etab.splt;
+         srel = htab->etab.srelplt;
          for (; local_plt < end_local_plt; ++local_plt)
            {
              if (*local_plt > 0)
@@ -2348,9 +2338,9 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       /* Allocate 2 got entries and 1 dynamic reloc for
          R_PARISC_TLS_DTPMOD32 relocs.  */
-      htab->tls_ldm_got.offset = htab->sgot->size;
-      htab->sgot->size += (GOT_ENTRY_SIZE * 2);
-      htab->srelgot->size += sizeof (Elf32_External_Rela);
+      htab->tls_ldm_got.offset = htab->etab.sgot->size;
+      htab->etab.sgot->size += (GOT_ENTRY_SIZE * 2);
+      htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
@@ -2373,14 +2363,14 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((sec->flags & SEC_LINKER_CREATED) == 0)
        continue;
 
-      if (sec == htab->splt)
+      if (sec == htab->etab.splt)
        {
          if (htab->need_plt_stub)
            {
              /* Make space for the plt stub at the end of the .plt
                 section.  We want this stub right at the end, up
                 against the .got section.  */
-             int gotalign = bfd_section_alignment (dynobj, htab->sgot);
+             int gotalign = bfd_section_alignment (dynobj, htab->etab.sgot);
              int pltalign = bfd_section_alignment (dynobj, sec);
              bfd_size_type mask;
 
@@ -2390,7 +2380,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
              sec->size = (sec->size + sizeof (plt_stub) + mask) & ~mask;
            }
        }
-      else if (sec == htab->sgot
+      else if (sec == htab->etab.sgot
               || sec == htab->sdynbss)
        ;
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, sec), ".rela"))
@@ -2399,7 +2389,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            {
              /* Remember whether there are any reloc sections other
                 than .rela.plt.  */
-             if (sec != htab->srelplt)
+             if (sec != htab->etab.srelplt)
                relocs = TRUE;
 
              /* We use the reloc_count field as a counter if we need
@@ -2461,7 +2451,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-      if (htab->srelplt->size != 0)
+      if (htab->etab.srelplt->size != 0)
        {
          if (!add_dynamic_entry (DT_PLTRELSZ, 0)
              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
@@ -3824,11 +3814,11 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                       object because the symbol index is zero.  */
                    Elf_Internal_Rela outrel;
                    bfd_byte *loc;
-                   asection *sec = htab->srelgot;
+                   asection *sec = htab->etab.srelgot;
 
                    outrel.r_offset = (off
-                                      + htab->sgot->output_offset
-                                      + htab->sgot->output_section->vma);
+                                      + htab->etab.sgot->output_offset
+                                      + htab->etab.sgot->output_section->vma);
                    outrel.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
                    outrel.r_addend = relocation;
                    loc = sec->contents;
@@ -3837,7 +3827,7 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                  }
                else
                  bfd_put_32 (output_bfd, relocation,
-                             htab->sgot->contents + off);
+                             htab->etab.sgot->contents + off);
              }
 
            if (off >= (bfd_vma) -2)
@@ -3845,8 +3835,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
 
            /* Add the base of the GOT to the relocation value.  */
            relocation = (off
-                         + htab->sgot->output_offset
-                         + htab->sgot->output_section->vma);
+                         + htab->etab.sgot->output_offset
+                         + htab->etab.sgot->output_section->vma);
          }
          break;
 
@@ -3915,11 +3905,11 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                         PLT entry.  */
                      Elf_Internal_Rela outrel;
                      bfd_byte *loc;
-                     asection *s = htab->srelplt;
+                     asection *s = htab->etab.srelplt;
 
                      outrel.r_offset = (off
-                                        + htab->splt->output_offset
-                                        + htab->splt->output_section->vma);
+                                        + htab->etab.splt->output_offset
+                                        + htab->etab.splt->output_section->vma);
                      outrel.r_info = ELF32_R_INFO (0, R_PARISC_IPLT);
                      outrel.r_addend = relocation;
                      loc = s->contents;
@@ -3930,10 +3920,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                    {
                      bfd_put_32 (output_bfd,
                                  relocation,
-                                 htab->splt->contents + off);
+                                 htab->etab.splt->contents + off);
                      bfd_put_32 (output_bfd,
-                                 elf_gp (htab->splt->output_section->owner),
-                                 htab->splt->contents + off + 4);
+                                 elf_gp (htab->etab.splt->output_section->owner),
+                                 htab->etab.splt->contents + off + 4);
                    }
                }
 
@@ -3951,8 +3941,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                      && hh->eh.root.type != bfd_link_hash_undefined))
                {
                  relocation = (off
-                               + htab->splt->output_offset
-                               + htab->splt->output_section->vma
+                               + htab->etab.splt->output_offset
+                               + htab->etab.splt->output_section->vma
                                + 2);
                }
              plabel = 1;
@@ -4093,12 +4083,12 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                bfd_byte *loc;
 
                outrel.r_offset = (off
-                                  + htab->sgot->output_section->vma
-                                  + htab->sgot->output_offset);
+                                  + htab->etab.sgot->output_section->vma
+                                  + htab->etab.sgot->output_offset);
                outrel.r_addend = 0;
                outrel.r_info = ELF32_R_INFO (0, R_PARISC_TLS_DTPMOD32);
-               loc = htab->srelgot->contents;
-               loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+               loc = htab->etab.srelgot->contents;
+               loc += htab->etab.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
 
                bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
                htab->tls_ldm_got.offset |= 1;
@@ -4106,8 +4096,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
 
            /* Add the base of the GOT to the relocation value.  */
            relocation = (off
-                         + htab->sgot->output_offset
-                         + htab->sgot->output_section->vma);
+                         + htab->etab.sgot->output_offset
+                         + htab->etab.sgot->output_section->vma);
 
            break;
          }
@@ -4171,9 +4161,9 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                        || hh->eh.root.type != bfd_link_hash_undefweak))
                  {
                    need_relocs = TRUE;
-                   loc = htab->srelgot->contents;
+                   loc = htab->etab.srelgot->contents;
                    /* FIXME (CAO): Should this be reloc_count++ ? */
-                   loc += htab->srelgot->reloc_count * sizeof (Elf32_External_Rela);
+                   loc += htab->etab.srelgot->reloc_count * sizeof (Elf32_External_Rela);
                  }
 
                if (tls_type & GOT_TLS_GD)
@@ -4181,26 +4171,26 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                    if (need_relocs)
                      {
                        outrel.r_offset = (cur_off
-                                          + htab->sgot->output_section->vma
-                                          + htab->sgot->output_offset);
+                                          + htab->etab.sgot->output_section->vma
+                                          + htab->etab.sgot->output_offset);
                        outrel.r_info = ELF32_R_INFO (indx,R_PARISC_TLS_DTPMOD32);
                        outrel.r_addend = 0;
-                       bfd_put_32 (output_bfd, 0, htab->sgot->contents + cur_off);
+                       bfd_put_32 (output_bfd, 0, htab->etab.sgot->contents + cur_off);
                        bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
-                       htab->srelgot->reloc_count++;
+                       htab->etab.srelgot->reloc_count++;
                        loc += sizeof (Elf32_External_Rela);
 
                        if (indx == 0)
                          bfd_put_32 (output_bfd, relocation - dtpoff_base (info),
-                                     htab->sgot->contents + cur_off + 4);
+                                     htab->etab.sgot->contents + cur_off + 4);
                        else
                          {
                            bfd_put_32 (output_bfd, 0,
-                                       htab->sgot->contents + cur_off + 4);
+                                       htab->etab.sgot->contents + cur_off + 4);
                            outrel.r_info = ELF32_R_INFO (indx, R_PARISC_TLS_DTPOFF32);
                            outrel.r_offset += 4;
                            bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);
-                           htab->srelgot->reloc_count++;
+                           htab->etab.srelgot->reloc_count++;
                            loc += sizeof (Elf32_External_Rela);
                          }
                      }
@@ -4212,9 +4202,9 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                           symbol binding locally.  Mark it as belonging
                           to module 1, the executable.  */
                        bfd_put_32 (output_bfd, 1,
-                                   htab->sgot->contents + cur_off);
+                                   htab->etab.sgot->contents + cur_off);
                        bfd_put_32 (output_bfd, relocation - dtpoff_base (info),
-                                   htab->sgot->contents + cur_off + 4);
+                                   htab->etab.sgot->contents + cur_off + 4);
                      }
 
 
@@ -4226,8 +4216,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                    if (need_relocs)
                      {
                        outrel.r_offset = (cur_off
-                                          + htab->sgot->output_section->vma
-                                          + htab->sgot->output_offset);
+                                          + htab->etab.sgot->output_section->vma
+                                          + htab->etab.sgot->output_offset);
                        outrel.r_info = ELF32_R_INFO (indx, R_PARISC_TLS_TPREL32);
 
                        if (indx == 0)
@@ -4236,12 +4226,12 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                          outrel.r_addend = 0;
 
                        bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
-                       htab->srelgot->reloc_count++;
+                       htab->etab.srelgot->reloc_count++;
                        loc += sizeof (Elf32_External_Rela);
                      }
                    else
                      bfd_put_32 (output_bfd, tpoff (info, relocation),
-                                 htab->sgot->contents + cur_off);
+                                 htab->etab.sgot->contents + cur_off);
 
                    cur_off += 4;
                  }
@@ -4259,8 +4249,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
 
            /* Add the base of the GOT to the relocation value.  */
            relocation = (off
-                         + htab->sgot->output_offset
-                         + htab->sgot->output_section->vma);
+                         + htab->etab.sgot->output_offset
+                         + htab->etab.sgot->output_section->vma);
 
            break;
          }
@@ -4366,8 +4356,8 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
 
       /* Create a dynamic IPLT relocation for this entry.  */
       rela.r_offset = (eh->plt.offset
-                     + htab->splt->output_offset
-                     + htab->splt->output_section->vma);
+                     + htab->etab.splt->output_offset
+                     + htab->etab.splt->output_section->vma);
       if (eh->dynindx != -1)
        {
          rela.r_info = ELF32_R_INFO (eh->dynindx, R_PARISC_IPLT);
@@ -4381,9 +4371,9 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
          rela.r_addend = value;
        }
 
-      loc = htab->srelplt->contents;
-      loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
-      bfd_elf32_swap_reloca_out (htab->splt->output_section->owner, &rela, loc);
+      loc = htab->etab.srelplt->contents;
+      loc += htab->etab.srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (htab->etab.splt->output_section->owner, &rela, loc);
 
       if (!eh->def_regular)
        {
@@ -4401,8 +4391,8 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
         up.  */
 
       rela.r_offset = ((eh->got.offset &~ (bfd_vma) 1)
-                     + htab->sgot->output_offset
-                     + htab->sgot->output_section->vma);
+                     + htab->etab.sgot->output_offset
+                     + htab->etab.sgot->output_section->vma);
 
       /* If this is a -Bsymbolic link and the symbol is defined
         locally or was forced to be local because of a version file,
@@ -4423,13 +4413,13 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
          if ((eh->got.offset & 1) != 0)
            abort ();
 
-         bfd_put_32 (output_bfd, 0, htab->sgot->contents + (eh->got.offset & ~1));
+         bfd_put_32 (output_bfd, 0, htab->etab.sgot->contents + (eh->got.offset & ~1));
          rela.r_info = ELF32_R_INFO (eh->dynindx, R_PARISC_DIR32);
          rela.r_addend = 0;
        }
 
-      loc = htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+      loc = htab->etab.srelgot->contents;
+      loc += htab->etab.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
@@ -4514,7 +4504,7 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = htab->etab.dynobj;
 
-  sgot = htab->sgot;
+  sgot = htab->etab.sgot;
   /* A broken linker script might have discarded the dynamic sections.
      Catch this here so that we do not seg-fault later on.  */
   if (sgot != NULL && bfd_is_abs_section (sgot->output_section))
@@ -4549,19 +4539,19 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_JMPREL:
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              break;
 
            case DT_PLTRELSZ:
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              dyn.d_un.d_val = s->size;
              break;
 
            case DT_RELASZ:
              /* Don't count procedure linkage table relocs in the
                 overall reloc count.  */
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              if (s == NULL)
                continue;
              dyn.d_un.d_val -= s->size;
@@ -4571,7 +4561,7 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
              /* We may not be using the standard ELF linker script.
                 If .rela.plt is the first .rela section, we adjust
                 DT_RELA to not include it.  */
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              if (s == NULL)
                continue;
              if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
@@ -4600,23 +4590,23 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
        ->this_hdr.sh_entsize = GOT_ENTRY_SIZE;
     }
 
-  if (htab->splt != NULL && htab->splt->size != 0)
+  if (htab->etab.splt != NULL && htab->etab.splt->size != 0)
     {
       /* Set plt entry size to 0 instead of PLT_ENTRY_SIZE, since we add the
         plt stubs and as such the section does not hold a table of fixed-size
         entries.  */
-      elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize = 0;
+      elf_section_data (htab->etab.splt->output_section)->this_hdr.sh_entsize = 0;
 
       if (htab->need_plt_stub)
        {
          /* Set up the .plt stub.  */
-         memcpy (htab->splt->contents
-                 + htab->splt->size - sizeof (plt_stub),
+         memcpy (htab->etab.splt->contents
+                 + htab->etab.splt->size - sizeof (plt_stub),
                  plt_stub, sizeof (plt_stub));
 
-         if ((htab->splt->output_offset
-              + htab->splt->output_section->vma
-              + htab->splt->size)
+         if ((htab->etab.splt->output_offset
+              + htab->etab.splt->output_section->vma
+              + htab->etab.splt->size)
              != (sgot->output_offset
                  + sgot->output_section->vma))
            {
index 7427995bd31ab8e330bc9f7a1be7b47626125ca7..940fc9dacedd6d172c4ba691ed33d1976f81fcd1 100644 (file)
@@ -884,7 +884,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
 {
   asection *sdyn;
   bfd *dynobj = elf_hash_table (info)->dynobj;
-  asection *sgot = bfd_get_linker_section (dynobj, ".got");
+  asection *sgot = elf_hash_table (info)->sgot;
 
 #ifdef DEBUG
   fprintf (stderr, "i370_elf_finish_dynamic_sections called\n");
@@ -897,7 +897,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -905,35 +905,39 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd,
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char *name;
+         asection *s;
          bfd_boolean size;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
 
          switch (dyn.d_tag)
            {
-           case DT_PLTGOT:   name = ".plt";      size = FALSE; break;
-           case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE;  break;
-           case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break;
-           default:          name = NULL;        size = FALSE; break;
+           case DT_PLTGOT:
+             s = elf_hash_table (info)->splt;
+             size = FALSE;
+             break;
+           case DT_PLTRELSZ:
+             s = elf_hash_table (info)->srelplt;
+             size = TRUE;
+             break;
+           case DT_JMPREL:
+             s = elf_hash_table (info)->srelplt;
+             size = FALSE;
+             break;
+           default:
+             continue;
            }
 
-         if (name != NULL)
+         if (s == NULL)
+           dyn.d_un.d_val = 0;
+         else
            {
-             asection *s;
-
-             s = bfd_get_linker_section (dynobj, name);
-             if (s == NULL)
-               dyn.d_un.d_val = 0;
+             if (!size)
+               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              else
-               {
-                 if (! size)
-                   dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
-                 else
-                   dyn.d_un.d_val = s->size;
-               }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+               dyn.d_un.d_val = s->size;
            }
+         bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
        }
     }
 
index 3729503b409e8be513684bea97c41b751fdc43fa..405768cf228f5e809f81f076334659ce90c3ff3a 100644 (file)
@@ -87,12 +87,7 @@ struct elf_lm32_link_hash_table
   struct elf_link_hash_table root;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
   asection *sfixup32;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -106,9 +101,9 @@ struct elf_lm32_link_hash_table
   == LM32_ELF_DATA ? ((struct elf_lm32_link_hash_table *) ((p)->hash)) : NULL)
 
 #define lm32fdpic_got_section(info) \
-  (lm32_elf_hash_table (info)->sgot)
+  (lm32_elf_hash_table (info)->root.sgot)
 #define lm32fdpic_gotrel_section(info) \
-  (lm32_elf_hash_table (info)->srelgot)
+  (lm32_elf_hash_table (info)->root.srelgot)
 #define lm32fdpic_fixup32_section(info) \
   (lm32_elf_hash_table (info)->sfixup32)
 
@@ -197,36 +192,6 @@ _lm32fdpic_add_rofixup (bfd *output_bfd, asection *rofixup, bfd_vma relocation)
   return fixup_offset;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf_lm32_link_hash_table *htab;
-  asection *s;
-
-  /* This function may be called more than once.  */
-  s = bfd_get_linker_section (dynobj, ".got");
-  if (s != NULL)
-    return TRUE;
-
-  htab = lm32_elf_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab->sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
-    abort ();
-
-  return TRUE;
-}
-
 /* Create .rofixup sections in DYNOBJ, and set up
    shortcuts to them in our hash table.  */
 
@@ -823,17 +788,15 @@ lm32_elf_relocate_section (bfd *output_bfd,
   struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
   Elf_Internal_Rela *rel, *relend;
   struct elf_lm32_link_hash_table *htab = lm32_elf_hash_table (info);
-  bfd *dynobj;
   bfd_vma *local_got_offsets;
   asection *sgot;
 
   if (htab == NULL)
     return FALSE;
 
-  dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -1029,8 +992,7 @@ lm32_elf_relocate_section (bfd *output_bfd,
 
                           /* We need to generate a R_LM32_RELATIVE reloc
                              for the dynamic linker.  */
-                          srelgot = bfd_get_linker_section (dynobj,
-                                                           ".rela.got");
+                          srelgot = htab->root.srelgot;
                           BFD_ASSERT (srelgot != NULL);
 
                           outrel.r_offset = (sgot->output_section->vma
@@ -1314,7 +1276,7 @@ lm32_elf_check_relocs (bfd *abfd,
        }
 
       /* Some relocs require a global offset table.  */
-      if (htab->sgot == NULL)
+      if (htab->root.sgot == NULL)
         {
           switch (r_type)
             {
@@ -1323,7 +1285,7 @@ lm32_elf_check_relocs (bfd *abfd,
             case R_LM32_GOTOFF_LO16:
               if (dynobj == NULL)
                 htab->root.dynobj = dynobj = abfd;
-              if (! create_got_section (dynobj, info))
+              if (!_bfd_elf_create_got_section (dynobj, info))
                 return FALSE;
               break;
             }
@@ -1339,7 +1301,7 @@ lm32_elf_check_relocs (bfd *abfd,
                  (Normal ELF doesn't). */
               if (dynobj == NULL)
                 htab->root.dynobj = dynobj = abfd;
-              if (! create_got_section (dynobj, info))
+              if (!_bfd_elf_create_got_section (dynobj, info))
                 return FALSE;
               /* Create .rofixup section */
               if (htab->sfixup32 == NULL)
@@ -1426,7 +1388,7 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = htab->root.dynobj;
 
-  sgot = htab->sgotplt;
+  sgot = htab->root.sgotplt;
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
@@ -1452,17 +1414,17 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
               break;
 
             case DT_PLTGOT:
-              s = htab->sgotplt;
+              s = htab->root.sgotplt;
               goto get_vma;
             case DT_JMPREL:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
             get_vma:
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
 
             case DT_PLTRELSZ:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
              dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
@@ -1477,9 +1439,9 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
                  the linker script arranges for .rela.plt to follow all
                  other relocation sections, we don't have to worry
                  about changing the DT_RELA entry.  */
-              if (htab->srelplt != NULL)
+              if (htab->root.srelplt != NULL)
                 {
-                  s = htab->srelplt;
+                  s = htab->root.srelplt;
                  dyn.d_un.d_val -= s->size;
                 }
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -1488,7 +1450,7 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
         }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->root.splt;
       if (splt && splt->size > 0)
         {
           if (bfd_link_pic (info))
@@ -1614,9 +1576,9 @@ lm32_elf_finish_dynamic_symbol (bfd *output_bfd,
          it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      sgot = htab->sgotplt;
-      srela = htab->srelplt;
+      splt = htab->root.splt;
+      sgot = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -1675,8 +1637,8 @@ lm32_elf_finish_dynamic_symbol (bfd *output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
-      sgot = htab->sgot;
-      srela = htab->srelgot;
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -1930,7 +1892,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
         {
-          asection *s = htab->splt;
+          asection *s = htab->root.splt;
 
           /* If this is the first .plt entry, make room for the special
              first entry.  */
@@ -1956,10 +1918,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
           /* We also need to make an entry in the .got.plt section, which
              will be placed in the .got section by the linker script.  */
-          htab->sgotplt->size += 4;
+          htab->root.sgotplt->size += 4;
 
           /* We also need to make an entry in the .rel.plt section.  */
-          htab->srelplt->size += sizeof (Elf32_External_Rela);
+          htab->root.srelplt->size += sizeof (Elf32_External_Rela);
         }
       else
         {
@@ -1987,13 +1949,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
             return FALSE;
         }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
 
       h->got.offset = s->size;
       s->size += 4;
       dyn = htab->root.dynamic_sections_created;
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
-        htab->srelgot->size += sizeof (Elf32_External_Rela);
+        htab->root.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) -1;
@@ -2191,8 +2153,8 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
       symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
       for (; local_got < end_local_got; ++local_got)
         {
           if (*local_got > 0)
@@ -2219,9 +2181,9 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
         continue;
 
-      if (s == htab->splt
-          || s == htab->sgot
-          || s == htab->sgotplt
+      if (s == htab->root.splt
+          || s == htab->root.sgot
+          || s == htab->root.sgotplt
          || s == htab->sdynbss)
         {
           /* Strip this section if we don't need it; see the
@@ -2229,7 +2191,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
         }
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
         {
-          if (s->size != 0 && s != htab->srelplt)
+          if (s->size != 0 && s != htab->root.srelplt)
             relocs = TRUE;
 
           /* We use the reloc_count field as a counter if we need
@@ -2284,7 +2246,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
            return FALSE;
        }
 
-      if (htab->splt->size != 0)
+      if (htab->root.splt->size != 0)
         {
           if (! add_dynamic_entry (DT_PLTGOT, 0)
               || ! add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2429,7 +2391,8 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
         }
 
       /* Size sections.  */
-      lm32fdpic_fixup32_section (info)->size = (r32_count + (htab->sgot->size / 4) - rgot_weak_count + 1) * 4;
+      lm32fdpic_fixup32_section (info)->size
+       = (r32_count + (htab->root.sgot->size / 4) - rgot_weak_count + 1) * 4;
       if (lm32fdpic_fixup32_section (info)->size == 0)
         lm32fdpic_fixup32_section (info)->flags |= SEC_EXCLUDE;
       else
@@ -2461,7 +2424,7 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   /* Make sure we have a GOT - For the case where we have a dynamic object
      but none of the relocs in check_relocs */
-  if (! create_got_section (abfd, info))
+  if (!_bfd_elf_create_got_section (abfd, info))
     return FALSE;
   if (IS_FDPIC (abfd) && (htab->sfixup32 == NULL))
     {
@@ -2482,7 +2445,7 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     pltflags |= SEC_READONLY;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
-  htab->splt = s;
+  htab->root.splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -2513,13 +2476,13 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                                          bed->default_use_rela_p
                                          ? ".rela.plt" : ".rel.plt",
                                          flags | SEC_READONLY);
-  htab->srelplt = s;
+  htab->root.srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (htab->sgot == NULL
-      && ! create_got_section (abfd, info))
+  if (htab->root.sgot == NULL
+      && !_bfd_elf_create_got_section (abfd, info))
     return FALSE;
 
   if (bed->want_dynbss)
index 44fcc24980e8f6eb44941873e67c571cb69c94a7..c49de8443a0f21fd2342b6e34207c70cd464cf95 100644 (file)
@@ -400,17 +400,13 @@ m32c_elf_relocate_section
   struct elf_link_hash_entry ** sym_hashes;
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
-  bfd *dynobj;
   asection *splt;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
-  dynobj = elf_hash_table (info)->dynobj;
-  splt = NULL;
-  if (dynobj != NULL)
-    splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -704,20 +700,18 @@ m32c_elf_check_relocs
        case R_M32C_16:
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
+         splt = elf_hash_table (info)->splt;
          if (splt == NULL)
            {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             if (splt == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY | SEC_CODE);
-                 splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
-                                                            flags);
-                 if (splt == NULL
-                     || ! bfd_set_section_alignment (dynobj, splt, 1))
-                   return FALSE;
-               }
+             flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                               | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                               | SEC_READONLY | SEC_CODE);
+             splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+                                                        flags);
+             elf_hash_table (info)->splt = splt;
+             if (splt == NULL
+                 || ! bfd_set_section_alignment (dynobj, splt, 1))
+               return FALSE;
            }
 
          if (h != NULL)
@@ -759,14 +753,13 @@ static bfd_boolean
 m32c_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
                                   struct bfd_link_info *info)
 {
-  bfd *dynobj;
-  asection *splt;
+  bfd *dynobj = elf_hash_table (info)->dynobj;
+  asection *splt = elf_hash_table (info)->splt;
 
   /* As an extra sanity check, verify that all plt entries have
      been filled in.  */
 
-  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
+  if (dynobj != NULL && splt != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
@@ -794,7 +787,7 @@ m32c_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
   BFD_ASSERT (splt != NULL);
 
   splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
index 4cf5b56c5a87cffcd68bff6f425770bc3b31a490..9d1492553b856ed60fd1f7417d017910b91dd623 100644 (file)
@@ -1523,11 +1523,6 @@ struct elf_m32r_link_hash_table
   struct elf_link_hash_table root;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -1606,30 +1601,6 @@ m32r_elf_link_hash_table_create (bfd *abfd)
   return &ret->root.root;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf_m32r_link_hash_table *htab;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab = m32r_elf_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  htab->sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
-    abort ();
-
-  return TRUE;
-}
-
 /* Create dynamic sections when linking against a dynamic object.  */
 
 static bfd_boolean
@@ -1658,7 +1629,7 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     pltflags |= SEC_READONLY;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
-  htab->splt = s;
+  htab->root.splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -1689,13 +1660,13 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                                          bed->default_use_rela_p
                                          ? ".rela.plt" : ".rel.plt",
                                          flags | SEC_READONLY);
-  htab->srelplt = s;
+  htab->root.srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (htab->sgot == NULL
-      && ! create_got_section (abfd, info))
+  if (htab->root.sgot == NULL
+      && !_bfd_elf_create_got_section (abfd, info))
     return FALSE;
 
   if (bed->want_dynbss)
@@ -1962,7 +1933,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
         {
-          asection *s = htab->splt;
+          asection *s = htab->root.splt;
 
           /* If this is the first .plt entry, make room for the special
              first entry.  */
@@ -1988,10 +1959,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
           /* We also need to make an entry in the .got.plt section, which
              will be placed in the .got section by the linker script.  */
-          htab->sgotplt->size += 4;
+          htab->root.sgotplt->size += 4;
 
           /* We also need to make an entry in the .rel.plt section.  */
-          htab->srelplt->size += sizeof (Elf32_External_Rela);
+          htab->root.srelplt->size += sizeof (Elf32_External_Rela);
         }
       else
         {
@@ -2019,13 +1990,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
             return FALSE;
         }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
 
       h->got.offset = s->size;
       s->size += 4;
       dyn = htab->root.dynamic_sections_created;
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
-        htab->srelgot->size += sizeof (Elf32_External_Rela);
+        htab->root.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) -1;
@@ -2227,8 +2198,8 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
       for (; local_got < end_local_got; ++local_got)
         {
           if (*local_got > 0)
@@ -2255,9 +2226,9 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
         continue;
 
-      if (s == htab->splt
-          || s == htab->sgot
-          || s == htab->sgotplt
+      if (s == htab->root.splt
+          || s == htab->root.sgot
+          || s == htab->root.sgotplt
          || s == htab->sdynbss)
         {
           /* Strip this section if we don't need it; see the
@@ -2265,7 +2236,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         }
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
         {
-          if (s->size != 0 && s != htab->srelplt)
+          if (s->size != 0 && s != htab->root.srelplt)
             relocs = TRUE;
 
           /* We use the reloc_count field as a counter if we need
@@ -2320,7 +2291,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-      if (htab->splt->size != 0)
+      if (htab->root.splt->size != 0)
         {
           if (! add_dynamic_entry (DT_PLTGOT, 0)
               || ! add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2404,7 +2375,6 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   /* Assume success.  */
   bfd_boolean ret = TRUE;
   struct elf_m32r_link_hash_table *htab = m32r_elf_hash_table (info);
-  bfd *dynobj;
   bfd_vma *local_got_offsets;
   asection *sgot, *splt, *sreloc;
   bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section);
@@ -2412,11 +2382,10 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
 
-  sgot = htab->sgot;
-  splt = htab->splt;
+  sgot = htab->root.sgot;
+  splt = htab->root.splt;
   sreloc = NULL;
 
   rel = relocs;
@@ -2792,8 +2761,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
                           /* We need to generate a R_M32R_RELATIVE reloc
                              for the dynamic linker.  */
-                          srelgot = bfd_get_linker_section (dynobj,
-                                                           ".rela.got");
+                          srelgot = htab->root.srelgot;
                           BFD_ASSERT (srelgot != NULL);
 
                           outrel.r_offset = (sgot->output_section->vma
@@ -3134,9 +3102,9 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      sgot = htab->sgotplt;
-      srela = htab->srelplt;
+      splt = htab->root.splt;
+      sgot = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -3230,8 +3198,8 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd,
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
 
-      sgot = htab->sgot;
-      srela = htab->srelgot;
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -3322,7 +3290,7 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = htab->root.dynobj;
 
-  sgot = htab->sgotplt;
+  sgot = htab->root.sgotplt;
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
@@ -3348,17 +3316,17 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd,
               break;
 
             case DT_PLTGOT:
-              s = htab->sgotplt;
+              s = htab->root.sgotplt;
               goto get_vma;
             case DT_JMPREL:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
             get_vma:
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
 
             case DT_PLTRELSZ:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
              dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
@@ -3373,9 +3341,9 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd,
                  the linker script arranges for .rela.plt to follow all
                  other relocation sections, we don't have to worry
                  about changing the DT_RELA entry.  */
-              if (htab->srelplt != NULL)
+              if (htab->root.srelplt != NULL)
                 {
-                  s = htab->srelplt;
+                  s = htab->root.srelplt;
                  dyn.d_un.d_val -= s->size;
                 }
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -3384,7 +3352,7 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd,
         }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->root.splt;
       if (splt && splt->size > 0)
         {
           if (bfd_link_pic (info))
@@ -3760,7 +3728,7 @@ m32r_elf_check_relocs (bfd *abfd,
        }
 
       /* Some relocs require a global offset table.  */
-      if (htab->sgot == NULL)
+      if (htab->root.sgot == NULL)
         {
           switch (r_type)
             {
@@ -3778,7 +3746,7 @@ m32r_elf_check_relocs (bfd *abfd,
             case R_M32R_GOT24:
               if (dynobj == NULL)
                 htab->root.dynobj = dynobj = abfd;
-              if (! create_got_section (dynobj, info))
+              if (!_bfd_elf_create_got_section (dynobj, info))
                 return FALSE;
               break;
 
index 7c2e0fcca3bfb35d71dc1431c69958c84f04de7b..58df4c9070541b1d2a2fc3b8301602b4cb0686f9 100644 (file)
@@ -2434,7 +2434,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
     {
       asection *s;
 
-      s = bfd_get_linker_section (elf_hash_table (info)->dynobj, ".got");
+      s = elf_hash_table (info)->sgot;
       if (s != NULL)
        s->size = arg_.offset;
       else
@@ -2443,7 +2443,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
       BFD_ASSERT (arg_.slots_relas_diff <= arg_.n_slots);
       arg_.n_slots -= arg_.slots_relas_diff;
 
-      s = bfd_get_linker_section (elf_hash_table (info)->dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = arg_.n_slots * sizeof (Elf32_External_Rela);
       else
@@ -2557,8 +2557,6 @@ elf_m68k_check_relocs (bfd *abfd,
   struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
-  asection *sgot;
-  asection *srelgot;
   asection *sreloc;
   struct elf_m68k_got *got;
 
@@ -2569,8 +2567,6 @@ elf_m68k_check_relocs (bfd *abfd,
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
 
-  sgot = NULL;
-  srelgot = NULL;
   sreloc = NULL;
 
   got = NULL;
@@ -2642,30 +2638,6 @@ elf_m68k_check_relocs (bfd *abfd,
                return FALSE;
            }
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
-
          if (got == NULL)
            {
              struct elf_m68k_bfd2got_entry *bfd2got_entry;
@@ -3105,7 +3077,7 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info,
   asection *s;
 
   htab = elf_m68k_hash_table (info);
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
@@ -3148,7 +3120,7 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info,
            return FALSE;
        }
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = htab->root.splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3175,12 +3147,12 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info,
 
       /* We also need to make an entry in the .got.plt section, which
         will be placed in the .got section by the linker script.  */
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = htab->root.sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = htab->root.srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -3280,7 +3252,7 @@ elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         not actually use these entries.  Reset the size of .rela.got,
         which will cause it to get stripped from the output file
         below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -3617,7 +3589,6 @@ elf_m68k_relocate_section (bfd *output_bfd,
                           Elf_Internal_Sym *local_syms,
                           asection **local_sections)
 {
-  bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   asection *sgot;
@@ -3628,7 +3599,6 @@ elf_m68k_relocate_section (bfd *output_bfd,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
-  dynobj = elf_hash_table (info)->dynobj;
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -3706,21 +3676,16 @@ elf_m68k_relocate_section (bfd *output_bfd,
                  bfd_vma sgot_output_offset;
                  bfd_vma got_offset;
 
-                 if (sgot == NULL)
-                   {
-                     sgot = bfd_get_linker_section (dynobj, ".got");
+                 sgot = elf_hash_table (info)->sgot;
 
-                     if (sgot != NULL)
-                       sgot_output_offset = sgot->output_offset;
-                     else
-                       /* In this case we have a reference to
-                          _GLOBAL_OFFSET_TABLE_, but the GOT itself is
-                          empty.
-                          ??? Issue a warning?  */
-                       sgot_output_offset = 0;
-                   }
-                 else
+                 if (sgot != NULL)
                    sgot_output_offset = sgot->output_offset;
+                 else
+                   /* In this case we have a reference to
+                      _GLOBAL_OFFSET_TABLE_, but the GOT itself is
+                      empty.
+                      ??? Issue a warning?  */
+                   sgot_output_offset = 0;
 
                  if (got == NULL)
                    {
@@ -3781,11 +3746,8 @@ elf_m68k_relocate_section (bfd *output_bfd,
            bfd_vma *off_ptr;
            bfd_vma off;
 
-           if (sgot == NULL)
-             {
-               sgot = bfd_get_linker_section (dynobj, ".got");
-               BFD_ASSERT (sgot != NULL);
-             }
+           sgot = elf_hash_table (info)->sgot;
+           BFD_ASSERT (sgot != NULL);
 
            if (got == NULL)
              {
@@ -3854,11 +3816,8 @@ elf_m68k_relocate_section (bfd *output_bfd,
                else if (bfd_link_pic (info)) /* && h == NULL */
                  /* Process local symbol during dynamic link.  */
                  {
-                   if (srela == NULL)
-                     {
-                       srela = bfd_get_linker_section (dynobj, ".rela.got");
-                       BFD_ASSERT (srela != NULL);
-                     }
+                   srela = elf_hash_table (info)->srelgot;
+                   BFD_ASSERT (srela != NULL);
 
                    elf_m68k_init_got_entry_local_shared (info,
                                                          output_bfd,
@@ -3959,11 +3918,8 @@ elf_m68k_relocate_section (bfd *output_bfd,
              break;
            }
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
          relocation = (splt->output_section->vma
                        + splt->output_offset
@@ -3978,11 +3934,8 @@ elf_m68k_relocate_section (bfd *output_bfd,
             the procedure linkage table.  */
          BFD_ASSERT (h != NULL && h->plt.offset != (bfd_vma) -1);
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
          relocation = h->plt.offset;
          unresolved_reloc = FALSE;
@@ -4260,9 +4213,9 @@ elf_m68k_finish_dynamic_symbol (bfd *output_bfd,
       BFD_ASSERT (h->dynindx != -1);
 
       plt_info = elf_m68k_hash_table (info)->plt_info;
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgot = bfd_get_linker_section (dynobj, ".got.plt");
-      srela = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = elf_hash_table (info)->splt;
+      sgot = elf_hash_table (info)->sgotplt;
+      srela = elf_hash_table (info)->srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -4327,8 +4280,8 @@ elf_m68k_finish_dynamic_symbol (bfd *output_bfd,
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srela = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       got_entry = elf_m68k_hash_entry (h)->glist;
@@ -4477,7 +4430,7 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -4486,7 +4439,7 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -4494,7 +4447,6 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char *name;
          asection *s;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -4505,18 +4457,17 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              break;
 
            case DT_PLTGOT:
-             name = ".got.plt";
+             s = elf_hash_table (info)->sgotplt;
              goto get_vma;
            case DT_JMPREL:
-             name = ".rela.plt";
+             s = elf_hash_table (info)->srelplt;
            get_vma:
-             s = bfd_get_linker_section (dynobj, name);
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -4529,7 +4480,7 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
                 linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s != NULL)
                dyn.d_un.d_val -= s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
index ac78324992b2755e75a475e648cc1d7406b89a24..60d47287a37fe47daa0077cde801aaebc23a3099 100644 (file)
@@ -843,11 +843,6 @@ struct elf_metag_link_hash_table
   Elf_Internal_Sym **all_local_syms;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -1664,8 +1659,7 @@ elf_metag_relocate_section (bfd *output_bfd,
          if (hh->eh.forced_local)
            break;
 
-         if (hh->eh.plt.offset == (bfd_vma) -1 ||
-             htab->splt == NULL)
+         if (hh->eh.plt.offset == (bfd_vma) -1 || htab->etab.splt == NULL)
            {
              /* We didn't make a PLT entry for this symbol.  This
                 happens when statically linking PIC code, or when
@@ -1673,16 +1667,16 @@ elf_metag_relocate_section (bfd *output_bfd,
              break;
            }
 
-         relocation = (htab->splt->output_section->vma
-                       + htab->splt->output_offset
+         relocation = (htab->etab.splt->output_section->vma
+                       + htab->etab.splt->output_offset
                        + hh->eh.plt.offset);
          break;
        case R_METAG_HI16_GOTPC:
        case R_METAG_LO16_GOTPC:
-         BFD_ASSERT (htab->sgot != NULL);
+         BFD_ASSERT (htab->etab.sgot != NULL);
 
-         relocation = (htab->sgot->output_section->vma +
-                       htab->sgot->output_offset);
+         relocation = (htab->etab.sgot->output_section->vma +
+                       htab->etab.sgot->output_offset);
          relocation += GOT_REG_OFFSET;
          relocation -= (input_section->output_section->vma
                         + input_section->output_offset
@@ -1691,10 +1685,10 @@ elf_metag_relocate_section (bfd *output_bfd,
        case R_METAG_HI16_GOTOFF:
        case R_METAG_LO16_GOTOFF:
        case R_METAG_GETSET_GOTOFF:
-         BFD_ASSERT (htab->sgot != NULL);
+         BFD_ASSERT (htab->etab.sgot != NULL);
 
-         relocation -= (htab->sgot->output_section->vma +
-                        htab->sgot->output_offset);
+         relocation -= (htab->etab.sgot->output_section->vma +
+                        htab->etab.sgot->output_offset);
          relocation -= GOT_REG_OFFSET;
          break;
        case R_METAG_GETSET_GOT:
@@ -1758,11 +1752,11 @@ elf_metag_relocate_section (bfd *output_bfd,
                       object because the symbol index is zero.  */
                    Elf_Internal_Rela outrel;
                    bfd_byte *loc;
-                   asection *s = htab->srelgot;
+                   asection *s = htab->etab.srelgot;
 
                    outrel.r_offset = (off
-                                      + htab->sgot->output_offset
-                                      + htab->sgot->output_section->vma);
+                                      + htab->etab.sgot->output_offset
+                                      + htab->etab.sgot->output_section->vma);
                    outrel.r_info = ELF32_R_INFO (0, R_METAG_RELATIVE);
                    outrel.r_addend = relocation;
                    loc = s->contents;
@@ -1771,7 +1765,7 @@ elf_metag_relocate_section (bfd *output_bfd,
                  }
                else
                  bfd_put_32 (output_bfd, relocation,
-                             htab->sgot->contents + off);
+                             htab->etab.sgot->contents + off);
              }
 
            if (off >= (bfd_vma) -2)
@@ -1789,7 +1783,7 @@ elf_metag_relocate_section (bfd *output_bfd,
            int indx;
            char tls_type;
 
-           if (htab->sgot == NULL)
+           if (htab->etab.sgot == NULL)
              abort();
 
            indx = 0;
@@ -1841,9 +1835,9 @@ elf_metag_relocate_section (bfd *output_bfd,
                        || hh->eh.root.type != bfd_link_hash_undefweak))
                  {
                    need_relocs = TRUE;
-                   loc = htab->srelgot->contents;
+                   loc = htab->etab.srelgot->contents;
                    /* FIXME (CAO): Should this be reloc_count++ ? */
-                   loc += htab->srelgot->reloc_count * sizeof (Elf32_External_Rela);
+                   loc += htab->etab.srelgot->reloc_count * sizeof (Elf32_External_Rela);
                  }
 
                if (tls_type & GOT_TLS_GD)
@@ -1851,29 +1845,29 @@ elf_metag_relocate_section (bfd *output_bfd,
                    if (need_relocs)
                      {
                        outrel.r_offset = (cur_off
-                                          + htab->sgot->output_section->vma
-                                          + htab->sgot->output_offset);
+                                          + htab->etab.sgot->output_section->vma
+                                          + htab->etab.sgot->output_offset);
                        outrel.r_info = ELF32_R_INFO (indx, R_METAG_TLS_DTPMOD);
                        outrel.r_addend = 0;
-                       bfd_put_32 (output_bfd, 0, htab->sgot->contents + cur_off);
+                       bfd_put_32 (output_bfd, 0, htab->etab.sgot->contents + cur_off);
 
                        bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
-                       htab->srelgot->reloc_count++;
+                       htab->etab.srelgot->reloc_count++;
                        loc += sizeof (Elf32_External_Rela);
 
                        if (indx == 0)
                          bfd_put_32 (output_bfd, 0,
-                                     htab->sgot->contents + cur_off + 4);
+                                     htab->etab.sgot->contents + cur_off + 4);
                        else
                          {
                            bfd_put_32 (output_bfd, 0,
-                                       htab->sgot->contents + cur_off + 4);
+                                       htab->etab.sgot->contents + cur_off + 4);
                            outrel.r_info = ELF32_R_INFO (indx,
                                                      R_METAG_TLS_DTPOFF);
                            outrel.r_offset += 4;
                            bfd_elf32_swap_reloca_out (output_bfd,
                                                       &outrel, loc);
-                           htab->srelgot->reloc_count++;
+                           htab->etab.srelgot->reloc_count++;
                            loc += sizeof (Elf32_External_Rela);
                          }
                      }
@@ -1898,8 +1892,8 @@ elf_metag_relocate_section (bfd *output_bfd,
                    if (need_relocs)
                      {
                        outrel.r_offset = (cur_off
-                                          + htab->sgot->output_section->vma
-                                          + htab->sgot->output_offset);
+                                          + htab->etab.sgot->output_section->vma
+                                          + htab->etab.sgot->output_offset);
                        outrel.r_info = ELF32_R_INFO (indx, R_METAG_TLS_TPOFF);
 
                        if (indx == 0)
@@ -1908,12 +1902,12 @@ elf_metag_relocate_section (bfd *output_bfd,
                          outrel.r_addend = 0;
 
                        bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
-                       htab->srelgot->reloc_count++;
+                       htab->etab.srelgot->reloc_count++;
                        loc += sizeof (Elf32_External_Rela);
                      }
                    else
                      bfd_put_32 (output_bfd, tpoff (info, relocation),
-                                 htab->sgot->contents + cur_off);
+                                 htab->etab.sgot->contents + cur_off);
 
                    cur_off += 4;
                  }
@@ -1957,7 +1951,7 @@ elf_metag_relocate_section (bfd *output_bfd,
          {
            bfd_vma off;
 
-           if (htab->sgot == NULL)
+           if (htab->etab.sgot == NULL)
              abort();
            off = htab->tls_ldm_got.offset;
            if (off & 1)
@@ -1968,13 +1962,13 @@ elf_metag_relocate_section (bfd *output_bfd,
                bfd_byte *loc;
 
                outrel.r_offset = (off
-                                  + htab->sgot->output_section->vma
-                                  + htab->sgot->output_offset);
+                                  + htab->etab.sgot->output_section->vma
+                                  + htab->etab.sgot->output_offset);
 
                outrel.r_addend = 0;
                outrel.r_info = ELF32_R_INFO (0, R_METAG_TLS_DTPMOD);
-               loc = htab->srelgot->contents;
-               loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+               loc = htab->etab.srelgot->contents;
+               loc += htab->etab.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
                bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
                htab->tls_ldm_got.offset |= 1;
              }
@@ -2046,32 +2040,22 @@ elf_metag_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   /* Don't try to create the .plt and .got twice.  */
   htab = metag_link_hash_table (info);
-  if (htab->splt != NULL)
+  if (htab->etab.splt != NULL)
     return TRUE;
 
   /* Call the generic code to do most of the work.  */
   if (! _bfd_elf_create_dynamic_sections (abfd, info))
     return FALSE;
 
-  htab->sgot = bfd_get_linker_section (abfd, ".got");
-  if (! htab->sgot)
-    return FALSE;
-
-  htab->sgotplt = bfd_make_section_with_flags (abfd, ".got.plt",
-                                              (SEC_ALLOC | SEC_LOAD |
-                                               SEC_HAS_CONTENTS |
-                                               SEC_IN_MEMORY |
-                                               SEC_LINKER_CREATED));
-  if (htab->sgotplt == NULL
-      || !bfd_set_section_alignment (abfd, htab->sgotplt, 2))
-    return FALSE;
+  /* The header goes at the start of the dynamic .got section, which
+     is placed after the dynamic .got.plt section.  ie. The header is
+     not necessarily at the start of the output .got section.  */
+  htab->etab.sgot->size += 12;
 
-  /* Define the symbol __GLOBAL_OFFSET_TABLE__ at the start of the .got
-     section.  We don't do this in the linker script because we don't want
-     to define the symbol if we are not creating a global offset table.  */
+  /* Define the symbol __GLOBAL_OFFSET_TABLE__ on the header.  */
   bh = NULL;
   if (!(_bfd_generic_link_add_one_symbol
-       (info, abfd, "__GLOBAL_OFFSET_TABLE__", BSF_GLOBAL, htab->sgot,
+       (info, abfd, "__GLOBAL_OFFSET_TABLE__", BSF_GLOBAL, htab->etab.sgot,
         (bfd_vma) 0, NULL, FALSE, bed->collect, &bh)))
     return FALSE;
   eh = (struct elf_link_hash_entry *) bh;
@@ -2083,12 +2067,7 @@ elf_metag_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
       && ! bfd_elf_link_record_dynamic_symbol (info, eh))
     return FALSE;
 
-  elf_hash_table (info)->hgot = eh;
-
-  htab->splt = bfd_get_linker_section (abfd, ".plt");
-  htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
-
-  htab->srelgot = bfd_get_linker_section (abfd, ".rela.got");
+  htab->etab.hgot = eh;
 
   htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
   htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
@@ -2164,7 +2143,7 @@ elf_metag_check_relocs (bfd *abfd,
        }
 
       /* Some relocs require a global offset table.  */
-      if (htab->sgot == NULL)
+      if (htab->etab.sgot == NULL)
        {
          switch (r_type)
            {
@@ -2637,7 +2616,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), eh))
        {
-         asection *s = htab->splt;
+         asection *s = htab->etab.splt;
 
          /* If this is the first .plt entry, make room for the special
             first entry.  */
@@ -2663,10 +2642,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
 
          /* We also need to make an entry in the .got.plt section, which
             will be placed in the .got section by the linker script.  */
-         htab->sgotplt->size += 4;
+         htab->etab.sgotplt->size += 4;
 
          /* We also need to make an entry in the .rel.plt section.  */
-         htab->srelplt->size += sizeof (Elf32_External_Rela);
+         htab->etab.srelplt->size += sizeof (Elf32_External_Rela);
        }
       else
        {
@@ -2695,7 +2674,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
            return FALSE;
        }
 
-      s = htab->sgot;
+      s = htab->etab.sgot;
 
       eh->got.offset = s->size;
       s->size += 4;
@@ -2707,13 +2686,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
         R_METAG_TLS_GD needs one if local symbol and two if global.  */
       if ((tls_type == GOT_TLS_GD && eh->dynindx == -1)
          || (tls_type == GOT_TLS_IE && dyn))
-       htab->srelgot->size += sizeof (Elf32_External_Rela);
+       htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
       else if (tls_type == GOT_TLS_GD)
-         htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+         htab->etab.srelgot->size += 2 * sizeof (Elf32_External_Rela);
       else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
                                                bfd_link_pic (info),
                                                eh))
-         htab->srelgot->size += sizeof (Elf32_External_Rela);
+         htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     eh->got.offset = (bfd_vma) -1;
@@ -2913,8 +2892,8 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
       local_tls_type = metag_elf_local_got_tls_type (ibfd);
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->etab.sgot;
+      srel = htab->etab.srelgot;
       for (; local_got < end_local_got; ++local_got)
        {
          if (*local_got > 0)
@@ -2937,9 +2916,9 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       /* Allocate 2 got entries and 1 dynamic reloc for R_METAG_TLS_LDM
         reloc.  */
-      htab->tls_ldm_got.offset = htab->sgot->size;
-      htab->sgot->size += 8;
-      htab->srelgot->size += sizeof (Elf32_External_Rela);
+      htab->tls_ldm_got.offset = htab->etab.sgot->size;
+      htab->etab.sgot->size += 8;
+      htab->etab.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
@@ -2958,9 +2937,9 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
        continue;
 
-      if (s == htab->splt
-         || s == htab->sgot
-         || s == htab->sgotplt
+      if (s == htab->etab.splt
+         || s == htab->etab.sgot
+         || s == htab->etab.sgotplt
          || s == htab->sdynbss)
        {
          /* Strip this section if we don't need it; see the
@@ -2968,7 +2947,7 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
        {
-         if (s->size != 0 && s != htab->srelplt)
+         if (s->size != 0 && s != htab->etab.srelplt)
            relocs = TRUE;
 
          /* We use the reloc_count field as a counter if we need
@@ -3039,7 +3018,7 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-      if (htab->srelplt->size != 0)
+      if (htab->etab.srelplt->size != 0)
        {
          if (!add_dynamic_entry (DT_PLTRELSZ, 0)
              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
@@ -3101,9 +3080,9 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (eh->dynindx != -1);
 
-      splt = htab->splt;
-      sgot = htab->sgotplt;
-      srela = htab->srelplt;
+      splt = htab->etab.splt;
+      sgot = htab->etab.sgotplt;
+      srela = htab->etab.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -3181,7 +3160,7 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
                      + got_offset);
       rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_JMP_SLOT);
       rel.r_addend = 0;
-      loc = htab->srelplt->contents;
+      loc = htab->etab.srelplt->contents;
       loc += plt_index * sizeof(Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
 
@@ -3201,8 +3180,8 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
         up.  */
 
       rel.r_offset = ((eh->got.offset &~ (bfd_vma) 1)
-                     + htab->sgot->output_offset
-                     + htab->sgot->output_section->vma);
+                     + htab->etab.sgot->output_offset
+                     + htab->etab.sgot->output_section->vma);
 
       /* If this is a -Bsymbolic link and the symbol is defined
         locally or was forced to be local because of a version file,
@@ -3222,13 +3201,13 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
        {
          if ((eh->got.offset & 1) != 0)
            abort ();
-         bfd_put_32 (output_bfd, 0, htab->sgot->contents + eh->got.offset);
+         bfd_put_32 (output_bfd, 0, htab->etab.sgot->contents + eh->got.offset);
          rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_GLOB_DAT);
          rel.r_addend = 0;
        }
 
-      loc = htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+      loc = htab->etab.srelgot->contents;
+      loc += htab->etab.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
@@ -3336,19 +3315,19 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
              continue;
 
            case DT_PLTGOT:
-             s = htab->sgot;
+             s = htab->etab.sgot;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_JMPREL:
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = htab->srelplt;
+             s = htab->etab.srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -3356,8 +3335,8 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
            case DT_RELASZ:
              /* Don't count procedure linkage table relocs in the
                 overall reloc count.  */
-             if (htab->srelplt) {
-               s = htab->srelplt;
+             if (htab->etab.srelplt) {
+               s = htab->etab.srelplt;
                dyn.d_un.d_val -= s->size;
              }
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -3367,8 +3346,8 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
              /* We may not be using the standard ELF linker script.
                 If .rela.plt is the first .rela section, we adjust
                 DT_RELA to not include it.  */
-             if (htab->srelplt) {
-               s = htab->srelplt;
+             if (htab->etab.srelplt) {
+               s = htab->etab.srelplt;
                if (dyn.d_un.d_ptr == s->output_section->vma + s->output_offset)
                  dyn.d_un.d_ptr += s->size;
              }
@@ -3379,13 +3358,13 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
        }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->etab.splt;
       if (splt && splt->size > 0)
        {
          unsigned long addr;
          /* addr = .got + 4 */
-         addr = htab->sgot->output_section->vma +
-           htab->sgot->output_offset + 4;
+         addr = (htab->etab.sgot->output_section->vma
+                 + htab->etab.sgot->output_offset + 4);
          if (bfd_link_pic (info))
            {
              addr -= splt->output_section->vma + splt->output_offset;
@@ -3417,19 +3396,19 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
        }
     }
 
-  if (htab->sgot != NULL && htab->sgot->size != 0)
+  if (htab->etab.sgot != NULL && htab->etab.sgot->size != 0)
     {
       /* Fill in the first entry in the global offset table.
         We use it to point to our dynamic section, if we have one.  */
       bfd_put_32 (output_bfd,
                  sdyn ? sdyn->output_section->vma + sdyn->output_offset : 0,
-                 htab->sgot->contents);
+                 htab->etab.sgot->contents);
 
       /* The second entry is reserved for use by the dynamic linker.  */
-      memset (htab->sgot->contents + GOT_ENTRY_SIZE, 0, GOT_ENTRY_SIZE);
+      memset (htab->etab.sgot->contents + GOT_ENTRY_SIZE, 0, GOT_ENTRY_SIZE);
 
       /* Set .got entry size.  */
-      elf_section_data (htab->sgot->output_section)
+      elf_section_data (htab->etab.sgot->output_section)
        ->this_hdr.sh_entsize = GOT_ENTRY_SIZE;
     }
 
@@ -4141,7 +4120,7 @@ elf_metag_size_stubs(bfd *output_bfd, bfd *stub_bfd,
                              && hh->eh.dynindx != -1
                              && r_type == (unsigned int) R_METAG_RELBRANCH_PLT)
                            {
-                             sym_sec = htab->splt;
+                             sym_sec = htab->etab.splt;
                              sym_value = hh->eh.plt.offset;
                            }
 
@@ -4330,8 +4309,8 @@ elf_metag_plt_sym_val (bfd_vma i, const asection *plt,
 
 #define elf_backend_can_gc_sections            1
 #define elf_backend_can_refcount               1
-#define elf_backend_got_header_size            12
-#define elf_backend_rela_normal                1
+#define elf_backend_rela_normal                        1
+#define elf_backend_want_got_plt               1
 #define elf_backend_want_got_sym               0
 #define elf_backend_want_plt_sym               0
 #define elf_backend_plt_readonly               1
index 5c66808ed423f9321ea026ba0baa0f6d708b1c24..c700bcb64ffe812ee2608e320aa2f517108e9dbe 100644 (file)
@@ -731,11 +731,6 @@ struct elf32_mb_link_hash_table
   struct elf_link_hash_table elf;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -1152,8 +1147,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
              break; /* Do nothing.  */
 
            case (int) R_MICROBLAZE_GOTPC_64:
-             relocation = htab->sgotplt->output_section->vma
-               + htab->sgotplt->output_offset;
+             relocation = (htab->elf.sgotplt->output_section->vma
+                           + htab->elf.sgotplt->output_offset);
              relocation -= (input_section->output_section->vma
                             + input_section->output_offset
                             + offset + INST_WORD_SIZE);
@@ -1167,11 +1162,11 @@ microblaze_elf_relocate_section (bfd *output_bfd,
            case (int) R_MICROBLAZE_PLT_64:
              {
                bfd_vma immediate;
-               if (htab->splt != NULL && h != NULL
+               if (htab->elf.splt != NULL && h != NULL
                    && h->plt.offset != (bfd_vma) -1)
                  {
-                   relocation = (htab->splt->output_section->vma
-                                 + htab->splt->output_offset
+                   relocation = (htab->elf.splt->output_section->vma
+                                 + htab->elf.splt->output_offset
                                  + h->plt.offset);
                    unresolved_reloc = FALSE;
                    immediate = relocation - (input_section->output_section->vma
@@ -1211,7 +1206,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                bfd_vma static_value;
 
                bfd_boolean need_relocs = FALSE;
-               if (htab->sgot == NULL)
+               if (htab->elf.sgot == NULL)
                  abort ();
 
                indx = 0;
@@ -1227,10 +1222,11 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                  offp = &htab->tlsld_got.offset;
                else if (h != NULL)
                  {
-                   if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1)
-                       offp = &h->got.offset;
+                   if (htab->elf.sgotplt != NULL
+                       && h->got.offset != (bfd_vma) -1)
+                     offp = &h->got.offset;
                    else
-                       abort ();
+                     abort ();
                  }
                else
                  {
@@ -1277,97 +1273,95 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                  {
                    bfd_vma got_offset;
 
-                   got_offset = (htab->sgot->output_section->vma
-                                 + htab->sgot->output_offset
+                   got_offset = (htab->elf.sgot->output_section->vma
+                                 + htab->elf.sgot->output_offset
                                  + off);
 
                    /* Process module-id */
                    if (IS_TLS_LD(tls_type))
                      {
                        if (! bfd_link_pic (info))
-                         {
-                           bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
-                         }
+                         bfd_put_32 (output_bfd, 1,
+                                     htab->elf.sgot->contents + off);
                        else
-                         {
-                           microblaze_elf_output_dynamic_relocation (output_bfd,
-                             htab->srelgot, htab->srelgot->reloc_count++,
-                             /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
-                             got_offset, 0);
-                         }
+                         microblaze_elf_output_dynamic_relocation
+                           (output_bfd,
+                            htab->elf.srelgot,
+                            htab->elf.srelgot->reloc_count++,
+                            /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
+                            got_offset, 0);
                      }
                    else if (IS_TLS_GD(tls_type))
                      {
                        if (! need_relocs)
-                         {
-                           bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
-                         }
+                         bfd_put_32 (output_bfd, 1,
+                                     htab->elf.sgot->contents + off);
                        else
-                         {
-                           microblaze_elf_output_dynamic_relocation (output_bfd,
-                             htab->srelgot,
-                             htab->srelgot->reloc_count++,
-                             /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
-                             got_offset, indx ? 0 : static_value);
-                         }
+                         microblaze_elf_output_dynamic_relocation
+                           (output_bfd,
+                            htab->elf.srelgot,
+                            htab->elf.srelgot->reloc_count++,
+                            /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
+                            got_offset, indx ? 0 : static_value);
                      }
 
                    /* Process Offset */
-                   if (htab->srelgot == NULL)
+                   if (htab->elf.srelgot == NULL)
                      abort ();
 
-                   got_offset = (htab->sgot->output_section->vma
-                                 + htab->sgot->output_offset
+                   got_offset = (htab->elf.sgot->output_section->vma
+                                 + htab->elf.sgot->output_offset
                                  + off2);
                    if (IS_TLS_LD(tls_type))
                      {
                        /* For LD, offset should be 0 */
                        *offp |= 1;
-                       bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2);
+                       bfd_put_32 (output_bfd, 0,
+                                   htab->elf.sgot->contents + off2);
                      }
                    else if (IS_TLS_GD(tls_type))
                      {
                        *offp |= 1;
                        static_value -= dtprel_base(info);
                        if (need_relocs)
-                         {
-                           microblaze_elf_output_dynamic_relocation (output_bfd,
-                             htab->srelgot, htab->srelgot->reloc_count++,
-                             /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
-                             got_offset, indx ? 0 : static_value);
-                         }
+                         microblaze_elf_output_dynamic_relocation
+                           (output_bfd,
+                            htab->elf.srelgot,
+                            htab->elf.srelgot->reloc_count++,
+                            /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
+                            got_offset, indx ? 0 : static_value);
                        else
-                         {
-                           bfd_put_32 (output_bfd, static_value,
-                                       htab->sgot->contents + off2);
-                         }
+                         bfd_put_32 (output_bfd, static_value,
+                                     htab->elf.sgot->contents + off2);
                      }
                    else
                      {
-                         bfd_put_32 (output_bfd, static_value,
-                                     htab->sgot->contents + off2);
+                       bfd_put_32 (output_bfd, static_value,
+                                   htab->elf.sgot->contents + off2);
 
-                         /* Relocs for dyn symbols generated by
-                            finish_dynamic_symbols */
-                         if (bfd_link_pic (info) && h == NULL)
-                           {
-                             *offp |= 1;
-                             microblaze_elf_output_dynamic_relocation (output_bfd,
-                               htab->srelgot, htab->srelgot->reloc_count++,
-                               /* symindex= */ indx, R_MICROBLAZE_REL,
-                               got_offset, static_value);
-                           }
+                       /* Relocs for dyn symbols generated by
+                          finish_dynamic_symbols */
+                       if (bfd_link_pic (info) && h == NULL)
+                         {
+                           *offp |= 1;
+                           microblaze_elf_output_dynamic_relocation
+                             (output_bfd,
+                              htab->elf.srelgot,
+                              htab->elf.srelgot->reloc_count++,
+                              /* symindex= */ indx, R_MICROBLAZE_REL,
+                              got_offset, static_value);
+                         }
                      }
                  }
 
                /* 4. Fixup Relocation with GOT offset value
                      Compute relative address of GOT entry for applying
                      the current relocation */
-               relocation = htab->sgot->output_section->vma
-                            + htab->sgot->output_offset
+               relocation = htab->elf.sgot->output_section->vma
+                            + htab->elf.sgot->output_offset
                             + off
-                            - htab->sgotplt->output_section->vma
-                            - htab->sgotplt->output_offset;
+                            - htab->elf.sgotplt->output_section->vma
+                            - htab->elf.sgotplt->output_offset;
 
                /* Apply Current Relocation */
                bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
@@ -1384,22 +1378,23 @@ microblaze_elf_relocate_section (bfd *output_bfd,
                bfd_vma immediate;
                unsigned short lo, high;
                relocation += addend;
-               relocation -= htab->sgotplt->output_section->vma
-                 + htab->sgotplt->output_offset;
+               relocation -= (htab->elf.sgotplt->output_section->vma
+                              + htab->elf.sgotplt->output_offset);
                /* Write this value into correct location.  */
                immediate = relocation;
                lo = immediate & 0x0000ffff;
                high = (immediate >> 16) & 0x0000ffff;
                bfd_put_16 (input_bfd, high, contents + offset + endian);
-               bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian);
+               bfd_put_16 (input_bfd, lo,
+                           contents + offset + INST_WORD_SIZE + endian);
                break;
              }
 
            case (int) R_MICROBLAZE_GOTOFF_32:
              {
                relocation += addend;
-               relocation -= htab->sgotplt->output_section->vma
-                 + htab->sgotplt->output_offset;
+               relocation -= (htab->elf.sgotplt->output_section->vma
+                              + htab->elf.sgotplt->output_offset);
                /* Write this value into correct location.  */
                bfd_put_32 (input_bfd, relocation, contents + offset);
                break;
@@ -2248,39 +2243,6 @@ microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
 #define PLT_ENTRY_WORD_2  0x98186000          /* "brad r12".  */
 #define PLT_ENTRY_WORD_3  0x80000000          /* "nop".  */
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf32_mb_link_hash_table *htab;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-  htab = elf32_mb_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  htab->sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  if (!htab->sgot || !htab->sgotplt)
-    return FALSE;
-
-  if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
-    htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
-  if (htab->srelgot == NULL
-      || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
-                                  | SEC_LOAD
-                                  | SEC_HAS_CONTENTS
-                                  | SEC_IN_MEMORY
-                                  | SEC_LINKER_CREATED
-                                  | SEC_READONLY)
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-  return TRUE;
-}
-
 static bfd_boolean
 update_local_sym_info (bfd *abfd,
                       Elf_Internal_Shdr *symtab_hdr,
@@ -2396,11 +2358,11 @@ microblaze_elf_check_relocs (bfd * abfd,
           sec->has_tls_reloc = 1;
          /* Fall through.  */
         case R_MICROBLAZE_GOT_64:
-          if (htab->sgot == NULL)
+          if (htab->elf.sgot == NULL)
             {
               if (htab->elf.dynobj == NULL)
                 htab->elf.dynobj = abfd;
-              if (!create_got_section (htab->elf.dynobj, info))
+              if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
                 return FALSE;
             }
           if (h != NULL)
@@ -2550,19 +2512,17 @@ microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->sgot && !create_got_section (dynobj, info))
+  if (!htab->elf.sgot && !_bfd_elf_create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->splt = bfd_get_linker_section (dynobj, ".plt");
-  htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
   htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!bfd_link_pic (info))
     htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
-  if (!htab->splt || !htab->srelplt || !htab->sdynbss
+  if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
       || (!bfd_link_pic (info) && !htab->srelbss))
     abort ();
 
@@ -2793,7 +2753,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
         {
-          asection *s = htab->splt;
+          asection *s = htab->elf.splt;
 
           /* The first entry in .plt is reserved.  */
           if (s->size == 0)
@@ -2818,10 +2778,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
 
           /* We also need to make an entry in the .got.plt section, which
              will be placed in the .got section by the linker script.  */
-         htab->sgotplt->size += 4;
+         htab->elf.sgotplt->size += 4;
 
           /* We also need to make an entry in the .rel.plt section.  */
-          htab->srelplt->size += sizeof (Elf32_External_Rela);
+          htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
         }
       else
         {
@@ -2878,10 +2838,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
         }
       else
         {
-          s = htab->sgot;
+          s = htab->elf.sgot;
           h->got.offset = s->size;
           s->size += need;
-          htab->srelgot->size += need * (sizeof (Elf32_External_Rela) / 4);
+          htab->elf.srelgot->size += need * (sizeof (Elf32_External_Rela) / 4);
         }
     }
   else
@@ -3025,8 +2985,8 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
       lgot_masks = (unsigned char *) end_local_got;
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->elf.sgot;
+      srel = htab->elf.srelgot;
 
       for (; local_got < end_local_got; ++local_got, ++lgot_masks)
        {
@@ -3066,10 +3026,10 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (htab->tlsld_got.refcount > 0)
     {
-      htab->tlsld_got.offset = htab->sgot->size;
-      htab->sgot->size += 8;
+      htab->tlsld_got.offset = htab->elf.sgot->size;
+      htab->elf.sgot->size += 8;
       if (bfd_link_pic (info))
-        htab->srelgot->size += sizeof (Elf32_External_Rela);
+        htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tlsld_got.offset = (bfd_vma) -1;
@@ -3077,8 +3037,8 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Make space for the trailing nop in .plt.  */
-      if (htab->splt->size > 0)
-        htab->splt->size += 4;
+      if (htab->elf.splt->size > 0)
+        htab->elf.splt->size += 4;
     }
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
@@ -3118,7 +3078,9 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
               s->reloc_count = 0;
             }
         }
-      else if (s != htab->splt && s != htab->sgot && s != htab->sgotplt)
+      else if (s != htab->elf.splt
+              && s != htab->elf.sgot
+              && s != htab->elf.sgotplt)
         {
           /* It's not one of our sections, so don't allocate space.  */
           continue;
@@ -3162,7 +3124,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
           || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
        return FALSE;
 
-      if (htab->splt->size != 0)
+      if (htab->elf.splt->size != 0)
         {
           if (!add_dynamic_entry (DT_PLTGOT, 0)
               || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -3213,9 +3175,9 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
          it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      srela = htab->srelplt;
-      sgotplt = htab->sgotplt;
+      splt = htab->elf.splt;
+      srela = htab->elf.srelplt;
+      sgotplt = htab->elf.sgotplt;
       BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL);
 
       plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved.  */
@@ -3224,7 +3186,7 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
 
       /* For non-PIC objects we need absolute address of the GOT entry.  */
       if (!bfd_link_pic (info))
-        got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
+        got_addr += sgotplt->output_section->vma + sgotplt->output_offset;
 
       /* Fill in the entry in the procedure linkage table.  */
       bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
@@ -3276,8 +3238,8 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
 
-      sgot = htab->sgot;
-      srela = htab->srelgot;
+      sgot = htab->elf.sgot;
+      srela = htab->elf.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       offset = (sgot->output_section->vma + sgot->output_offset
@@ -3369,7 +3331,7 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = htab->elf.splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -3424,7 +3386,7 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
 
   /* Set the first entry in the global offset table to the address of
      the dynamic section.  */
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = htab->elf.sgotplt;
   if (sgot && sgot->size > 0)
     {
       if (sdyn == NULL)
@@ -3436,8 +3398,8 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
       elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
     }
 
-  if (htab->sgot && htab->sgot->size > 0)
-    elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
+  if (htab->elf.sgot && htab->elf.sgot->size > 0)
+    elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 4;
 
   return TRUE;
 }
index ab19801da3ff46cc35d33e558995f2d707111089..8a06da5cc95205af99b395b5dbc99cb286fc6793 100644 (file)
@@ -3380,50 +3380,9 @@ nds32_elf_link_hash_table_create (bfd *abfd)
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->sym_ld_script = NULL;
-  ret->ex9_export_file = NULL;
-  ret->ex9_import_file = NULL;
-
   return &ret->root.root;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf_nds32_link_hash_table *htab;
-
-  if (!_bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab = nds32_elf_hash_table (info);
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  if (!htab->sgot || !htab->sgotplt)
-    abort ();
-
-  /* _bfd_elf_create_got_section will create it for us.  */
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-  if (htab->srelgot == NULL
-      || !bfd_set_section_flags (dynobj, htab->srelgot,
-                                (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                 | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                 | SEC_READONLY))
-      || !bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-
-  return TRUE;
-}
-
 /* Create dynamic sections when linking against a dynamic object.  */
 
 static bfd_boolean
@@ -3453,7 +3412,7 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     pltflags |= SEC_READONLY;
 
   s = bfd_make_section (abfd, ".plt");
-  htab->splt = s;
+  htab->root.splt = s;
   if (s == NULL
       || !bfd_set_section_flags (abfd, s, pltflags)
       || !bfd_set_section_alignment (abfd, s, bed->plt_alignment))
@@ -3482,13 +3441,13 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   s = bfd_make_section (abfd,
                        bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
-  htab->srelplt = s;
+  htab->root.srelplt = s;
   if (s == NULL
       || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
       || !bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (htab->sgot == NULL && !create_got_section (abfd, info))
+  if (htab->root.sgot == NULL && !_bfd_elf_create_got_section (abfd, info))
     return FALSE;
 
   {
@@ -3796,7 +3755,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
        {
-         asection *s = htab->splt;
+         asection *s = htab->root.splt;
 
          /* If this is the first .plt entry, make room for the special
             first entry.  */
@@ -3821,10 +3780,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
          /* We also need to make an entry in the .got.plt section, which
             will be placed in the .got section by the linker script.  */
-         htab->sgotplt->size += 4;
+         htab->root.sgotplt->size += 4;
 
          /* We also need to make an entry in the .rel.plt section.  */
-         htab->srelplt->size += sizeof (Elf32_External_Rela);
+         htab->root.srelplt->size += sizeof (Elf32_External_Rela);
        }
       else
        {
@@ -3852,7 +3811,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            return FALSE;
        }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
       h->got.offset = s->size;
 
       if (tls_type == GOT_UNKNOWN)
@@ -3864,7 +3823,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       dyn = htab->root.dynamic_sections_created;
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
-       htab->srelgot->size += sizeof (Elf32_External_Rela);
+       htab->root.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) - 1;
@@ -4039,8 +3998,8 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
       for (; local_got < end_local_got; ++local_got)
        {
          if (*local_got > 0)
@@ -4067,22 +4026,22 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
        continue;
 
-      if (s == htab->splt)
+      if (s == htab->root.splt)
        {
          /* Strip this section if we don't need it; see the
             comment below.  */
        }
-      else if (s == htab->sgot)
+      else if (s == htab->root.sgot)
        {
          got_size += s->size;
        }
-      else if (s == htab->sgotplt)
+      else if (s == htab->root.sgotplt)
        {
          got_size += s->size;
        }
       else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
        {
-         if (s->size != 0 && s != htab->srelplt)
+         if (s->size != 0 && s != htab->root.srelplt)
            relocs = TRUE;
 
          /* We use the reloc_count field as a counter if we need
@@ -4137,7 +4096,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-      if (htab->splt->size != 0)
+      if (htab->root.splt->size != 0)
        {
          if (!add_dynamic_entry (DT_PLTGOT, 0)
              || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -4499,8 +4458,8 @@ nds32_elf_relocate_section (bfd *                  output_bfd ATTRIBUTE_UNUSED,
   dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
 
-  sgot = htab->sgot;
-  splt = htab->splt;
+  sgot = htab->root.sgot;
+  splt = htab->root.splt;
   sreloc = NULL;
 
   rel = relocs;
@@ -4867,7 +4826,7 @@ nds32_elf_relocate_section (bfd *                  output_bfd ATTRIBUTE_UNUSED,
 
                      /* We need to generate a R_NDS32_RELATIVE reloc
                         for the dynamic linker.  */
-                     srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                     srelgot = htab->root.srelgot;
                      BFD_ASSERT (srelgot != NULL);
 
                      outrel.r_offset = (elf_gp (output_bfd)
@@ -5121,7 +5080,7 @@ nds32_elf_relocate_section (bfd *                  output_bfd ATTRIBUTE_UNUSED,
 
                          /* We need to generate a R_NDS32_RELATIVE reloc
                             for the dynamic linker.  */
-                         srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                         srelgot = htab->root.srelgot;
                          BFD_ASSERT (srelgot != NULL);
 
                          outrel.r_offset = (elf_gp (output_bfd)
@@ -5279,7 +5238,7 @@ handle_sda:
            else
              {
                bfd_boolean need_relocs = FALSE;
-               srelgot = htab->srelgot;
+               srelgot = htab->root.srelgot;
                if ((bfd_link_pic (info) || indx != 0)
                    && (h == NULL
                        || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
@@ -5494,9 +5453,9 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      sgot = htab->sgotplt;
-      srela = htab->srelplt;
+      splt = htab->root.splt;
+      sgot = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -5603,8 +5562,8 @@ nds32_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
       /* This symbol has an entry in the global offset table.
         Set it up.  */
 
-      sgot = htab->sgot;
-      srela = htab->srelgot;
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -5686,7 +5645,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   htab = nds32_elf_hash_table (info);
   dynobj = htab->root.dynobj;
 
-  sgot = htab->sgotplt;
+  sgot = htab->root.sgotplt;
   sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
@@ -5712,17 +5671,17 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              break;
 
            case DT_PLTGOT:
-             s = htab->sgotplt;
+             s = htab->root.sgotplt;
              goto get_vma;
            case DT_JMPREL:
-             s = htab->srelplt;
+             s = htab->root.srelplt;
            get_vma:
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = htab->srelplt;
+             s = htab->root.srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -5737,9 +5696,9 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
                 the linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             if (htab->srelplt != NULL)
+             if (htab->root.srelplt != NULL)
                {
-                 s = htab->srelplt;
+                 s = htab->root.srelplt;
                  dyn.d_un.d_val -= s->size;
                }
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -5748,7 +5707,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
        }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->root.splt;
       if (splt && splt->size > 0)
        {
          if (bfd_link_pic (info))
@@ -6396,7 +6355,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
       /* Some relocs require a global offset table.  We create
         got section here, since these relocation need got section
         and it is not created yet.  */
-      if (htab->sgot == NULL)
+      if (htab->root.sgot == NULL)
        {
          switch (r_type)
            {
@@ -6419,7 +6378,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
            case R_NDS32_TLS_IE_LO12S2:
              if (dynobj == NULL)
                htab->root.dynobj = dynobj = abfd;
-             if (!create_got_section (dynobj, info))
+             if (!_bfd_elf_create_got_section (dynobj, info))
                return FALSE;
              break;
 
@@ -6825,7 +6784,7 @@ calculate_plt_memory_address (bfd *abfd, struct bfd_link_info *link_info,
       h = elf_sym_hashes (abfd)[indx];
       BFD_ASSERT (h != NULL);
       htab = nds32_elf_hash_table (link_info);
-      splt = htab->splt;
+      splt = htab->root.splt;
 
       while (h->root.type == bfd_link_hash_indirect
             || h->root.type == bfd_link_hash_warning)
@@ -8101,15 +8060,17 @@ calculate_got_memory_address (bfd *abfd, struct bfd_link_info *link_info,
   if (symndx >= 0)
     {
       BFD_ASSERT (h != NULL);
-      return htab->sgot->output_section->vma + htab->sgot->output_offset
-            + h->got.offset;
+      return (htab->root.sgot->output_section->vma
+             + htab->root.sgot->output_offset
+             + h->got.offset);
     }
   else
     {
       local_got_offsets = elf_local_got_offsets (abfd);
       BFD_ASSERT (local_got_offsets != NULL);
-      return htab->sgot->output_section->vma + htab->sgot->output_offset
-            + local_got_offsets[ELF32_R_SYM (irel->r_info)];
+      return (htab->root.sgot->output_section->vma
+             + htab->root.sgot->output_offset
+             + local_got_offsets[ELF32_R_SYM (irel->r_info)]);
     }
 
   /* The _GLOBAL_OFFSET_TABLE_ may be undefweak(or should be?).  */
index 82278276f311d71c532671dd87b586a2c123715a..f68805cff481b3c77671ededf88e7a33053edc41 100644 (file)
@@ -129,11 +129,6 @@ struct elf_nds32_link_hash_table
   struct elf_link_hash_table root;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
index df2bf03fb26436f9b246159b9ba4ebec0d9c1563..3ec16aab3d63fd68ff8d8e029b67ce3500e7fed1 100644 (file)
@@ -616,11 +616,6 @@ struct elf_or1k_link_hash_table
   struct elf_link_hash_table root;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
 
@@ -820,7 +815,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
 
   sreloc = elf_section_data (input_section)->sreloc;
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -887,11 +882,11 @@ or1k_elf_relocate_section (bfd *output_bfd,
         {
         case R_OR1K_PLT26:
           {
-            if (htab->splt != NULL && h != NULL
+            if (htab->root.splt != NULL && h != NULL
                 && h->plt.offset != (bfd_vma) -1)
               {
-                relocation = (htab->splt->output_section->vma
-                              + htab->splt->output_offset
+                relocation = (htab->root.splt->output_section->vma
+                              + htab->root.splt->output_offset
                               + h->plt.offset);
               }
             break;
@@ -969,7 +964,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
 
                       /* We need to generate a R_OR1K_RELATIVE reloc
                          for the dynamic linker.  */
-                      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                      srelgot = htab->root.srelgot;
                       BFD_ASSERT (srelgot != NULL);
 
                       outrel.r_offset = (sgot->output_section->vma
@@ -1365,46 +1360,6 @@ or1k_elf_gc_sweep_hook (bfd *abfd,
   return TRUE;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf_or1k_link_hash_table *htab;
-  asection *s;
-
-  /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
-    return TRUE;
-
-  htab = or1k_elf_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-
-  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
-    abort ();
-
-  if (! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
-                               | SEC_LOAD
-                               | SEC_HAS_CONTENTS
-                               | SEC_IN_MEMORY
-                               | SEC_LINKER_CREATED
-                               | SEC_READONLY)
-      || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return FALSE;
-
-  return TRUE;
-}
-
 /* Look through the relocs for a section during the first phase.  */
 
 static bfd_boolean
@@ -1536,11 +1491,11 @@ or1k_elf_check_relocs (bfd *abfd,
         case R_OR1K_TLS_GD_LO16:
         case R_OR1K_TLS_IE_HI16:
         case R_OR1K_TLS_IE_LO16:
-          if (htab->sgot == NULL)
+          if (htab->root.sgot == NULL)
             {
               if (dynobj == NULL)
                 htab->root.dynobj = dynobj = abfd;
-              if (! create_got_section (dynobj, info))
+              if (!_bfd_elf_create_got_section (dynobj, info))
                 return FALSE;
             }
 
@@ -1735,7 +1690,7 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = htab->root.dynobj;
 
-  sgot = htab->sgotplt;
+  sgot = htab->root.sgotplt;
   sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
@@ -1761,17 +1716,17 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
               continue;
 
             case DT_PLTGOT:
-              s = htab->sgotplt;
+              s = htab->root.sgotplt;
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               break;
 
             case DT_JMPREL:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               break;
 
             case DT_PLTRELSZ:
-              s = htab->srelplt;
+              s = htab->root.srelplt;
               dyn.d_un.d_val = s->size;
               break;
 
@@ -1785,9 +1740,9 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
                  the linker script arranges for .rela.plt to follow all
                  other relocation sections, we don't have to worry
                  about changing the DT_RELA entry.  */
-              if (htab->srelplt != NULL)
+              if (htab->root.srelplt != NULL)
                 {
-                  s = htab->srelplt;
+                  s = htab->root.srelplt;
                   dyn.d_un.d_val -= s->size;
                 }
               break;
@@ -1797,7 +1752,7 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
 
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->root.splt;
       if (splt && splt->size > 0)
         {
           if (bfd_link_pic (info))
@@ -1846,8 +1801,8 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
       elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
     }
 
-  if (htab->sgot && htab->sgot->size > 0)
-    elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
+  if (htab->root.sgot && htab->root.sgot->size > 0)
+    elf_section_data (htab->root.sgot->output_section)->this_hdr.sh_entsize = 4;
 
   return TRUE;
 }
@@ -1883,9 +1838,9 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
          it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      sgot = htab->sgotplt;
-      srela = htab->srelplt;
+      splt = htab->root.splt;
+      sgot = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -1903,8 +1858,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
       /* Fill in the entry in the procedure linkage table.  */
       if (! bfd_link_pic (info))
         {
-          got_addr += htab->sgotplt->output_section->vma
-            + htab->sgotplt->output_offset;
+          got_addr += htab->root.sgotplt->output_section->vma
+            + htab->root.sgotplt->output_offset;
           bfd_put_32 (output_bfd, PLT_ENTRY_WORD0 | ((got_addr >> 16) & 0xffff),
                       splt->contents + h->plt.offset);
           bfd_put_32 (output_bfd, PLT_ENTRY_WORD1 | (got_addr & 0xffff),
@@ -1966,8 +1921,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
-      sgot = htab->sgot;
-      srela = htab->srelgot;
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -2219,7 +2174,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
         {
-          asection *s = htab->splt;
+          asection *s = htab->root.splt;
 
           /* If this is the first .plt entry, make room for the special
              first entry.  */
@@ -2245,10 +2200,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
           /* We also need to make an entry in the .got.plt section, which
              will be placed in the .got section by the linker script.  */
-          htab->sgotplt->size += 4;
+          htab->root.sgotplt->size += 4;
 
           /* We also need to make an entry in the .rel.plt section.  */
-          htab->srelplt->size += sizeof (Elf32_External_Rela);
+          htab->root.srelplt->size += sizeof (Elf32_External_Rela);
         }
       else
         {
@@ -2277,7 +2232,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
             return FALSE;
         }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
 
       h->got.offset = s->size;
 
@@ -2292,9 +2247,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
         {
           if (tls_type == TLS_GD)
-            htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+            htab->root.srelgot->size += 2 * sizeof (Elf32_External_Rela);
           else
-            htab->srelgot->size += sizeof (Elf32_External_Rela);
+            htab->root.srelgot->size += sizeof (Elf32_External_Rela);
         }
     }
   else
@@ -2492,8 +2447,8 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
       local_tls_type = (unsigned char *) elf_or1k_local_tls_type (ibfd);
       for (; local_got < end_local_got; ++local_got)
         {
@@ -2535,9 +2490,9 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
         continue;
 
-      if (s == htab->splt
-          || s == htab->sgot
-          || s == htab->sgotplt
+      if (s == htab->root.splt
+          || s == htab->root.sgot
+          || s == htab->root.sgotplt
           || s == htab->sdynbss)
         {
           /* Strip this section if we don't need it; see the
@@ -2545,7 +2500,7 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         }
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
         {
-          if (s->size != 0 && s != htab->srelplt)
+          if (s->size != 0 && s != htab->root.srelplt)
             relocs = TRUE;
 
           /* We use the reloc_count field as a counter if we need
@@ -2601,7 +2556,7 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-     if (htab->splt->size != 0)
+     if (htab->root.splt->size != 0)
        {
          if (! add_dynamic_entry (DT_PLTGOT, 0)
              || ! add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2647,19 +2602,17 @@ or1k_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->sgot && !create_got_section (dynobj, info))
+  if (!htab->root.sgot && !_bfd_elf_create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->splt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
   htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
   if (!bfd_link_pic (info))
     htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
 
-  if (!htab->splt || !htab->srelplt || !htab->sdynbss
+  if (!htab->root.splt || !htab->root.srelplt || !htab->sdynbss
       || (!bfd_link_pic (info) && !htab->srelbss))
     abort ();
 
index efe7f69b83ca828b5cbe59a97ebe553511b1472f..35a505c4bc56cd9946c6d5f49fbd89189c44e602 100644 (file)
@@ -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;
index c6ee06ba9ddfcdeb98ed40f6e86e6425590d259a..8a45d81cd4aeec45ab9198b67bf060c5ce4e1b8f 100644 (file)
@@ -685,17 +685,13 @@ rl78_elf_relocate_section
   struct elf_link_hash_entry ** sym_hashes;
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
-  bfd *dynobj;
   asection *splt;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
-  dynobj = elf_hash_table (info)->dynobj;
-  splt = NULL;
-  if (dynobj != NULL)
-    splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -1311,7 +1307,6 @@ rl78_elf_check_relocs
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
-  splt = NULL;
   dynobj = elf_hash_table(info)->dynobj;
 
   rel_end = relocs + sec->reloc_count;
@@ -1344,20 +1339,18 @@ rl78_elf_check_relocs
        case R_RL78_DIR16S:
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
+         splt = elf_hash_table (info)->splt;
          if (splt == NULL)
            {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             if (splt == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY | SEC_CODE);
-                 splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
-                                                            flags);
-                 if (splt == NULL
-                     || ! bfd_set_section_alignment (dynobj, splt, 1))
-                   return FALSE;
-               }
+             flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                               | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                               | SEC_READONLY | SEC_CODE);
+             splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+                                                        flags);
+             elf_hash_table (info)->splt = splt;
+             if (splt == NULL
+                 || ! bfd_set_section_alignment (dynobj, splt, 1))
+               return FALSE;
            }
 
          if (h != NULL)
@@ -1414,8 +1407,9 @@ rl78_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
   if (info->relax_trip > 0)
     return TRUE;
 
-  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
+  dynobj = elf_hash_table (info)->dynobj;
+  splt = elf_hash_table (info)->splt;
+  if (dynobj != NULL && splt != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
@@ -1444,7 +1438,7 @@ rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
   BFD_ASSERT (splt != NULL);
 
   splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
index 3ad4e3113f9a5ec5d2f8906171f23dc56ee51f5c..9226eb03d3736d78b9ac36df103cfed0ead701b1 100644 (file)
@@ -818,27 +818,6 @@ elf_s390_link_hash_table_create (bfd *abfd)
   return &ret->elf.root;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct elf_s390_link_hash_table *htab;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab = elf_s390_hash_table (info);
-  htab->elf.sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->elf.sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->elf.srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
-    abort ();
-
-  return TRUE;
-}
-
 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
    .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
    hash table.  */
@@ -849,14 +828,12 @@ elf_s390_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   struct elf_s390_link_hash_table *htab;
 
   htab = elf_s390_hash_table (info);
-  if (!htab->elf.sgot && !create_got_section (dynobj, info))
+  if (!htab->elf.sgot && !_bfd_elf_create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->elf.splt = bfd_get_linker_section (dynobj, ".plt");
-  htab->elf.srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
   htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!bfd_link_pic (info))
     htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
@@ -1090,7 +1067,7 @@ elf_s390_check_relocs (bfd *abfd,
            {
              if (htab->elf.dynobj == NULL)
                htab->elf.dynobj = abfd;
-             if (!create_got_section (htab->elf.dynobj, info))
+             if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
                return FALSE;
            }
        }
index 4ba3dd5ac94944689be5c5f24202f89e130ea86e..36a064d69aab19773aa191bbbfa45d582a719856 100644 (file)
@@ -1429,7 +1429,8 @@ score_elf_create_got_section (bfd *abfd,
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
-   if (s == NULL
+  elf_hash_table (info)->sgot = s;
+  if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
 
@@ -1446,6 +1447,7 @@ score_elf_create_got_section (bfd *abfd,
   h->non_elf = 0;
   h->def_regular = 1;
   h->type = STT_OBJECT;
+  elf_hash_table (info)->hgot = h;
 
   if (bfd_link_pic (info) && ! bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
@@ -3627,8 +3629,7 @@ s3_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
               break;
 
             case DT_PLTGOT:
-              name = ".got";
-              s = bfd_get_linker_section (dynobj, name);
+              s = elf_hash_table (info)->sgot;
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               break;
 
index ab980ef1f8c841172c42c486202f0455eff90da7..79d67689a1be313b53cbabd9850185259762d606 100644 (file)
@@ -1287,7 +1287,8 @@ score_elf_create_got_section (bfd *abfd,
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
   s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
-   if (s == NULL
+  elf_hash_table (info)->sgot = s;
+  if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
 
@@ -1304,6 +1305,7 @@ score_elf_create_got_section (bfd *abfd,
   h->non_elf = 0;
   h->def_regular = 1;
   h->type = STT_OBJECT;
+  elf_hash_table (info)->hgot = h;
 
   if (bfd_link_pic (info)
       && ! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -3438,8 +3440,7 @@ s7_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
               break;
 
             case DT_PLTGOT:
-              name = ".got";
-              s = bfd_get_linker_section (dynobj, name);
+              s = elf_hash_table (info)->sgot;
               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
               break;
 
index c0a3368cc88a57bee68875c54e1462c47883949b..c9a9fc384f44dbb3447447e755c99121493cc048 100644 (file)
@@ -2475,11 +2475,6 @@ struct elf_sh_link_hash_table
   struct elf_link_hash_table root;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
   asection *sfuncdesc;
@@ -2631,12 +2626,6 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   if (htab == NULL)
     return FALSE;
 
-  htab->sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
-    abort ();
-
   htab->sfuncdesc = bfd_make_section_anyway_with_flags (dynobj, ".got.funcdesc",
                                                        (SEC_ALLOC | SEC_LOAD
                                                         | SEC_HAS_CONTENTS
@@ -2718,7 +2707,7 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     pltflags |= SEC_READONLY;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
-  htab->splt = s;
+  htab->root.splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -2750,12 +2739,12 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                                          bed->default_use_rela_p
                                          ? ".rela.plt" : ".rel.plt",
                                          flags | SEC_READONLY);
-  htab->srelplt = s;
+  htab->root.srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
-  if (htab->sgot == NULL
+  if (htab->root.sgot == NULL
       && !create_got_section (abfd, info))
     return FALSE;
 
@@ -2989,7 +2978,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       if (bfd_link_pic (info)
          || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
        {
-         asection *s = htab->splt;
+         asection *s = htab->root.splt;
          const struct elf_sh_plt_info *plt_info;
 
          /* If this is the first .plt entry, make room for the special
@@ -3022,12 +3011,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
          /* We also need to make an entry in the .got.plt section, which
             will be placed in the .got section by the linker script.  */
          if (!htab->fdpic_p)
-           htab->sgotplt->size += 4;
+           htab->root.sgotplt->size += 4;
          else
-           htab->sgotplt->size += 8;
+           htab->root.sgotplt->size += 8;
 
          /* We also need to make an entry in the .rel.plt section.  */
-         htab->srelplt->size += sizeof (Elf32_External_Rela);
+         htab->root.srelplt->size += sizeof (Elf32_External_Rela);
 
          if (htab->vxworks_p && !bfd_link_pic (info))
            {
@@ -3073,7 +3062,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            return FALSE;
        }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
       h->got.offset = s->size;
       s->size += 4;
       /* R_SH_TLS_GD needs 2 consecutive GOT slots.  */
@@ -3097,21 +3086,21 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
         R_SH_TLS_GD needs one if local symbol and two if global.  */
       else if ((got_type == GOT_TLS_GD && h->dynindx == -1)
               || got_type == GOT_TLS_IE)
-       htab->srelgot->size += sizeof (Elf32_External_Rela);
+       htab->root.srelgot->size += sizeof (Elf32_External_Rela);
       else if (got_type == GOT_TLS_GD)
-       htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+       htab->root.srelgot->size += 2 * sizeof (Elf32_External_Rela);
       else if (got_type == GOT_FUNCDESC)
        {
          if (!bfd_link_pic (info) && SYMBOL_FUNCDESC_LOCAL (info, h))
            htab->srofixup->size += 4;
          else
-           htab->srelgot->size += sizeof (Elf32_External_Rela);
+           htab->root.srelgot->size += sizeof (Elf32_External_Rela);
        }
       else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
                || h->root.type != bfd_link_hash_undefweak)
               && (bfd_link_pic (info)
                   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
-       htab->srelgot->size += sizeof (Elf32_External_Rela);
+       htab->root.srelgot->size += sizeof (Elf32_External_Rela);
       else if (htab->fdpic_p
               && !bfd_link_pic (info)
               && got_type == GOT_NORMAL
@@ -3137,12 +3126,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            return FALSE;
        }
 
-      s = htab->sgot;
+      s = htab->root.sgot;
       eh->datalabel_got.offset = s->size;
       s->size += 4;
       dyn = htab->root.dynamic_sections_created;
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h))
-       htab->srelgot->size += sizeof (Elf32_External_Rela);
+       htab->root.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     eh->datalabel_got.offset = (bfd_vma) -1;
@@ -3161,7 +3150,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       if (!bfd_link_pic (info) && SYMBOL_FUNCDESC_LOCAL (info, h))
        htab->srofixup->size += eh->abs_funcdesc_refcount * 4;
       else
-       htab->srelgot->size
+       htab->root.srelgot->size
          += eh->abs_funcdesc_refcount * sizeof (Elf32_External_Rela);
     }
 
@@ -3425,8 +3414,8 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Count datalabel local GOT.  */
       locsymcount *= 2;
 #endif
-      s = htab->sgot;
-      srel = htab->srelgot;
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
 
       local_got = elf_local_got_refcounts (ibfd);
       if (local_got)
@@ -3499,9 +3488,9 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       /* Allocate 2 got entries and 1 dynamic reloc for R_SH_TLS_LD_32
         relocs.  */
-      htab->tls_ldm_got.offset = htab->sgot->size;
-      htab->sgot->size += 8;
-      htab->srelgot->size += sizeof (Elf32_External_Rela);
+      htab->tls_ldm_got.offset = htab->root.sgot->size;
+      htab->root.sgot->size += 8;
+      htab->root.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
@@ -3510,8 +3499,8 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
      the end of .got.plt.  */
   if (htab->fdpic_p)
     {
-      BFD_ASSERT (htab->sgotplt && htab->sgotplt->size == 12);
-      htab->sgotplt->size = 0;
+      BFD_ASSERT (htab->root.sgotplt && htab->root.sgotplt->size == 12);
+      htab->root.sgotplt->size = 0;
     }
 
   /* Allocate global sym .plt and .got entries, and space for global
@@ -3522,8 +3511,8 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
      end of the FDPIC .got.plt.  */
   if (htab->fdpic_p)
     {
-      htab->root.hgot->root.u.def.value = htab->sgotplt->size;
-      htab->sgotplt->size += 12;
+      htab->root.hgot->root.u.def.value = htab->root.sgotplt->size;
+      htab->root.sgotplt->size += 12;
     }
 
   /* At the very end of the .rofixup section is a pointer to the GOT.  */
@@ -3538,9 +3527,9 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if ((s->flags & SEC_LINKER_CREATED) == 0)
        continue;
 
-      if (s == htab->splt
-         || s == htab->sgot
-         || s == htab->sgotplt
+      if (s == htab->root.splt
+         || s == htab->root.sgot
+         || s == htab->root.sgotplt
          || s == htab->sfuncdesc
          || s == htab->srofixup
          || s == htab->sdynbss)
@@ -3550,7 +3539,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
        {
-         if (s->size != 0 && s != htab->srelplt && s != htab->srelplt2)
+         if (s->size != 0 && s != htab->root.srelplt && s != htab->srelplt2)
            relocs = TRUE;
 
          /* We use the reloc_count field as a counter if we need
@@ -3608,7 +3597,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            return FALSE;
        }
 
-      if (htab->splt->size != 0)
+      if (htab->root.splt->size != 0)
        {
          if (! add_dynamic_entry (DT_PLTGOT, 0)
              || ! add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -3690,7 +3679,7 @@ sh_elf_add_rofixup (bfd *output_bfd, asection *srofixup, bfd_vma offset)
 static bfd_signed_vma
 sh_elf_got_offset (struct elf_sh_link_hash_table *htab)
 {
-  return (htab->sgot->output_offset - htab->sgotplt->output_offset
+  return (htab->root.sgot->output_offset - htab->root.sgotplt->output_offset
          - htab->root.hgot->root.u.def.value);
 }
 
@@ -3837,7 +3826,6 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   Elf_Internal_Rela *rel, *relend;
-  bfd *dynobj = NULL;
   bfd_vma *local_got_offsets;
   asection *sgot = NULL;
   asection *sgotplt = NULL;
@@ -3853,10 +3841,10 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   htab = sh_elf_hash_table (info);
   if (htab != NULL)
     {
-      dynobj = htab->root.dynobj;
-      sgot = htab->sgot;
-      sgotplt = htab->sgotplt;
-      splt = htab->splt;
+      sgot = htab->root.sgot;
+      sgotplt = htab->root.sgotplt;
+      srelgot = htab->root.srelgot;
+      splt = htab->root.splt;
       fdpic_p = htab->fdpic_p;
     }
   symtab_hdr = &elf_symtab_hdr (input_bfd);
@@ -4628,13 +4616,6 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                      Elf_Internal_Rela outrel;
                      bfd_byte *loc;
 
-                     if (srelgot == NULL)
-                       {
-                         srelgot = bfd_get_linker_section (dynobj,
-                                                           ".rela.got");
-                         BFD_ASSERT (srelgot != NULL);
-                       }
-
                      outrel.r_offset = (sgot->output_section->vma
                                         + sgot->output_offset
                                         + off);
@@ -4951,12 +4932,6 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                    return FALSE;
                  }
 
-               if (srelgot == NULL)
-                 {
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-                   BFD_ASSERT (srelgot != NULL);
-                 }
-
                offset = _bfd_elf_section_offset (output_bfd, info,
                                                  reloc_section, reloc_offset);
 
@@ -5242,12 +5217,6 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              bfd_byte *loc;
              int dr_type, indx;
 
-             if (srelgot == NULL)
-               {
-                 srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-                 BFD_ASSERT (srelgot != NULL);
-               }
-
              outrel.r_offset = (sgot->output_section->vma
                                 + sgot->output_offset + off);
 
@@ -5417,10 +5386,6 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              Elf_Internal_Rela outrel;
              bfd_byte *loc;
 
-             srelgot = htab->srelgot;
-             if (srelgot == NULL)
-               abort ();
-
              outrel.r_offset = (sgot->output_section->vma
                                 + sgot->output_offset + off);
              outrel.r_addend = 0;
@@ -5895,7 +5860,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          }
 
       /* Some relocs require a global offset table.  */
-      if (htab->sgot == NULL)
+      if (htab->root.sgot == NULL)
        {
          switch (r_type)
            {
@@ -6145,7 +6110,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
                  if (!bfd_link_pic (info))
                    htab->srofixup->size += 4;
                  else
-                   htab->srelgot->size += sizeof (Elf32_External_Rela);
+                   htab->root.srelgot->size += sizeof (Elf32_External_Rela);
                }
            }
          else
@@ -6583,9 +6548,9 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = htab->splt;
-      sgotplt = htab->sgotplt;
-      srelplt = htab->srelplt;
+      splt = htab->root.splt;
+      sgotplt = htab->root.sgotplt;
+      srelplt = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgotplt != NULL && srelplt != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -6711,8 +6676,7 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
                  sgotplt->contents + got_offset);
       if (htab->fdpic_p)
        bfd_put_32 (output_bfd,
-                   sh_elf_osec_to_segment (output_bfd,
-                                           htab->splt->output_section),
+                   sh_elf_osec_to_segment (output_bfd, splt->output_section),
                    sgotplt->contents + got_offset + 4);
 
       /* Fill in the entry in the .rela.plt section.  */
@@ -6739,8 +6703,8 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
          /* Create a .rela.plt.unloaded R_SH_DIR32 relocation
             for the PLT entry's pointer to the .got.plt entry.  */
-         rel.r_offset = (htab->splt->output_section->vma
-                         + htab->splt->output_offset
+         rel.r_offset = (splt->output_section->vma
+                         + splt->output_offset
                          + h->plt.offset
                          + plt_info->symbol_fields.got_entry);
          rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_SH_DIR32);
@@ -6779,8 +6743,8 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
 
-      sgot = htab->sgot;
-      srelgot = htab->srelgot;
+      sgot = htab->root.sgot;
+      srelgot = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -6840,8 +6804,8 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
        /* This symbol has a datalabel entry in the global offset table.
           Set it up.  */
 
-       sgot = htab->sgot;
-       srelgot = htab->srelgot;
+       sgot = htab->root.sgot;
+       srelgot = htab->root.srelgot;
        BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
        rel.r_offset = (sgot->output_section->vma
@@ -6936,7 +6900,7 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (htab == NULL)
     return FALSE;
 
-  sgotplt = htab->sgotplt;
+  sgotplt = htab->root.sgotplt;
   sdyn = bfd_get_linker_section (htab->root.dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
@@ -6998,14 +6962,14 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              break;
 
            case DT_JMPREL:
-             s = htab->srelplt->output_section;
+             s = htab->root.srelplt->output_section;
              BFD_ASSERT (s != NULL);
              dyn.d_un.d_ptr = s->vma;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = htab->srelplt->output_section;
+             s = htab->root.srelplt->output_section;
              BFD_ASSERT (s != NULL);
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -7021,9 +6985,9 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
                 the linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             if (htab->srelplt != NULL)
+             if (htab->root.srelplt != NULL)
                {
-                 s = htab->srelplt->output_section;
+                 s = htab->root.srelplt->output_section;
                  dyn.d_un.d_val -= s->size;
                }
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -7032,7 +6996,7 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
        }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = htab->splt;
+      splt = htab->root.splt;
       if (splt && splt->size > 0 && htab->plt_info->plt0_entry)
        {
          unsigned int i;
@@ -7128,9 +7092,9 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
     BFD_ASSERT (htab->srelfuncdesc->reloc_count * sizeof (Elf32_External_Rela)
                == htab->srelfuncdesc->size);
 
-  if (htab->srelgot)
-    BFD_ASSERT (htab->srelgot->reloc_count * sizeof (Elf32_External_Rela)
-               == htab->srelgot->size);
+  if (htab->root.srelgot)
+    BFD_ASSERT (htab->root.srelgot->reloc_count * sizeof (Elf32_External_Rela)
+               == htab->root.srelgot->size);
 
   return TRUE;
 }
index f2710fff71a6c09a7072317692a0dc39d2050a17..80ddfaff0bdf961ae9f13835ddcd45315b014c78 100644 (file)
@@ -1735,11 +1735,9 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd,
                                   struct elf_link_hash_entry *h,
                                   Elf_Internal_Sym * sym)
 {
-  bfd *dynobj;
   struct elf32_tic6x_link_hash_table *htab;
 
   htab = elf32_tic6x_hash_table (info);
-  dynobj = htab->elf.dynobj;
 
   if (h->plt.offset != (bfd_vma) -1)
     {
@@ -1839,8 +1837,8 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd,
       /* This symbol has an entry in the global offset table.
          Set it up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = htab->elf.sgot;
+      srela = htab->elf.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       /* If this is a -Bsymbolic link, and the symbol is defined
index ebd5046c46c8be8f9a93b8fb3abb4842c90278e8..9430b78000f9b58d4e6535a4ef3ddc3e55368d95 100644 (file)
@@ -1234,8 +1234,7 @@ tilepro_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
-  if (s != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
index 02b69a1d0db8e60de18496eb15cf729dd5e14e3c..d7c6137554ecd5d238f6bc17f60f5c41179d9a00 100644 (file)
@@ -561,8 +561,6 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
   struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
-  asection *sgot;
-  asection *srelgot;
   asection *sreloc;
 
   if (bfd_link_relocatable (info))
@@ -572,8 +570,6 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
 
-  sgot = NULL;
-  srelgot = NULL;
   sreloc = NULL;
 
   rel_end = relocs + sec->reloc_count;
@@ -620,31 +616,6 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
                return FALSE;
            }
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
-
          if (h != NULL)
            {
              struct elf_vax_link_hash_entry *eh;
@@ -957,7 +928,7 @@ elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info,
          return TRUE;
        }
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = elf_hash_table (info)->splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -987,13 +958,13 @@ elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info,
       /* We also need to make an entry in the .got.plt section, which
         will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = elf_hash_table (info)->sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = elf_hash_table (info)->srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -1088,13 +1059,13 @@ elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         not actually use these entries.  Reset the size of .rela.got
         and .got, which will cause them to get stripped from the output
         file below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = 0;
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = elf_hash_table (info)->sgotplt;
       if (s != NULL)
        s->size = 0;
-      s = bfd_get_linker_section (dynobj, ".got");
+      s = elf_hash_table (info)->sgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -1324,8 +1295,8 @@ elf_vax_instantiate_got_entries (struct elf_link_hash_entry *h, void * infoptr)
   dynobj = elf_hash_table (info)->dynobj;
   BFD_ASSERT (dynobj != NULL);
 
-  sgot = bfd_get_linker_section (dynobj, ".got");
-  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  sgot = elf_hash_table (info)->sgot;
+  srelgot = elf_hash_table (info)->srelgot;
 
   if (SYMBOL_REFERENCES_LOCAL (info, h))
     {
@@ -1361,7 +1332,6 @@ elf_vax_relocate_section (bfd *output_bfd,
                          Elf_Internal_Sym *local_syms,
                          asection **local_sections)
 {
-  bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   bfd_vma plt_index;
@@ -1373,7 +1343,6 @@ elf_vax_relocate_section (bfd *output_bfd,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
-  dynobj = elf_hash_table (info)->dynobj;
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -1478,11 +1447,8 @@ elf_vax_relocate_section (bfd *output_bfd,
          {
            bfd_vma off;
 
-           if (sgot == NULL)
-             {
-               sgot = bfd_get_linker_section (dynobj, ".got");
-               BFD_ASSERT (sgot != NULL);
-             }
+           sgot = elf_hash_table (info)->sgot;
+           BFD_ASSERT (sgot != NULL);
 
            off = h->got.offset;
            BFD_ASSERT (off < sgot->size);
@@ -1517,17 +1483,11 @@ elf_vax_relocate_section (bfd *output_bfd,
              || h->plt.offset == (bfd_vma) -1)
            break;
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
-         if (sgotplt == NULL)
-           {
-             sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-             BFD_ASSERT (sgotplt != NULL);
-           }
+         sgotplt = elf_hash_table (info)->sgotplt;
+         BFD_ASSERT (sgotplt != NULL);
 
          plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
 
@@ -1782,9 +1742,9 @@ elf_vax_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
         it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgot = bfd_get_linker_section (dynobj, ".got.plt");
-      srela = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = elf_hash_table (info)->splt;
+      sgot = elf_hash_table (info)->sgotplt;
+      srela = elf_hash_table (info)->srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       addend = 2 * (h->plt.offset & 1);
@@ -1846,8 +1806,8 @@ elf_vax_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srela = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -1904,7 +1864,7 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -1913,7 +1873,7 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -1921,7 +1881,6 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char *name;
          asection *s;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -1932,18 +1891,17 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              break;
 
            case DT_PLTGOT:
-             name = ".got.plt";
+             s = elf_hash_table (info)->sgotplt;
              goto get_vma;
            case DT_JMPREL:
-             name = ".rela.plt";
+             s = elf_hash_table (info)->srelplt;
            get_vma:
-             s = bfd_get_linker_section (dynobj, name);
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -1956,7 +1914,7 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
                 linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s != NULL)
                dyn.d_un.d_val -= s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
index cab0f23794dce6938251fb1c2ada053927437325..1c458a587afb0f9b7caf0f00beb01351e8364bd8 100644 (file)
@@ -417,7 +417,6 @@ xstormy16_elf_check_relocs (bfd *abfd,
   symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
-  splt = NULL;
   dynobj = elf_hash_table(info)->dynobj;
 
   relend = relocs + sec->reloc_count;
@@ -457,21 +456,19 @@ xstormy16_elf_check_relocs (bfd *abfd,
 
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
+         splt = elf_hash_table (info)->splt;
          if (splt == NULL)
            {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             if (splt == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY | SEC_CODE);
-
-                 splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
-                                                            flags);
-                 if (splt == NULL
-                     || ! bfd_set_section_alignment (dynobj, splt, 1))
-                   return FALSE;
-               }
+             flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                               | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                               | SEC_READONLY | SEC_CODE);
+
+             splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+                                                        flags);
+             elf_hash_table (info)->splt = splt;
+             if (splt == NULL
+                 || ! bfd_set_section_alignment (dynobj, splt, 1))
+               return FALSE;
            }
 
          if (h != NULL)
@@ -719,7 +716,7 @@ xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
   BFD_ASSERT (splt != NULL);
 
   splt->contents = bfd_zalloc (dynobj, splt->size);
@@ -773,17 +770,13 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
   struct elf_link_hash_entry ** sym_hashes;
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
-  bfd *dynobj;
   asection *splt;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
-  dynobj = elf_hash_table (info)->dynobj;
-  splt = NULL;
-  if (dynobj != NULL)
-    splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -962,14 +955,13 @@ static bfd_boolean
 xstormy16_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
                                       struct bfd_link_info *info)
 {
-  bfd *dynobj;
-  asection *splt;
+  bfd *dynobj = elf_hash_table (info)->dynobj;
+  asection *splt = elf_hash_table (info)->splt;
 
   /* As an extra sanity check, verify that all plt entries have
      been filled in.  */
 
-  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
+  if (dynobj != NULL && splt != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
index 99d56bf3f4e09190fa11ec01996a4dd854320594..c4a00642834ba57b710c7825a85e7054d891f26f 100644 (file)
@@ -600,11 +600,6 @@ struct elf_xtensa_link_hash_table
   struct elf_link_hash_table elf;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sgotloc;
   asection *spltlittbl;
 
@@ -1423,11 +1418,6 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   /* First do all the standard stuff.  */
   if (! _bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
-  htab->splt = bfd_get_linker_section (dynobj, ".plt");
-  htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
-  htab->sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
   /* Create any extra PLT sections in case check_relocs has already
      been called on all the non-dynamic input files.  */
@@ -1439,8 +1429,8 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
   flags = noalloc_flags | SEC_ALLOC | SEC_LOAD;
 
   /* Mark the ".got.plt" section READONLY.  */
-  if (htab->sgotplt == NULL
-      || ! bfd_set_section_flags (dynobj, htab->sgotplt, flags))
+  if (htab->elf.sgotplt == NULL
+      || ! bfd_set_section_flags (dynobj, htab->elf.sgotplt, flags))
     return FALSE;
 
   /* Create ".got.loc" (literal tables for use by dynamic linker).  */
@@ -1558,10 +1548,10 @@ elf_xtensa_allocate_dynrelocs (struct elf_link_hash_entry *h, void *arg)
     elf_xtensa_make_sym_local (info, h);
 
   if (h->plt.refcount > 0)
-    htab->srelplt->size += (h->plt.refcount * sizeof (Elf32_External_Rela));
+    htab->elf.srelplt->size += (h->plt.refcount * sizeof (Elf32_External_Rela));
 
   if (h->got.refcount > 0)
-    htab->srelgot->size += (h->got.refcount * sizeof (Elf32_External_Rela));
+    htab->elf.srelgot->size += (h->got.refcount * sizeof (Elf32_External_Rela));
 
   return TRUE;
 }
@@ -1603,8 +1593,8 @@ elf_xtensa_allocate_local_got_size (struct bfd_link_info *info)
            }
 
          if (local_got_refcounts[j] > 0)
-           htab->srelgot->size += (local_got_refcounts[j]
-                                   * sizeof (Elf32_External_Rela));
+           htab->elf.srelgot->size += (local_got_refcounts[j]
+                                       * sizeof (Elf32_External_Rela));
        }
     }
 }
@@ -1632,14 +1622,14 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   dynobj = elf_hash_table (info)->dynobj;
   if (dynobj == NULL)
     abort ();
-  srelgot = htab->srelgot;
-  srelplt = htab->srelplt;
+  srelgot = htab->elf.srelgot;
+  srelplt = htab->elf.srelplt;
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
-      BFD_ASSERT (htab->srelgot != NULL
-                 && htab->srelplt != NULL
-                 && htab->sgot != NULL
+      BFD_ASSERT (htab->elf.srelgot != NULL
+                 && htab->elf.srelplt != NULL
+                 && htab->elf.sgot != NULL
                  && htab->spltlittbl != NULL
                  && htab->sgotloc != NULL);
 
@@ -1654,7 +1644,7 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
 
       /* Allocate room for one word in ".got".  */
-      htab->sgot->size = 4;
+      htab->elf.sgot->size = 4;
 
       /* Allocate space in ".rela.got" for literals that reference global
         symbols and space in ".rela.plt" for literals that have PLT
@@ -2840,9 +2830,9 @@ elf_xtensa_relocate_section (bfd *output_bfd,
              asection *srel;
 
              if (dynamic_symbol && r_type == R_XTENSA_PLT)
-               srel = htab->srelplt;
+               srel = htab->elf.srelplt;
              else
-               srel = htab->srelgot;
+               srel = htab->elf.srelgot;
 
              BFD_ASSERT (srel != NULL);
 
@@ -2969,7 +2959,7 @@ elf_xtensa_relocate_section (bfd *output_bfd,
              {
                Elf_Internal_Rela outrel;
                bfd_byte *loc;
-               asection *srel = htab->srelgot;
+               asection *srel = htab->elf.srelgot;
                int indx;
 
                outrel.r_offset = (input_section->output_section->vma
@@ -3282,7 +3272,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
 
   /* Set the first entry in the global offset table to the address of
      the dynamic section.  */
-  sgot = htab->sgot;
+  sgot = htab->elf.sgot;
   if (sgot)
     {
       BFD_ASSERT (sgot->size == 4);
@@ -3294,7 +3284,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
                    sgot->contents);
     }
 
-  srelplt = htab->srelplt;
+  srelplt = htab->elf.srelplt;
   if (srelplt && srelplt->size != 0)
     {
       asection *sgotplt, *srelgot, *spltlittbl;
@@ -3303,7 +3293,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
       bfd_byte *loc;
       unsigned rtld_reloc;
 
-      srelgot = htab->srelgot;
+      srelgot = htab->elf.srelgot;
       spltlittbl = htab->spltlittbl;
       BFD_ASSERT (srelgot != NULL && spltlittbl != NULL);
 
@@ -3427,17 +3417,17 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
          break;
 
        case DT_PLTGOT:
-         dyn.d_un.d_ptr = (htab->sgot->output_section->vma
-                           + htab->sgot->output_offset);
+         dyn.d_un.d_ptr = (htab->elf.sgot->output_section->vma
+                           + htab->elf.sgot->output_offset);
          break;
 
        case DT_JMPREL:
-         dyn.d_un.d_ptr = (htab->srelplt->output_section->vma
-                           + htab->srelplt->output_offset);
+         dyn.d_un.d_ptr = (htab->elf.srelplt->output_section->vma
+                           + htab->elf.srelplt->output_offset);
          break;
 
        case DT_PLTRELSZ:
-         dyn.d_un.d_val = htab->srelplt->size;
+         dyn.d_un.d_val = htab->elf.srelplt->size;
          break;
 
        case DT_RELASZ:
@@ -3447,8 +3437,8 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
             seems to be unresolved.  Since the linker script arranges
             for .rela.plt to follow all other relocation sections, we
             don't have to worry about changing the DT_RELA entry.  */
-         if (htab->srelplt)
-           dyn.d_un.d_val -= htab->srelplt->size;
+         if (htab->elf.srelplt)
+           dyn.d_un.d_val -= htab->elf.srelplt->size;
          break;
        }
 
@@ -10132,11 +10122,11 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
 
       if (dynamic_symbol && r_type == R_XTENSA_PLT)
        {
-         srel = htab->srelplt;
+         srel = htab->elf.srelplt;
          is_plt = TRUE;
        }
       else
-       srel = htab->srelgot;
+       srel = htab->elf.srelgot;
 
       /* Reduce size of the .rela.* section by one reloc.  */
       BFD_ASSERT (srel != NULL);
@@ -10165,7 +10155,7 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
          if (reloc_index % PLT_ENTRIES_PER_CHUNK == 0)
            {
              /* The two magic GOT entries for that chunk can go away.  */
-             srelgot = htab->srelgot;
+             srelgot = htab->elf.srelgot;
              BFD_ASSERT (srelgot != NULL);
              srelgot->reloc_count -= 2;
              srelgot->size -= 2 * sizeof (Elf32_External_Rela);
@@ -10842,18 +10832,11 @@ do_fix_for_final_link (Elf_Internal_Rela *rel,
 static asection *
 elf_xtensa_get_plt_section (struct bfd_link_info *info, int chunk)
 {
-  struct elf_xtensa_link_hash_table *htab;
   bfd *dynobj;
   char plt_name[10];
 
   if (chunk == 0)
-    {
-      htab = elf_xtensa_hash_table (info);
-      if (htab == NULL)
-       return NULL;
-
-      return htab->splt;
-    }
+    return elf_hash_table (info)->splt;
 
   dynobj = elf_hash_table (info)->dynobj;
   sprintf (plt_name, ".plt.%u", chunk);
@@ -10864,17 +10847,11 @@ elf_xtensa_get_plt_section (struct bfd_link_info *info, int chunk)
 static asection *
 elf_xtensa_get_gotplt_section (struct bfd_link_info *info, int chunk)
 {
-  struct elf_xtensa_link_hash_table *htab;
   bfd *dynobj;
   char got_name[14];
 
   if (chunk == 0)
-    {
-      htab = elf_xtensa_hash_table (info);
-      if (htab == NULL)
-       return NULL;
-      return htab->sgotplt;
-    }
+    return elf_hash_table (info)->sgotplt;
 
   dynobj = elf_hash_table (info)->dynobj;
   sprintf (got_name, ".got.plt.%u", chunk);
@@ -11257,7 +11234,7 @@ xtensa_callback_required_dependence (bfd *abfd,
 
       /* Find the corresponding ".got.plt*" section.  */
       if (sec->name[4] == '\0')
-       sgotplt = bfd_get_linker_section (sec->owner, ".got.plt");
+       sgotplt = elf_hash_table (link_info)->sgotplt;
       else
        {
          char got_name[14];
index bbea92ce874cea7ccd45129384d8c7a370a5feac..54205bc930e63acec82da1a83677d8620d5b5804 100644 (file)
@@ -1300,6 +1300,7 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
           | SEC_LINKER_CREATED
           | (elf64_alpha_use_secureplt ? SEC_READONLY : 0));
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags);
+  elf_hash_table (info)->splt = s;
   if (s == NULL || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
 
@@ -1314,6 +1315,7 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
           | SEC_LINKER_CREATED | SEC_READONLY);
   s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt", flags);
+  elf_hash_table (info)->srelplt = s;
   if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
 
@@ -1321,6 +1323,7 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     {
       flags = SEC_ALLOC | SEC_LINKER_CREATED;
       s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
+      elf_hash_table (info)->sgotplt = s;
       if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3))
        return FALSE;
     }
@@ -1337,6 +1340,7 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
           | SEC_LINKER_CREATED | SEC_READONLY);
   s = bfd_make_section_anyway_with_flags (abfd, ".rela.got", flags);
+  elf_hash_table (info)->srelgot = s;
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
@@ -2128,7 +2132,7 @@ elf64_alpha_adjust_dynamic_symbol (struct bfd_link_info *info,
     {
       h->needs_plt = TRUE;
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = elf_hash_table(info)->splt;
       if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info))
        return FALSE;
 
@@ -2612,15 +2616,13 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info)
 {
   asection *splt, *spltrel, *sgotplt;
   unsigned long entries;
-  bfd *dynobj;
   struct alpha_elf_link_hash_table * htab;
 
   htab = alpha_elf_hash_table (info);
   if (htab == NULL)
     return;
 
-  dynobj = elf_hash_table(info)->dynobj;
-  splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table(info)->splt;
   if (splt == NULL)
     return;
 
@@ -2630,7 +2632,7 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info)
                                elf64_alpha_size_plt_section_1, splt);
 
   /* Every plt entry requires a JMP_SLOT relocation.  */
-  spltrel = bfd_get_linker_section (dynobj, ".rela.plt");
+  spltrel = elf_hash_table(info)->srelplt;
   entries = 0;
   if (splt->size)
     {
@@ -2646,7 +2648,7 @@ elf64_alpha_size_plt_section (struct bfd_link_info *info)
      entire contents of the .got.plt section.  */
   if (elf64_alpha_use_secureplt)
     {
-      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+      sgotplt = elf_hash_table(info)->sgotplt;
       sgotplt->size = entries ? 16 : 0;
     }
 }
@@ -2806,8 +2808,7 @@ elf64_alpha_size_rela_got_1 (struct alpha_elf_link_hash_entry *h,
 
   if (entries > 0)
     {
-      bfd *dynobj = elf_hash_table(info)->dynobj;
-      asection *srel = bfd_get_linker_section (dynobj, ".rela.got");
+      asection *srel = elf_hash_table(info)->srelgot;
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf64_External_Rela) * entries;
     }
@@ -2821,7 +2822,7 @@ static void
 elf64_alpha_size_rela_got_section (struct bfd_link_info *info)
 {
   unsigned long entries;
-  bfd *i, *dynobj;
+  bfd *i;
   asection *srel;
   struct alpha_elf_link_hash_table * htab;
 
@@ -2857,8 +2858,7 @@ elf64_alpha_size_rela_got_section (struct bfd_link_info *info)
        }
     }
 
-  dynobj = elf_hash_table(info)->dynobj;
-  srel = bfd_get_linker_section (dynobj, ".rela.got");
+  srel = elf_hash_table(info)->srelgot;
   if (!srel)
     {
       BFD_ASSERT (entries == 0);
@@ -4238,10 +4238,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   symtab_hdr = &elf_symtab_hdr (input_bfd);
 
   dynobj = elf_hash_table (info)->dynobj;
-  if (dynobj)
-    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  else
-    srelgot = NULL;
+  srelgot = elf_hash_table (info)->srelgot;
 
   if (input_section->flags & SEC_ALLOC)
     {
@@ -4866,7 +4863,6 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
                                   Elf_Internal_Sym *sym)
 {
   struct alpha_elf_link_hash_entry *ah = (struct alpha_elf_link_hash_entry *)h;
-  bfd *dynobj = elf_hash_table(info)->dynobj;
 
   if (h->needs_plt)
     {
@@ -4880,9 +4876,9 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL);
-      srel = bfd_get_linker_section (dynobj, ".rela.plt");
+      srel = elf_hash_table (info)->srelplt;
       BFD_ASSERT (srel != NULL);
 
       for (gotent = ah->got_entries; gotent ; gotent = gotent->next)
@@ -4952,7 +4948,7 @@ elf64_alpha_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info,
       asection *srel;
       struct alpha_elf_got_entry *gotent;
 
-      srel = bfd_get_linker_section (dynobj, ".rela.got");
+      srel = elf_hash_table (info)->srelgot;
       BFD_ASSERT (srel != NULL);
 
       for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
@@ -5025,8 +5021,8 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd,
       Elf64_External_Dyn *dyncon, *dynconend;
       bfd_vma plt_vma, gotplt_vma;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      srelaplt = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = elf_hash_table (info)->splt;
+      srelaplt = elf_hash_table (info)->srelplt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       plt_vma = splt->output_section->vma + splt->output_offset;
@@ -5034,7 +5030,7 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd,
       gotplt_vma = 0;
       if (elf64_alpha_use_secureplt)
        {
-         sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+         sgotplt = elf_hash_table (info)->sgotplt;
          BFD_ASSERT (sgotplt != NULL);
          if (sgotplt->size > 0)
            gotplt_vma = sgotplt->output_section->vma + sgotplt->output_offset;
index dbeda1c991ba74437ac619640f898bc2fe652889..a9e8d0c7cf5ecd48019904bd5213aa3189b4cb98 100644 (file)
@@ -1537,7 +1537,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (hppa_info == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = hppa_info->root.dynobj;
   BFD_ASSERT (dynobj != NULL);
 
   /* Mark each function this program exports so that we will allocate
@@ -1547,13 +1547,13 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 
      We have to traverse the main linker hash table since we have to
      find functions which may not have been mentioned in any relocs.  */
-  elf_link_hash_traverse (elf_hash_table (info),
-                         (elf_hash_table (info)->dynamic_sections_created
+  elf_link_hash_traverse (&hppa_info->root,
+                         (hppa_info->root.dynamic_sections_created
                           ? elf64_hppa_mark_milli_and_exported_functions
                           : elf64_hppa_mark_exported_functions),
                          info);
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (hppa_info->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
@@ -1571,7 +1571,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
         not actually use these entries.  Reset the size of .rela.dlt,
         which will cause it to get stripped from the output file
         below.  */
-      sec = bfd_get_linker_section (dynobj, ".rela.dlt");
+      sec = hppa_info->dlt_rel_sec;
       if (sec != NULL)
        sec->size = 0;
     }
@@ -1703,7 +1703,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (hppa_info->dlt_sec)
     {
       data.ofs = hppa_info->dlt_sec->size;
-      elf_link_hash_traverse (elf_hash_table (info),
+      elf_link_hash_traverse (&hppa_info->root,
                              allocate_global_data_dlt, &data);
       hppa_info->dlt_sec->size = data.ofs;
     }
@@ -1711,7 +1711,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (hppa_info->plt_sec)
     {
       data.ofs = hppa_info->plt_sec->size;
-      elf_link_hash_traverse (elf_hash_table (info),
+      elf_link_hash_traverse (&hppa_info->root,
                              allocate_global_data_plt, &data);
       hppa_info->plt_sec->size = data.ofs;
     }
@@ -1719,7 +1719,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (hppa_info->stub_sec)
     {
       data.ofs = 0x0;
-      elf_link_hash_traverse (elf_hash_table (info),
+      elf_link_hash_traverse (&hppa_info->root,
                              allocate_global_data_stub, &data);
       hppa_info->stub_sec->size = data.ofs;
     }
@@ -1728,14 +1728,14 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (hppa_info->opd_sec)
     {
       data.ofs = hppa_info->opd_sec->size;
-      elf_link_hash_traverse (elf_hash_table (info),
+      elf_link_hash_traverse (&hppa_info->root,
                              allocate_global_data_opd, &data);
       hppa_info->opd_sec->size = data.ofs;
     }
 
   /* Now allocate space for dynamic relocations, if necessary.  */
   if (hppa_info->root.dynamic_sections_created)
-    elf_link_hash_traverse (elf_hash_table (info),
+    elf_link_hash_traverse (&hppa_info->root,
                            allocate_dynrel_entries, &data);
 
   /* The sizes of all the sections are set.  Allocate memory for them.  */
@@ -1836,7 +1836,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
        }
     }
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (hppa_info->root.dynamic_sections_created)
     {
       /* Always create a DT_PLTGOT.  It actually has nothing to do with
         the PLT, it is how we communicate the __gp value of a load
index fa7c0be699df264efbd154af2376f9d3dda2f0bf..46d3099134efe904ce33df3d4e57c027533a58ca 100644 (file)
@@ -730,30 +730,6 @@ elf_s390_link_hash_table_create (bfd *abfd)
   return &ret->elf.root;
 }
 
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
-   shortcuts to them in our hash table.  */
-
-static bfd_boolean
-create_got_section (bfd *dynobj,
-                   struct bfd_link_info *info)
-{
-  struct elf_s390_link_hash_table *htab;
-
-  if (! _bfd_elf_create_got_section (dynobj, info))
-    return FALSE;
-
-  htab = elf_s390_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  htab->elf.sgot = bfd_get_linker_section (dynobj, ".got");
-  htab->elf.sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-  htab->elf.srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-  if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
-    abort ();
-  return TRUE;
-}
-
 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
    .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
    hash table.  */
@@ -768,14 +744,12 @@ elf_s390_create_dynamic_sections (bfd *dynobj,
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->elf.sgot && !create_got_section (dynobj, info))
+  if (!htab->elf.sgot && !_bfd_elf_create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->elf.splt = bfd_get_linker_section (dynobj, ".plt");
-  htab->elf.srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
   htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!bfd_link_pic (info))
     htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
@@ -1016,7 +990,7 @@ elf_s390_check_relocs (bfd *abfd,
            {
              if (htab->elf.dynobj == NULL)
                htab->elf.dynobj = abfd;
-             if (!create_got_section (htab->elf.dynobj, info))
+             if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
                return FALSE;
            }
        }
index 81cfa00fa59db7fcd5e3ff5ca355d9e8540b3100..352fd2973dc8d89cbb0098ed2dab1cd0edae562e 100644 (file)
@@ -1432,7 +1432,6 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   Elf_Internal_Rela *rel, *relend;
-  bfd *dynobj;
   bfd_vma *local_got_offsets;
   asection *sgot;
   asection *sgotplt;
@@ -1442,12 +1441,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
-  dynobj = elf_hash_table (info)->dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
 
-  sgot = NULL;
-  sgotplt = NULL;
-  splt = NULL;
   sreloc = NULL;
 
   rel = relocs;
@@ -1794,11 +1789,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
          /* Relocation is to the entry for this symbol in the global
             offset table extension for the procedure linkage table.  */
-         if (sgotplt == NULL)
-           {
-             sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-             BFD_ASSERT (sgotplt != NULL);
-           }
+         sgotplt = elf_hash_table (info)->sgotplt;
+         BFD_ASSERT (sgotplt != NULL);
 
          relocation = (sgotplt->output_offset
                        + ((h->plt.offset / elf_sh64_sizeof_plt (info)
@@ -1817,11 +1809,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        case R_SH_GOT10BY8:
          /* Relocation is to the entry for this symbol in the global
             offset table.  */
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
+         sgot = elf_hash_table (info)->sgot;
+         BFD_ASSERT (sgot != NULL);
 
          if (h != NULL)
            {
@@ -1913,7 +1902,7 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                      Elf_Internal_Rela outrel;
                      bfd_byte *loc;
 
-                     s = bfd_get_linker_section (dynobj, ".rela.got");
+                     s = elf_hash_table (info)->srelgot;
                      BFD_ASSERT (s != NULL);
 
                      outrel.r_offset = (sgot->output_section->vma
@@ -1946,11 +1935,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          /* Relocation is relative to the start of the global offset
             table.  */
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
+         sgot = elf_hash_table (info)->sgot;
+         BFD_ASSERT (sgot != NULL);
 
          /* Note that sgot->output_offset is not involved in this
             calculation.  We always want the start of .got.  If we
@@ -1971,11 +1957,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        case R_SH_GOTPC_HI16:
          /* Use global offset table as symbol value.  */
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
+         sgot = elf_hash_table (info)->sgot;
+         BFD_ASSERT (sgot != NULL);
 
          relocation = sgot->output_section->vma;
 
@@ -2009,11 +1992,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
              goto final_link_relocate;
            }
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
          relocation = (splt->output_section->vma
                        + splt->output_offset
@@ -2376,8 +2356,6 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   asection *srelgot;
   asection *sreloc;
 
-  sgot = NULL;
-  srelgot = NULL;
   sreloc = NULL;
 
   if (bfd_link_relocatable (info))
@@ -2472,29 +2450,9 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_SH_GOT10BY8:
          /* This symbol requires a global offset table entry.  */
 
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_linker_section (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || ! bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
+         sgot = elf_hash_table (info)->sgot;
+         srelgot = elf_hash_table (info)->srelgot;
+         BFD_ASSERT (sgot != NULL && srelgot != NULL);
 
          if (h != NULL)
            {
@@ -3267,7 +3225,7 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info,
            return FALSE;
        }
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = elf_hash_table (info)->splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3295,13 +3253,13 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info,
       /* We also need to make an entry in the .got.plt section, which
         will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = elf_hash_table (info)->sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 8;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = elf_hash_table (info)->srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf64_External_Rela);
 
@@ -3421,7 +3379,7 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd,
         not actually use these entries.  Reset the size of .rela.got,
         which will cause it to get stripped from the output file
         below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -3590,9 +3548,9 @@ sh64_elf64_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgot = bfd_get_linker_section (dynobj, ".got.plt");
-      srel = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = elf_hash_table (info)->splt;
+      sgot = elf_hash_table (info)->sgotplt;
+      srel = elf_hash_table (info)->srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -3693,8 +3651,8 @@ sh64_elf64_finish_dynamic_symbol (bfd *output_bfd,
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srel = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srel = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -3772,7 +3730,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -3819,19 +3777,18 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_PLTGOT:
-             name = ".got.plt";
+             s = elf_hash_table (info)->sgotplt;
              goto get_vma;
 
            case DT_JMPREL:
-             name = ".rela.plt";
+             s = elf_hash_table (info)->srelplt;
            get_vma:
-             s = bfd_get_linker_section (dynobj, name);
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
@@ -3846,7 +3803,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
                 the linker script arranges for .rela.plt to follow all
                 other relocation sections, we don't have to worry
                 about changing the DT_RELA entry.  */
-             s = bfd_get_linker_section (dynobj, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s != NULL)
                dyn.d_un.d_val -= s->size;
              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -3855,7 +3812,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
        }
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       if (splt && splt->size > 0)
        {
          if (bfd_link_pic (info))
index 76f91e93dbf78dcef87a899f11fbfc9634b5838b..daf4b82e9479d4e2af612493a2ceb8b916286ed3 100644 (file)
@@ -149,8 +149,7 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
-  if (s != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
index 4ebdbe20d7178ce46e6b8f2a77784ec00c2fff92..0b5e655e3cdb5fda277bf19d2297802dfaecae7e 100644 (file)
@@ -6939,8 +6939,7 @@ aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
-  if (s != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
index 62370d9b4202b6e9cb2bb5c7510e0503b2fcba93..ef6344728b81a113b337a233ab0c632ee8f999ce 100644 (file)
@@ -2983,10 +2983,10 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   bfd *dynobj;
   bfd_boolean relplt = FALSE;
 
-  dynobj = elf_hash_table(info)->dynobj;
   ia64_info = elfNN_ia64_hash_table (info);
   if (ia64_info == NULL)
     return FALSE;
+  dynobj = ia64_info->root.dynobj;
   ia64_info->self_dtpmod_offset = (bfd_vma) -1;
   BFD_ASSERT(dynobj != NULL);
   data.info = info;
@@ -3052,8 +3052,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
       /* If we've got a .plt, we need some extra memory for the dynamic
         linker.  We stuff these in .got.plt.  */
-      sec = bfd_get_linker_section (dynobj, ".got.plt");
-      sec->size = 8 * PLT_RESERVED_WORDS;
+      ia64_info->root.sgotplt->size = 8 * PLT_RESERVED_WORDS;
     }
 
   /* Allocate the PLTOFF entries.  */
@@ -3176,7 +3175,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
     }
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (ia64_info->root.dynamic_sections_created)
     {
       /* Add some entries to the .dynamic section.  We fill in the values
         later (in finish_dynamic_sections) but we must add the entries now
@@ -4621,14 +4620,14 @@ elfNN_ia64_finish_dynamic_sections (bfd *abfd,
 
   dynobj = ia64_info->root.dynobj;
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (ia64_info->root.dynamic_sections_created)
     {
       ElfNN_External_Dyn *dyncon, *dynconend;
       asection *sdyn, *sgotplt;
       bfd_vma gp_val;
 
       sdyn = bfd_get_linker_section (dynobj, ".dynamic");
-      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+      sgotplt = ia64_info->root.sgotplt;
       BFD_ASSERT (sdyn != NULL);
       dyncon = (ElfNN_External_Dyn *) sdyn->contents;
       dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->size);
index be1de2267015aa288ca25214b7d61c64bbb1dd88..4f11cf6516fdf42a1e2e60d1994ede5242e6664c 100644 (file)
@@ -291,8 +291,7 @@ riscv_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
-  if (s != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
index e4fc0430402a227419a98db88d93c38b6b96ee83..029ea1c80d25d0eeedd1ba82c80169a9506a1a5a 100644 (file)
@@ -453,12 +453,8 @@ struct mips_elf_link_hash_table
      being used.  */
   asection *srelbss;
   asection *sdynbss;
-  asection *srelplt;
   asection *srelplt2;
-  asection *sgotplt;
-  asection *splt;
   asection *sstubs;
-  asection *sgot;
 
   /* The master GOT information.  */
   struct mips_got_info *got_info;
@@ -3356,7 +3352,7 @@ mips_elf_initialize_tls_slots (bfd *abfd, struct bfd_link_info *info,
   if (htab == NULL)
     return;
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
 
   indx = 0;
   if (h != NULL)
@@ -3483,8 +3479,8 @@ mips_elf_gotplt_index (struct bfd_link_info *info,
   BFD_ASSERT (h->plt.plist->gotplt_index != MINUS_ONE);
 
   /* Calculate the address of the associated .got.plt entry.  */
-  got_address = (htab->sgotplt->output_section->vma
-                + htab->sgotplt->output_offset
+  got_address = (htab->root.sgotplt->output_section->vma
+                + htab->root.sgotplt->output_offset
                 + (h->plt.plist->gotplt_index
                    * MIPS_ELF_GOT_SIZE (info->output_bfd)));
 
@@ -3548,7 +3544,7 @@ mips_elf_primary_global_got_index (bfd *obfd, struct bfd_link_info *info,
   g = mips_elf_bfd_got (obfd, FALSE);
   got_index = ((h->dynindx - global_got_dynindx + g->local_gotno)
               * MIPS_ELF_GOT_SIZE (obfd));
-  BFD_ASSERT (got_index < htab->sgot->size);
+  BFD_ASSERT (got_index < htab->root.sgot->size);
 
   return got_index;
 }
@@ -3582,7 +3578,7 @@ mips_elf_global_got_index (bfd *obfd, struct bfd_link_info *info, bfd *ibfd,
   BFD_ASSERT (entry);
 
   gotidx = entry->gotidx;
-  BFD_ASSERT (gotidx > 0 && gotidx < htab->sgot->size);
+  BFD_ASSERT (gotidx > 0 && gotidx < htab->root.sgot->size);
 
   if (lookup.tls_type)
     {
@@ -3670,7 +3666,7 @@ mips_elf_got_offset_from_index (struct bfd_link_info *info, bfd *output_bfd,
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
   gp = _bfd_get_gp_value (output_bfd)
     + mips_elf_adjust_gp (output_bfd, htab->got_info, input_bfd);
 
@@ -3733,7 +3729,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
       BFD_ASSERT (entry);
 
       gotidx = entry->gotidx;
-      BFD_ASSERT (gotidx > 0 && gotidx < htab->sgot->size);
+      BFD_ASSERT (gotidx > 0 && gotidx < htab->root.sgot->size);
 
       return entry;
     }
@@ -3773,7 +3769,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
   *entry = lookup;
   *loc = entry;
 
-  MIPS_ELF_PUT_WORD (abfd, value, htab->sgot->contents + entry->gotidx);
+  MIPS_ELF_PUT_WORD (abfd, value, htab->root.sgot->contents + entry->gotidx);
 
   /* These GOT entries need a dynamic relocation on VxWorks.  */
   if (htab->is_vxworks)
@@ -3784,8 +3780,8 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
       bfd_vma got_address;
 
       s = mips_elf_rel_dyn_section (info, FALSE);
-      got_address = (htab->sgot->output_section->vma
-                    + htab->sgot->output_offset
+      got_address = (htab->root.sgot->output_section->vma
+                    + htab->root.sgot->output_offset
                     + entry->gotidx);
 
       rloc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela));
@@ -5137,7 +5133,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   BFD_ASSERT (htab != NULL);
 
   /* This function may be called more than once.  */
-  if (htab->sgot)
+  if (htab->root.sgot)
     return TRUE;
 
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
@@ -5149,7 +5145,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
-  htab->sgot = s;
+  htab->root.sgot = s;
 
   /* Define the symbol _GLOBAL_OFFSET_TABLE_.  We don't do this in the
      linker script because we don't want to define the symbol if we
@@ -5183,7 +5179,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
                                          | SEC_LINKER_CREATED);
   if (s == NULL)
     return FALSE;
-  htab->sgotplt = s;
+  htab->root.sgotplt = s;
 
   return TRUE;
 }
@@ -5605,7 +5601,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
     {
       bfd_boolean micromips_p = MICROMIPS_P (abfd);
 
-      sec = htab->splt;
+      sec = htab->root.splt;
       symbol = (sec->output_section->vma
                + sec->output_offset
                + htab->plt_header_size
@@ -5721,7 +5717,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
              if (!TLS_RELOC_P (r_type)
                  && !elf_hash_table (info)->dynamic_sections_created)
                /* This is a static link.  We must initialize the GOT entry.  */
-               MIPS_ELF_PUT_WORD (dynobj, symbol, htab->sgot->contents + g);
+               MIPS_ELF_PUT_WORD (dynobj, symbol, htab->root.sgot->contents + g);
            }
        }
       else if (!htab->is_vxworks
@@ -7899,19 +7895,13 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     return FALSE;
 
   /* Cache the sections created above.  */
-  htab->splt = bfd_get_linker_section (abfd, ".plt");
   htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
   if (htab->is_vxworks)
-    {
-      htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
-      htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
-    }
-  else
-    htab->srelplt = bfd_get_linker_section (abfd, ".rel.plt");
+    htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
   if (!htab->sdynbss
       || (htab->is_vxworks && !htab->srelbss && !bfd_link_pic (info))
-      || !htab->srelplt
-      || !htab->splt)
+      || !htab->root.srelplt
+      || !htab->root.splt)
     abort ();
 
   /* Do the usual VxWorks handling.  */
@@ -9218,7 +9208,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
          for PLT offset calculations.  */
       if (htab->plt_mips_offset + htab->plt_comp_offset == 0)
        {
-         BFD_ASSERT (htab->sgotplt->size == 0);
+         BFD_ASSERT (htab->root.sgotplt->size == 0);
          BFD_ASSERT (htab->plt_got_index == 0);
 
          /* If we're using the PLT additions to the psABI, each PLT
@@ -9226,12 +9216,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
             Encourage better cache usage by aligning.  We do this
             lazily to avoid pessimizing traditional objects.  */
          if (!htab->is_vxworks
-             && !bfd_set_section_alignment (dynobj, htab->splt, 5))
+             && !bfd_set_section_alignment (dynobj, htab->root.splt, 5))
            return FALSE;
 
          /* Make sure that .got.plt is word-aligned.  We do this lazily
             for the same reason as above.  */
-         if (!bfd_set_section_alignment (dynobj, htab->sgotplt,
+         if (!bfd_set_section_alignment (dynobj, htab->root.sgotplt,
                                          MIPS_ELF_LOG_FILE_ALIGN (dynobj)))
            return FALSE;
 
@@ -9336,9 +9326,9 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
        hmips->use_plt_entry = TRUE;
 
       /* Make room for the R_MIPS_JUMP_SLOT relocation.  */
-      htab->srelplt->size += (htab->is_vxworks
-                             ? MIPS_ELF_RELA_SIZE (dynobj)
-                             : MIPS_ELF_REL_SIZE (dynobj));
+      htab->root.srelplt->size += (htab->is_vxworks
+                                  ? MIPS_ELF_RELA_SIZE (dynobj)
+                                  : MIPS_ELF_REL_SIZE (dynobj));
 
       /* Make room for the .rela.plt.unloaded relocations.  */
       if (htab->is_vxworks && !bfd_link_pic (info))
@@ -9463,7 +9453,7 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info)
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
-  s = htab->sgot;
+  s = htab->root.sgot;
   if (s == NULL)
     return TRUE;
 
@@ -9741,7 +9731,7 @@ mips_elf_set_plt_sym_value (struct mips_elf_link_hash_entry *h, void *data)
       if (htab->is_vxworks)
        val += 8;
 
-      h->root.root.u.def.section = htab->splt;
+      h->root.root.u.def.section = htab->root.splt;
       h->root.root.u.def.value = val;
       h->root.other = other;
     }
@@ -9790,7 +9780,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
 
          Also create the _PROCEDURE_LINKAGE_TABLE_ symbol if we
          haven't already in _bfd_elf_create_dynamic_sections.  */
-      if (htab->splt && htab->plt_mips_offset + htab->plt_comp_offset != 0)
+      if (htab->root.splt && htab->plt_mips_offset + htab->plt_comp_offset != 0)
        {
          bfd_boolean micromips_p = (MICROMIPS_P (output_bfd)
                                     && !htab->plt_mips_offset);
@@ -9800,8 +9790,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
          bfd_vma size;
 
          BFD_ASSERT (htab->use_plts_and_copy_relocs);
-         BFD_ASSERT (htab->sgotplt->size == 0);
-         BFD_ASSERT (htab->splt->size == 0);
+         BFD_ASSERT (htab->root.sgotplt->size == 0);
+         BFD_ASSERT (htab->root.splt->size == 0);
 
          if (htab->is_vxworks && bfd_link_pic (info))
            size = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry);
@@ -9820,17 +9810,17 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
 
          htab->plt_header_is_comp = micromips_p;
          htab->plt_header_size = size;
-         htab->splt->size = (size
-                             + htab->plt_mips_offset
-                             + htab->plt_comp_offset);
-         htab->sgotplt->size = (htab->plt_got_index
-                                * MIPS_ELF_GOT_SIZE (dynobj));
+         htab->root.splt->size = (size
+                                  + htab->plt_mips_offset
+                                  + htab->plt_comp_offset);
+         htab->root.sgotplt->size = (htab->plt_got_index
+                                     * MIPS_ELF_GOT_SIZE (dynobj));
 
          mips_elf_link_hash_traverse (htab, mips_elf_set_plt_sym_value, info);
 
          if (htab->root.hplt == NULL)
            {
-             h = _bfd_elf_define_linkage_sym (dynobj, info, htab->splt,
+             h = _bfd_elf_define_linkage_sym (dynobj, info, htab->root.splt,
                                               "_PROCEDURE_LINKAGE_TABLE_");
              htab->root.hplt = h;
              if (h == NULL)
@@ -9916,7 +9906,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
       else if (SGI_COMPAT (output_bfd)
               && CONST_STRNEQ (name, ".compact_rel"))
        s->size += mips_elf_hash_table (info)->compact_rel_size;
-      else if (s == htab->splt)
+      else if (s == htab->root.splt)
        {
          /* If the last PLT entry has a branch delay slot, allocate
             room for an extra nop to fill the delay slot.  This is
@@ -9926,8 +9916,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
            s->size += 4;
        }
       else if (! CONST_STRNEQ (name, ".init")
-              && s != htab->sgot
-              && s != htab->sgotplt
+              && s != htab->root.sgot
+              && s != htab->root.sgotplt
               && s != htab->sstubs
               && s != htab->sdynbss)
        {
@@ -10059,7 +10049,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
              && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
            return FALSE;
        }
-      if (htab->splt->size > 0)
+      if (htab->root.splt->size > 0)
        {
          if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTREL, 0))
            return FALSE;
@@ -10711,25 +10701,25 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (htab->use_plts_and_copy_relocs);
       BFD_ASSERT (h->dynindx != -1);
-      BFD_ASSERT (htab->splt != NULL);
+      BFD_ASSERT (htab->root.splt != NULL);
       BFD_ASSERT (got_index != MINUS_ONE);
       BFD_ASSERT (!h->def_regular);
 
       /* Calculate the address of the PLT header.  */
       isa_bit = htab->plt_header_is_comp;
-      header_address = (htab->splt->output_section->vma
-                       + htab->splt->output_offset + isa_bit);
+      header_address = (htab->root.splt->output_section->vma
+                       + htab->root.splt->output_offset + isa_bit);
 
       /* Calculate the address of the .got.plt entry.  */
-      got_address = (htab->sgotplt->output_section->vma
-                    + htab->sgotplt->output_offset
+      got_address = (htab->root.sgotplt->output_section->vma
+                    + htab->root.sgotplt->output_offset
                     + got_index * MIPS_ELF_GOT_SIZE (dynobj));
 
       got_address_high = ((got_address + 0x8000) >> 16) & 0xffff;
       got_address_low = got_address & 0xffff;
 
       /* Initially point the .got.plt entry at the PLT header.  */
-      loc = (htab->sgotplt->contents + got_index * MIPS_ELF_GOT_SIZE (dynobj));
+      loc = (htab->root.sgotplt->contents + got_index * MIPS_ELF_GOT_SIZE (dynobj));
       if (ABI_64_P (output_bfd))
        bfd_put_64 (output_bfd, header_address, loc);
       else
@@ -10744,10 +10734,10 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
 
          plt_offset = htab->plt_header_size + h->plt.plist->mips_offset;
 
-         BFD_ASSERT (plt_offset <= htab->splt->size);
+         BFD_ASSERT (plt_offset <= htab->root.splt->size);
 
          /* Find out where the .plt entry should go.  */
-         loc = htab->splt->contents + plt_offset;
+         loc = htab->root.splt->contents + plt_offset;
 
          /* Pick the load opcode.  */
          load = MIPS_ELF_LOAD_WORD (output_bfd);
@@ -10783,10 +10773,10 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
          plt_offset = (htab->plt_header_size + htab->plt_mips_offset
                        + h->plt.plist->comp_offset);
 
-         BFD_ASSERT (plt_offset <= htab->splt->size);
+         BFD_ASSERT (plt_offset <= htab->root.splt->size);
 
          /* Find out where the .plt entry should go.  */
-         loc = htab->splt->contents + plt_offset;
+         loc = htab->root.splt->contents + plt_offset;
 
          /* Fill in the PLT entry itself.  */
          if (!MICROMIPS_P (output_bfd))
@@ -10822,8 +10812,8 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
 
              BFD_ASSERT (got_address % 4 == 0);
 
-             loc_address = (htab->splt->output_section->vma
-                            + htab->splt->output_offset + plt_offset);
+             loc_address = (htab->root.splt->output_section->vma
+                            + htab->root.splt->output_offset + plt_offset);
              gotpc_offset = got_address - ((loc_address | 3) ^ 3);
 
              /* ADDIUPC has a span of +/-16MB, check we're in range.  */
@@ -10834,8 +10824,8 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
                    (_("%B: `%A' offset of %ld from `%A' "
                       "beyond the range of ADDIUPC"),
                     output_bfd,
-                    htab->sgotplt->output_section,
-                    htab->splt->output_section,
+                    htab->root.sgotplt->output_section,
+                    htab->root.splt->output_section,
                     (long) gotpc_offset);
                  bfd_set_error (bfd_error_no_error);
                  return FALSE;
@@ -10851,7 +10841,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
        }
 
       /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry.  */
-      mips_elf_output_dynamic_relocation (output_bfd, htab->srelplt,
+      mips_elf_output_dynamic_relocation (output_bfd, htab->root.srelplt,
                                          got_index - 2, h->dynindx,
                                          R_MIPS_JUMP_SLOT, got_address);
 
@@ -11015,7 +11005,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
   BFD_ASSERT (h->dynindx != -1
              || h->forced_local);
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
   g = htab->got_info;
   BFD_ASSERT (g != NULL);
 
@@ -11051,7 +11041,7 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
                                                           &e)))
            {
              offset = p->gotidx;
-             BFD_ASSERT (offset > 0 && offset < htab->sgot->size);
+             BFD_ASSERT (offset > 0 && offset < htab->root.sgot->size);
              if (bfd_link_pic (info)
                  || (elf_hash_table (info)->dynamic_sections_created
                      && p->d.h != NULL
@@ -11198,18 +11188,18 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
       gotplt_index = h->plt.plist->gotplt_index;
 
       BFD_ASSERT (h->dynindx != -1);
-      BFD_ASSERT (htab->splt != NULL);
+      BFD_ASSERT (htab->root.splt != NULL);
       BFD_ASSERT (gotplt_index != MINUS_ONE);
-      BFD_ASSERT (plt_offset <= htab->splt->size);
+      BFD_ASSERT (plt_offset <= htab->root.splt->size);
 
       /* Calculate the address of the .plt entry.  */
-      plt_address = (htab->splt->output_section->vma
-                    + htab->splt->output_offset
+      plt_address = (htab->root.splt->output_section->vma
+                    + htab->root.splt->output_offset
                     + plt_offset);
 
       /* Calculate the address of the .got.plt entry.  */
-      got_address = (htab->sgotplt->output_section->vma
-                    + htab->sgotplt->output_offset
+      got_address = (htab->root.sgotplt->output_section->vma
+                    + htab->root.sgotplt->output_offset
                     + gotplt_index * MIPS_ELF_GOT_SIZE (output_bfd));
 
       /* Calculate the offset of the .got.plt entry from
@@ -11222,11 +11212,11 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
 
       /* Fill in the initial value of the .got.plt entry.  */
       bfd_put_32 (output_bfd, plt_address,
-                 (htab->sgotplt->contents
+                 (htab->root.sgotplt->contents
                   + gotplt_index * MIPS_ELF_GOT_SIZE (output_bfd)));
 
       /* Find out where the .plt entry should go.  */
-      loc = htab->splt->contents + plt_offset;
+      loc = htab->root.splt->contents + plt_offset;
 
       if (bfd_link_pic (info))
        {
@@ -11275,7 +11265,7 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
        }
 
       /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry.  */
-      loc = (htab->srelplt->contents
+      loc = (htab->root.srelplt->contents
             + gotplt_index * sizeof (Elf32_External_Rela));
       rel.r_offset = got_address;
       rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_JUMP_SLOT);
@@ -11288,7 +11278,7 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
 
   BFD_ASSERT (h->dynindx != -1 || h->forced_local);
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
   g = htab->got_info;
   BFD_ASSERT (g != NULL);
 
@@ -11366,8 +11356,8 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
     plt_entry = micromips_o32_exec_plt0_entry;
 
   /* Calculate the value of .got.plt.  */
-  gotplt_value = (htab->sgotplt->output_section->vma
-                 + htab->sgotplt->output_offset);
+  gotplt_value = (htab->root.sgotplt->output_section->vma
+                 + htab->root.sgotplt->output_offset);
   gotplt_value_high = ((gotplt_value + 0x8000) >> 16) & 0xffff;
   gotplt_value_low = gotplt_value & 0xffff;
 
@@ -11377,7 +11367,7 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
              || ~(gotplt_value | 0x7fffffff) == 0);
 
   /* Install the PLT header.  */
-  loc = htab->splt->contents;
+  loc = htab->root.splt->contents;
   if (plt_entry == micromips_o32_exec_plt0_entry)
     {
       bfd_vma gotpc_offset;
@@ -11386,8 +11376,8 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
 
       BFD_ASSERT (gotplt_value % 4 == 0);
 
-      loc_address = (htab->splt->output_section->vma
-                    + htab->splt->output_offset);
+      loc_address = (htab->root.splt->output_section->vma
+                    + htab->root.splt->output_offset);
       gotpc_offset = gotplt_value - ((loc_address | 3) ^ 3);
 
       /* ADDIUPC has a span of +/-16MB, check we're in range.  */
@@ -11397,8 +11387,8 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%B: `%A' offset of %ld from `%A' beyond the range of ADDIUPC"),
             output_bfd,
-            htab->sgotplt->output_section,
-            htab->splt->output_section,
+            htab->root.sgotplt->output_section,
+            htab->root.splt->output_section,
             (long) gotpc_offset);
          bfd_set_error (bfd_error_no_error);
          return FALSE;
@@ -11463,10 +11453,11 @@ mips_vxworks_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
   got_value_low = got_value & 0xffff;
 
   /* Calculate the address of the PLT header.  */
-  plt_address = htab->splt->output_section->vma + htab->splt->output_offset;
+  plt_address = (htab->root.splt->output_section->vma
+                + htab->root.splt->output_offset);
 
   /* Install the PLT header.  */
-  loc = htab->splt->contents;
+  loc = htab->root.splt->contents;
   bfd_put_32 (output_bfd, plt_entry[0] | got_value_high, loc);
   bfd_put_32 (output_bfd, plt_entry[1] | got_value_low, loc + 4);
   bfd_put_32 (output_bfd, plt_entry[2], loc + 8);
@@ -11527,7 +11518,7 @@ mips_vxworks_finish_shared_plt (bfd *output_bfd, struct bfd_link_info *info)
   /* We just need to copy the entry byte-by-byte.  */
   for (i = 0; i < ARRAY_SIZE (mips_vxworks_shared_plt0_entry); i++)
     bfd_put_32 (output_bfd, mips_vxworks_shared_plt0_entry[i],
-               htab->splt->contents + i * 4);
+               htab->root.splt->contents + i * 4);
 }
 
 /* Finish up the dynamic sections.  */
@@ -11549,7 +11540,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
-  sgot = htab->sgot;
+  sgot = htab->root.sgot;
   gg = htab->got_info;
 
   if (elf_hash_table (info)->dynamic_sections_created)
@@ -11597,12 +11588,12 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_PLTGOT:
-             s = htab->sgot;
+             s = htab->root.sgot;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              break;
 
            case DT_MIPS_PLTGOT:
-             s = htab->sgotplt;
+             s = htab->root.sgotplt;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              break;
 
@@ -11726,8 +11717,8 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
            case DT_RELASZ:
              BFD_ASSERT (htab->is_vxworks);
              /* The count does not include the JUMP_SLOT relocations.  */
-             if (htab->srelplt)
-               dyn.d_un.d_val -= htab->srelplt->size;
+             if (htab->root.srelplt)
+               dyn.d_un.d_val -= htab->root.srelplt->size;
              break;
 
            case DT_PLTREL:
@@ -11740,13 +11731,13 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 
            case DT_PLTRELSZ:
              BFD_ASSERT (htab->use_plts_and_copy_relocs);
-             dyn.d_un.d_val = htab->srelplt->size;
+             dyn.d_un.d_val = htab->root.srelplt->size;
              break;
 
            case DT_JMPREL:
              BFD_ASSERT (htab->use_plts_and_copy_relocs);
-             dyn.d_un.d_ptr = (htab->srelplt->output_section->vma
-                               + htab->srelplt->output_offset);
+             dyn.d_un.d_ptr = (htab->root.srelplt->output_section->vma
+                               + htab->root.srelplt->output_offset);
              break;
 
            case DT_TEXTREL:
@@ -11977,7 +11968,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
       }
   }
 
-  if (htab->splt && htab->splt->size > 0)
+  if (htab->root.splt && htab->root.splt->size > 0)
     {
       if (htab->is_vxworks)
        {
index cf3001291e0702fd294ffb4fd303bf991640cb71..916d33bc23ac7f8f396ee9431adb77172f616dd6 100644 (file)
@@ -4578,7 +4578,6 @@ sparc_finish_dyn (bfd *output_bfd, struct bfd_link_info *info,
   for (dyncon = sdyn->contents; dyncon < dynconend; dyncon += dynsize)
     {
       Elf_Internal_Dyn dyn;
-      const char *name;
       bfd_boolean size;
 
       bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
@@ -4621,30 +4620,36 @@ sparc_finish_dyn (bfd *output_bfd, struct bfd_link_info *info,
        }
       else
        {
+         asection *s;
+
          switch (dyn.d_tag)
            {
-           case DT_PLTGOT:   name = ".plt"; size = FALSE; break;
-           case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
-           case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break;
-           default:          name = NULL; size = FALSE; break;
+           case DT_PLTGOT:
+             s = htab->elf.splt;
+             size = FALSE;
+             break;
+           case DT_PLTRELSZ:
+             s = htab->elf.srelplt;
+             size = TRUE;
+             break;
+           case DT_JMPREL:
+             s = htab->elf.srelplt;
+             size = FALSE;
+             break;
+           default:
+             continue;
            }
 
-         if (name != NULL)
+         if (s == NULL)
+           dyn.d_un.d_val = 0;
+         else
            {
-             asection *s;
-
-             s = bfd_get_linker_section (dynobj, name);
-             if (s == NULL)
-               dyn.d_un.d_val = 0;
+             if (!size)
+               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              else
-               {
-                 if (! size)
-                   dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
-                 else
-                   dyn.d_un.d_val = s->size;
-               }
-             bed->s->swap_dyn_out (output_bfd, &dyn, dyncon);
+               dyn.d_un.d_val = s->size;
            }
+         bed->s->swap_dyn_out (output_bfd, &dyn, dyncon);
        }
     }
   return TRUE;
index 0705509ed40af33c45dcde3bb26fe4a11f57531c..9cd71b64650b59be7be1c3d304ae0dcf4e1cb930 100644 (file)
@@ -1439,8 +1439,7 @@ tilegx_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_linker_section (abfd, ".got");
-  if (s != NULL)
+  if (htab->sgot != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;