diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-23 05:07:31 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-23 05:07:45 -0700 |
commit | 3084d7a27b8e4d13f0fdd0fac62ffadc9c2223b5 (patch) | |
tree | 6cf63cdbd80c06d4dfceb2ff02c4ebc3ff155104 /bfd/elf-m10300.c | |
parent | 2e573c0a3f9de232587f75de0af765abb8e193b9 (diff) | |
download | gdb-3084d7a27b8e4d13f0fdd0fac62ffadc9c2223b5.zip gdb-3084d7a27b8e4d13f0fdd0fac62ffadc9c2223b5.tar.gz gdb-3084d7a27b8e4d13f0fdd0fac62ffadc9c2223b5.tar.bz2 |
ELF: Add _bfd_elf_add_dynamic_tags
All ELF backends with shared library support need to add dynamic tags.
Add dt_pltgot_required and dt_jmprel_required to elf_link_hash_table to
indicate that DT_PLTGOT and DT_JMPREL are required dynamic tags.
1. Add _bfd_elf_add_dynamic_tags to add common dynamic tags.
2. Add _bfd_elf_maybe_vxworks_add_dynamic_tags to add common VxWorks
dynamic tags.
* elf-bfd.h (elf_link_hash_table): Add dt_pltgot_required and
dt_jmprel_required.
(_bfd_elf_add_dynamic_tags): New.
* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-microblaze.c (microblaze_elf_size_dynamic_sections):
Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections):
Likewise.
* elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections):
Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
* elfxx-x86.h (elf_x86_link_hash_table): Remove dt_reloc,
dt_reloc_sz and dt_reloc_ent.
* elf-vxworks.c (_bfd_elf_maybe_vxworks_add_dynamic_tags): New.
* elf-vxworks.h (_bfd_elf_maybe_vxworks_add_dynamic_tags):
Likewise.
* elf32-hppa.c (elf32_hppa_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf32_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-metag.c (elf_metag_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf_metag_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags.
* elf32-sh.c (sh_elf_link_hash_table_create): Set
root.dt_pltgot_required for FDPIC output.
(sh_elf_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Set
elf.dt_pltgot_required.
(elf_xtensa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf64-hppa.c (elf64_hppa_hash_table_create): Set
root.dt_pltgot_required.
(elf64_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elfnn-ia64.c (elfNN_ia64_hash_table_create): Set
root.dt_pltgot_required.
(elfNN_ia64_size_dynamic_sections): Set root.dt_jmprel_required
for rel_pltoff_sec. Call _bfd_elf_add_dynamic_tags.
* elflink.c (_bfd_elf_add_dynamic_tags): New.
Diffstat (limited to 'bfd/elf-m10300.c')
-rw-r--r-- | bfd/elf-m10300.c | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 5a0bb9f..1c436a7 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -5012,9 +5012,7 @@ _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info); bfd * dynobj; asection * s; - bfd_boolean plt; bfd_boolean relocs; - bfd_boolean reltext; dynobj = htab->root.dynobj; BFD_ASSERT (dynobj != NULL); @@ -5052,9 +5050,7 @@ _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, /* The check_relocs and adjust_dynamic_symbol entry points have determined the sizes of the various dynamic sections. Allocate memory for them. */ - plt = FALSE; relocs = FALSE; - reltext = FALSE; for (s = dynobj->sections; s != NULL; s = s->next) { const char * name; @@ -5069,34 +5065,16 @@ _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, if (streq (name, ".plt")) { /* Remember whether there is a PLT. */ - plt = s->size != 0; + ; } else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { - asection * target; - /* Remember whether there are any reloc sections other than .rela.plt. */ if (! streq (name, ".rela.plt")) - { - const char * outname; - - relocs = TRUE; - - /* If this relocation section applies to a read only - section, then we probably need a DT_TEXTREL - entry. The entries in the .rela.plt section - really apply to the .got section, which we - created ourselves and so know is not readonly. */ - outname = bfd_section_name (s->output_section); - target = bfd_get_section_by_name (output_bfd, outname + 5); - if (target != NULL - && (target->flags & SEC_READONLY) != 0 - && (target->flags & SEC_ALLOC) != 0) - reltext = TRUE; - } + relocs = TRUE; /* We use the reloc_count field as a counter if we need to copy relocs into the output file. */ @@ -5136,45 +5114,7 @@ _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd, return FALSE; } - if (elf_hash_table (info)->dynamic_sections_created) - { - /* Add some entries to the .dynamic section. We fill in the - values later, in _bfd_mn10300_elf_finish_dynamic_sections, - but we must add the entries now so that we get the correct - size for the .dynamic section. The DT_DEBUG entry is filled - in by the dynamic linker and used by the debugger. */ - if (! bfd_link_pic (info)) - { - if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0)) - return FALSE; - } - - if (plt) - { - if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA) - || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) - return FALSE; - } - - if (relocs) - { - if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT, - sizeof (Elf32_External_Rela))) - return FALSE; - } - - if (reltext) - { - if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0)) - return FALSE; - } - } - - return TRUE; + return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs); } /* Finish up dynamic symbol handling. We set the contents of various |