]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
elf: Store __ehdr_start hash in elf_link_hash_table
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 3 Feb 2025 03:30:50 +0000 (11:30 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Feb 2025 05:02:58 +0000 (13:02 +0800)
Since

commit 97da0e2677c4a38df2406576428ec27d1da26e7c
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 12 23:42:23 2022 +1030

    tweak __ehdr_start visibility and flags for check_relocs

creates __ehdr_start hash in lang_symbol_tweaks, store __ehdr_start hash
in elf_link_hash_table so that we just need to lookup it up only once.

bfd/

* elf-bfd.h (elf_link_hash_table): Add hehdr_start.
* elf.c (assign_file_positions_for_load_sections): Use
hehdr_start.

ld/

* ldelf.c (ldelf_before_allocation): Use hehdr_start for
__ehdr_start hash.
* ldlang.c (lang_symbol_tweaks): Store hehdr_start hash in
hehdr_start.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/elf-bfd.h
bfd/elf.c
ld/ldelf.c
ld/ldlang.c

index c89327fdc9ca7b7bb314fddf322ee13d8a67fa8a..785a37dd7fdf7f48e51b6033a4f3fc8680da4d82 100644 (file)
@@ -699,6 +699,9 @@ struct elf_link_hash_table
   /* The _DYNAMIC symbol.  */
   struct elf_link_hash_entry *hdynamic;
 
+  /* The __ehdr_start symbol.  */
+  struct elf_link_hash_entry *hehdr_start;
+
   /* A pointer to information used to merge SEC_MERGE sections.  */
   void *merge_info;
 
index 0fa580d8d78421b31bc2d2a79dac42b776fbefb2..0e40d6d1d301d08fcbd26e9d31a6390df67bf7ec 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6419,9 +6419,9 @@ assign_file_positions_for_load_sections (bfd *abfd,
         program headers, so provide a symbol __ehdr_start pointing there.
         A program can use this to examine itself robustly.  */
 
-      struct elf_link_hash_entry *hash
-       = elf_link_hash_lookup (elf_hash_table (link_info), "__ehdr_start",
-                               false, false, true);
+      struct elf_link_hash_table *htab = elf_hash_table (link_info);
+      struct elf_link_hash_entry *hash = htab->hehdr_start;
+
       /* If the symbol was referenced and not defined, define it.  */
       if (hash != NULL
          && (hash->root.type == bfd_link_hash_new
index dbc3d77d47b0c54c694fe6c410a76b443b621639..141ee598a2813b0968c80c4cc5cb6024914eeabe 100644 (file)
@@ -1772,8 +1772,7 @@ ldelf_before_allocation (char **audit, char **depaudit,
       if (!bfd_link_relocatable (&link_info))
        {
          struct elf_link_hash_table *htab = elf_hash_table (&link_info);
-         struct elf_link_hash_entry *h
-           = elf_link_hash_lookup (htab, "__ehdr_start", false, false, true);
+         struct elf_link_hash_entry *h = htab->hehdr_start;
 
          /* Only adjust the export class if the symbol was referenced
             and not defined, otherwise leave it alone.  */
index cd94e2018371c281c94d95ee358480338be3f161..4a4acaa5493e30749c3d4ad4881706e86769c68c 100644 (file)
@@ -7176,6 +7176,7 @@ lang_symbol_tweaks (void)
          h->def_regular = 1;
          h->root.linker_def = 1;
          h->root.rel_from_abs = 1;
+         elf_hash_table (&link_info)->hehdr_start = h;
        }
     }
 }