aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-nios2.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-12-26 00:21:06 +1030
committerAlan Modra <amodra@gmail.com>2016-12-26 13:42:20 +1030
commit9d19e4fdb7c684329c8b1b72796a0071708dabc7 (patch)
tree6c02fe281d104a002db0c2a28ba7d9c1ddbd43b5 /bfd/elf32-nios2.c
parent09a1b0e9437f4e6c868b47322a84193a5ae3a391 (diff)
downloadfsf-binutils-gdb-9d19e4fdb7c684329c8b1b72796a0071708dabc7.zip
fsf-binutils-gdb-9d19e4fdb7c684329c8b1b72796a0071708dabc7.tar.gz
fsf-binutils-gdb-9d19e4fdb7c684329c8b1b72796a0071708dabc7.tar.bz2
Put .dynbss and .rel.bss shortcuts in main elf hash table
Also, create .rel{,a}.bss for PIEs on all targets, not just x86. * elf-bfd.h (struct elf_link_hash_table): Add sdynbss and srelbss. * elflink.c (_bfd_elf_create_dynamic_sections): Set them. Create .rel.bss/.rela.bss for executables, both PIE and non-PIE. * elf32-arc.c (struct elf_arc_link_hash_table): Delete srelbss. Use ELF hash table var throughout. * elf32-arm.c (struct elf32_arm_link_hash_table): Delete sdynbss and srelbss. Use ELF hash table vars throughout. * elf32-hppa.c (struct elf32_hppa_link_hash_table): Likewise. * elf32-i386.c (struct elf_i386_link_hash_table): Likewise. * elf32-metag.c (struct elf_metag_link_hash_table): Likewise. * elf32-microblaze.c (struct elf32_mb_link_hash_table): Likewise. * elf32-nios2.c (struct elf32_nios2_link_hash_table): Likewise. * elf32-or1k.c (struct elf_or1k_link_hash_table): Likewise. * elf32-ppc.c (struct ppc_elf_link_hash_table): Likewise. * elf32-s390.c (struct elf_s390_link_hash_table): Likewise. * elf32-tic6x.c (struct elf32_tic6x_link_hash_table): Likewise. * elf32-tilepro.c (struct tilepro_elf_link_hash_table): Likewise. * elf64-ppc.c (struct ppc_link_hash_table): Likewise. * elf64-s390.c (struct elf_s390_link_hash_table): Likewise. * elf64-x86-64.c (struct elf_x86_64_link_hash_table): Likewise. * elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Likewise. * elfnn-riscv.c (struct riscv_elf_link_hash_table): Likewise. * elfxx-mips.c (struct mips_elf_link_hash_table): Likewise. * elfxx-sparc.h (struct _bfd_sparc_elf_link_hash_table): Likewise. * elfxx-sparc.c: Likewise. * elfxx-tilegx.c (struct tilegx_elf_link_hash_table): Likewise. * elf32-arc.c (arc_elf_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf32-microblaze.c (microblaze_elf_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf32-or1k.c (or1k_elf_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf32-s390.c (elf_s390_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf64-ppc.c (ppc64_elf_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf64-s390.c (elf_s390_create_dynamic_sections): Delete. (elf_backend_create_dynamic_sections): Use base ELF version. * elf32-tilepro.c (tilepro_elf_create_dynamic_sections): Remove extraneous tests. * elfnn-aarch64.c (elfNN_aarch64_create_dynamic_sections): Likewise. * elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Likewise. * elfxx-tilegx.c (tilegx_elf_create_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_create_dynamic_sections): Don't create ".rel.bss" for executables. * elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Don't create ".rela.bss" for executables. * elf32-nios2.c (nios2_elf32_create_dynamic_sections): Don't ignore return status from _bfd_elf_create_dynamic_sections.
Diffstat (limited to 'bfd/elf32-nios2.c')
-rw-r--r--bfd/elf32-nios2.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index c63932f..a4ce99c 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -1820,8 +1820,6 @@ struct elf32_nios2_link_hash_table
Elf_Internal_Sym **all_local_syms;
/* Short-cuts to get to dynamic linker sections. */
- asection *sdynbss;
- asection *srelbss;
asection *sbss;
/* GOT pointer symbol _gp_got. */
@@ -4602,26 +4600,14 @@ nios2_elf32_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
if (!htab->root.sgot && !create_got_section (dynobj, info))
return FALSE;
- _bfd_elf_create_dynamic_sections (dynobj, info);
+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
+ return FALSE;
/* In order for the two loads in a shared object .PLTresolve to share the
same %hiadj, the start of the PLT (as well as the GOT) must be aligned
to a 16-byte boundary. This is because the addresses for these loads
include the -(.plt+4) PIC correction. */
- if (!bfd_set_section_alignment (dynobj, htab->root.splt, 4))
- return FALSE;
-
- htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
- if (!htab->sdynbss)
- return FALSE;
- if (!bfd_link_pic (info))
- {
- htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
- if (!htab->srelbss)
- return FALSE;
- }
-
- return TRUE;
+ return bfd_set_section_alignment (dynobj, htab->root.splt, 4);
}
/* Implement elf_backend_copy_indirect_symbol:
@@ -5289,7 +5275,7 @@ nios2_elf32_finish_dynamic_symbol (bfd *output_bfd,
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak));
- s = htab->srelbss;
+ s = htab->root.srelbss;
BFD_ASSERT (s != NULL);
rela.r_offset = (h->root.u.def.value
@@ -5537,7 +5523,7 @@ nios2_elf32_adjust_dynamic_symbol (struct bfd_link_info *info,
determine the address it must put in the global offset table, so
both the dynamic object and the regular object will refer to the
same memory location for the variable. */
- s = htab->sdynbss;
+ s = htab->root.sdynbss;
BFD_ASSERT (s != NULL);
/* We must generate a R_NIOS2_COPY reloc to tell the dynamic linker to
@@ -5548,7 +5534,7 @@ nios2_elf32_adjust_dynamic_symbol (struct bfd_link_info *info,
{
asection *srel;
- srel = htab->srelbss;
+ srel = htab->root.srelbss;
BFD_ASSERT (srel != NULL);
srel->size += sizeof (Elf32_External_Rela);
h->needs_copy = 1;