aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-bfd.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-04-21 05:23:51 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-04-21 05:24:03 -0700
commit6f6fd151cbf226bbaa66e44977f57b7c6dc33d89 (patch)
tree0ef4a78de35fde84a58c5964f7822a19a95c620c /bfd/elf-bfd.h
parent1f7f2abbc31ee9e6d4faca58bef14d8ee8cb1bd2 (diff)
downloadgdb-6f6fd151cbf226bbaa66e44977f57b7c6dc33d89.zip
gdb-6f6fd151cbf226bbaa66e44977f57b7c6dc33d89.tar.gz
gdb-6f6fd151cbf226bbaa66e44977f57b7c6dc33d89.tar.bz2
elf: Strip zero-sized dynamic sections
ELF size_dynamic_sections is called by the ELF backend linker after all the linker input files have been seen but before the section sizes have been set. After the sections sizes have been set, target-specific, global optimizations may make some dynamic sections zero-sized if they are no longer needed. Add ELF strip_zero_sized_dynamic_sections so that ELF backend linker can strip zero-sized dynamic sections after the sections sizes have been set. bfd/ PR ld/25849 * elf-bfd.h (elf_backend_data): Add elf_backend_strip_zero_sized_dynamic_sections. (_bfd_elf_strip_zero_sized_dynamic_sections): New prototype. * elf64-alpha.c (elf_backend_strip_zero_sized_dynamic_sections): New macro. * elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): New function. * elfxx-target.h (elf_backend_strip_zero_sized_dynamic_sections): New macro. (elfNN_bed): Add elf_backend_strip_zero_sized_dynamic_sections. ld/ PR ld/25849 * ldelfgen.c (ldelf_map_segments): Call elf_backend_strip_zero_sized_dynamic_sections. * testsuite/ld-alpha/tlsbinr.rd: Updated.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r--bfd/elf-bfd.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index b08502c..3ae9842 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1083,6 +1083,12 @@ struct elf_backend_data
bfd_boolean (*elf_backend_size_dynamic_sections)
(bfd *output_bfd, struct bfd_link_info *info);
+ /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the
+ ELF backend linker to strip zero-sized dynamic sections after
+ the section sizes have been set. */
+ bfd_boolean (*elf_backend_strip_zero_sized_dynamic_sections)
+ (struct bfd_link_info *info);
+
/* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
we keep to use as a base for relocs and symbols. */
void (*elf_backend_init_index_section)
@@ -2520,6 +2526,8 @@ extern bfd_boolean bfd_elf_link_add_symbols
(bfd *, struct bfd_link_info *);
extern bfd_boolean _bfd_elf_add_dynamic_entry
(struct bfd_link_info *, bfd_vma, bfd_vma);
+extern bfd_boolean _bfd_elf_strip_zero_sized_dynamic_sections
+ (struct bfd_link_info *);
extern int bfd_elf_add_dt_needed_tag
(bfd *, struct bfd_link_info *);
extern bfd_boolean _bfd_elf_link_check_relocs