diff options
author | Alan Modra <amodra@gmail.com> | 2016-05-13 11:48:56 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2016-05-13 14:34:45 +0930 |
commit | 4ade44b727ee77adaa9c22719935d012e253a5e6 (patch) | |
tree | b8245860459f263489810f5ad2a3a0dc1bc1c5df /bfd/elflink.c | |
parent | c8e44c6d168f8e68b7bbb1119065e0059a16fe34 (diff) | |
download | gdb-4ade44b727ee77adaa9c22719935d012e253a5e6.zip gdb-4ade44b727ee77adaa9c22719935d012e253a5e6.tar.gz gdb-4ade44b727ee77adaa9c22719935d012e253a5e6.tar.bz2 |
Set dynamic tag VMA and size from dynamic section when possible
Rather than searching the output for a specific named section, it's
better, where possible, to use a linker created dynamic section to set
a dynamic tag's value. That way ld doesn't depend on the output
section name, making it possibile to map dynamic sections differently.
bfd/
* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Use
linker dynamic sections in calculating size and address of
* dynamic tags rather than using output sections. Remove asserts.
* elf32-arm.c (elf32_arm_finish_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Likewise.
* elf32-cris.c (elf_cris_finish_dynamic_sections): Likewise.
* elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_finish_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_finish_dynamic_sections): Likewise.
* elf32-metag.c (elf_metag_finish_dynamic_sections): Likewise.
* elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Likewise.
* elf32-nds32.c (nds32_elf_finish_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_finish_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_finish_dynamic_sections): Likewise.
* elf32-score.c (s3_bfd_score_elf_finish_dynamic_sections): Likewise.
* elf32-score7.c (s7_bfd_score_elf_finish_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_finish_dynamic_sections): Likewise.
* elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
* elf64-sh64.c (sh64_elf64_finish_dynamic_sections): Likewise.
* elflink.c (bfd_elf_final_link): Likewise.
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Likewise.
* elfxx-sparc.c (sparc_finish_dyn): Likewise. Adjust error message.
* elf32-arc.c (GET_SYMBOL_OR_SECTION): Remove ASSERT arg and
don't set doit. Look up dynobj section.
(elf_arc_finish_dynamic_sections): Adjust GET_SYMBOL_OR_SECTION
invocation and dynamic tag vma calculation. Don't test
boolean var == TRUE.
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Fix
DT_JMPREL calc.
ld/
* testsuite/ld-arm/arm-elf.exp: Adjust for arm-no-rel-plt now passing.
Use different output file name for static app without .rel.plt.
* testsuite/ld-arm/arm-no-rel-plt.ld: Align .rel.dyn and .rela.dyn.
* testsuite/ld-arm/arm-no-rel-plt.out: Delete.
* testsuite/ld-arm/arm-no-rel-plt.r: New.
* testsuite/ld-arm/arm-static-app.d: Don't check file name.
* testsuite/ld-arm/arm-static-app.r: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 5f2fa52..1223d27 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11895,18 +11895,18 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) case DT_PREINIT_ARRAYSZ: name = ".preinit_array"; - goto get_size; + goto get_out_size; case DT_INIT_ARRAYSZ: name = ".init_array"; - goto get_size; + goto get_out_size; case DT_FINI_ARRAYSZ: name = ".fini_array"; - get_size: + get_out_size: o = bfd_get_section_by_name (abfd, name); if (o == NULL) { (*_bfd_error_handler) - (_("%B: could not find output section %s"), abfd, name); + (_("could not find section %s"), name); goto error_return; } if (o->size == 0) @@ -11917,13 +11917,15 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) case DT_PREINIT_ARRAY: name = ".preinit_array"; - goto get_vma; + goto get_out_vma; case DT_INIT_ARRAY: name = ".init_array"; - goto get_vma; + goto get_out_vma; case DT_FINI_ARRAY: name = ".fini_array"; - goto get_vma; + get_out_vma: + o = bfd_get_section_by_name (abfd, name); + goto do_vma; case DT_HASH: name = ".hash"; @@ -11946,11 +11948,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) case DT_VERSYM: name = ".gnu.version"; get_vma: - o = bfd_get_section_by_name (abfd, name); + o = bfd_get_linker_section (dynobj, name); + do_vma: if (o == NULL) { (*_bfd_error_handler) - (_("%B: could not find output section %s"), abfd, name); + (_("could not find section %s"), name); goto error_return; } if (elf_section_data (o->output_section)->this_hdr.sh_type == SHT_NOTE) @@ -11960,7 +11963,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) bfd_set_error (bfd_error_nonrepresentable_section); goto error_return; } - dyn.d_un.d_ptr = o->vma; + dyn.d_un.d_ptr = o->output_section->vma + o->output_offset; break; case DT_REL: |