]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd: move merge_info from ELF to general link hash table
authorJan Beulich <jbeulich@suse.com>
Fri, 24 Oct 2025 13:08:33 +0000 (15:08 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Oct 2025 13:08:33 +0000 (15:08 +0200)
This is in prepration of supporting section merging also when the output
isn't ELF (or not of the same class).

bfd/elf-bfd.h
bfd/elflink.c
bfd/linker.c
include/bfdlink.h

index a2b3eb0fa9f4148e4b9e13fd5c9732646f71d8b1..48e877f8a111e7e9f03f1f3575eeda4ab4c9db68 100644 (file)
@@ -710,9 +710,6 @@ struct elf_link_hash_table
   /* The __ehdr_start symbol.  */
   struct elf_link_hash_entry *hehdr_start;
 
-  /* A pointer to information used to merge SEC_MERGE sections.  */
-  void *merge_info;
-
   /* Used to link stabs in sections.  */
   struct stab_info stab_info;
 
index c7a5a52f1dd673f0f3303996c4bcc072fecf080a..b06d07c18b3f5ecedca7966e706ea953fe9d8d39 100644 (file)
@@ -8201,15 +8201,15 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
 
            secdata = elf_section_data (sec);
            if (! _bfd_add_merge_section (obfd,
-                                         &elf_hash_table (info)->merge_info,
+                                         &info->hash->merge_info,
                                          sec, &secdata->sec_info))
              return false;
            else if (secdata->sec_info)
              sec->sec_info_type = SEC_INFO_TYPE_MERGE;
          }
 
-  if (elf_hash_table (info)->merge_info != NULL)
-    return _bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info,
+  if (info->hash->merge_info != NULL)
+    return _bfd_merge_sections (obfd, info, info->hash->merge_info,
                                merge_sections_remove_hook);
   return true;
 }
@@ -8449,7 +8449,6 @@ _bfd_elf_link_hash_table_free (bfd *obfd)
   htab = (struct elf_link_hash_table *) obfd->link.hash;
   if (htab->dynstr != NULL)
     _bfd_elf_strtab_free (htab->dynstr);
-  _bfd_merge_sections_free (htab->merge_info);
   /* NB: htab->dynamic->contents is always allocated by bfd_realloc.  */
   if (htab->dynamic != NULL)
     {
index a9a23e5b9de9b2641f93e869f5ca834136f6aa13..ae44ec3f2d2923e389c27d48caea1e1c6da27852 100644 (file)
@@ -492,6 +492,7 @@ _bfd_link_hash_table_init
     {
       /* Arrange for destruction of this hash table on closing ABFD.  */
       table->hash_table_free = _bfd_generic_link_hash_table_free;
+      table->merge_info = NULL;
       abfd->link.hash = table;
       abfd->is_linker_output = true;
     }
@@ -809,6 +810,7 @@ _bfd_generic_link_hash_table_free (bfd *obfd)
 
   BFD_ASSERT (obfd->is_linker_output && obfd->link.hash);
   ret = (struct generic_link_hash_table *) obfd->link.hash;
+  _bfd_merge_sections_free (ret->root.merge_info);
   bfd_hash_table_free (&ret->root.table);
   free (ret);
   obfd->link.hash = NULL;
index 3d4d71b3347474f39394cff81b6b9860060859c4..0c47d09977f4b9bb81274836afb07488946683a4 100644 (file)
@@ -214,6 +214,10 @@ struct bfd_link_hash_table
   struct bfd_link_hash_entry *undefs_tail;
   /* Function to free the hash table on closing BFD.  */
   void (*hash_table_free) (bfd *);
+
+  /* A pointer to information used to merge SEC_MERGE sections.  */
+  void *merge_info;
+
   /* The type of the link hash table.  */
   enum bfd_link_hash_table_type type;
 };