[PATCH 11/15] s390: Sync htab checks between {elf32|elf64}-s390.c

Jens Remus jremus@linux.ibm.com
Fri Nov 7 16:34:54 GMT 2025


Over time elf32-s390.c and elf64-s390.c have diverged in some areas.

Apply hash table pointer checks for NULL from elf64-s390.c to
elf32-s390.c.

Additionally this simplifies comparison of elf32-s390.c and
elf64-s390.c, as it reduces the number of differences.

bfd/
	* elf32-s390.c (elf_s390_check_relocs,
	elf_s390_adjust_dynamic_symbol, allocate_dynrelocs,
	elf_s390_late_size_sections, elf_s390_relocate_section,
	elf_s390_finish_dynamic_sections): Add htab validations from
	elf64-s390.c.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 bfd/elf32-s390.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 214166bcd529..f02fdc144306 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -899,6 +899,9 @@ elf_s390_check_relocs (bfd *abfd,
   BFD_ASSERT (is_s390_elf (abfd));
 
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
+
   symtab_hdr = &elf_symtab_hdr (abfd);
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
@@ -1524,6 +1527,8 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
      same memory location for the variable.  */
 
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
 
   /* We must generate a R_390_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
@@ -1562,6 +1567,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 
   info = (struct bfd_link_info *) inf;
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
 
   /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
      here if it is defined and referenced in a non-shared object.  */
@@ -1786,6 +1793,9 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   bfd *ibfd;
 
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
+
   dynobj = htab->elf.dynobj;
   if (dynobj == NULL)
     return true;
@@ -2041,6 +2051,9 @@ elf_s390_relocate_section (bfd *output_bfd,
     }
 
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
+
   symtab_hdr = &elf_symtab_hdr (input_bfd);
   sym_hashes = elf_sym_hashes (input_bfd);
   local_got_offsets = elf_local_got_offsets (input_bfd);
@@ -3618,6 +3631,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
   unsigned int i;
 
   htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return false;
+
   dynobj = htab->elf.dynobj;
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
-- 
2.48.1



More information about the Binutils mailing list