[PATCH 1/8] bfd: move merge_info from ELF to general link hash table
Jan Beulich
jbeulich@suse.com
Mon Oct 13 09:04:55 GMT 2025
This is in prepration of supporting section merging also when the output
isn't ELF (or not of the same class).
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -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;
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8215,15 +8215,15 @@ _bfd_elf_merge_sections (bfd *obfd, stru
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;
}
@@ -8463,7 +8463,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)
{
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -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 *
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;
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -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;
};
More information about the Binutils
mailing list