aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-02-04 19:30:47 +1030
committerAlan Modra <amodra@gmail.com>2022-02-05 16:45:38 +1030
commit8df52eeeb06efcccd6b840689ad8e11ebb264e7f (patch)
treed44d46440c42aa85341f01f73302b853ae0fb19e /bfd/elf.c
parent06c441cceffb1437a3af51bfad43dce5fd200d9e (diff)
downloadgdb-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.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 14c2c7b..79f71aa 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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)
{