diff options
author | Alan Modra <amodra@gmail.com> | 2022-02-04 19:30:47 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-02-05 16:45:38 +1030 |
commit | 8df52eeeb06efcccd6b840689ad8e11ebb264e7f (patch) | |
tree | d44d46440c42aa85341f01f73302b853ae0fb19e /bfd/elf.c | |
parent | 06c441cceffb1437a3af51bfad43dce5fd200d9e (diff) | |
download | gdb-8df52eeeb06efcccd6b840689ad8e11ebb264e7f.zip gdb-8df52eeeb06efcccd6b840689ad8e11ebb264e7f.tar.gz gdb-8df52eeeb06efcccd6b840689ad8e11ebb264e7f.tar.bz2 |
Detect .eh_frame_hdr earlier for SIZEOF_HEADERS
Current code detects the need for PT_GNU_EH_FRAME using a field set by
_bfd_elf_discard_section_eh_frame_hdr, which is called fairly late in
the linking process. Use the elf hash table eh_info instead, which is
set up earlier by size_dynamic_sections.
* elf-bfd.h (struct output_elf_obj_tdata): Delete eh_frame_hdr.
(elf_eh_frame_hdr): Don't define.
(_bfd_elf_discard_section_eh_frame_hdr): Update prototype.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Delete
abfd parameter. Don't set elf_eh_frame_hdr.
* elf.c (elf_eh_frame_hdr): New function.
(get_program_header_size): Adjust elf_eh_frame_hdr call.
(_bfd_elf_map_sections_to_segments): Likewise.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -4343,6 +4343,20 @@ _bfd_elf_compute_section_file_positions (bfd *abfd, return true; } +/* Retrieve .eh_frame_hdr. Prior to size_dynamic_sections the + function effectively returns whether --eh-frame-hdr is given on the + command line. After size_dynamic_sections the result reflects + whether .eh_frame_hdr will actually be output (sizing isn't done + until ldemul_after_allocation). */ + +static asection * +elf_eh_frame_hdr (const struct bfd_link_info *info) +{ + if (info != NULL && is_elf_hash_table (info->hash)) + return elf_hash_table (info)->eh_info.hdr_sec; + return NULL; +} + /* Make an initial estimate of the size of the program header. If we get the number wrong here, we'll redo section placement. */ @@ -4379,7 +4393,7 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) ++segs; } - if (elf_eh_frame_hdr (abfd)) + if (elf_eh_frame_hdr (info)) { /* We need a PT_GNU_EH_FRAME segment. */ ++segs; @@ -5134,7 +5148,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME segment. */ - eh_frame_hdr = elf_eh_frame_hdr (abfd); + eh_frame_hdr = elf_eh_frame_hdr (info); if (eh_frame_hdr != NULL && (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0) { |