Fix a dereference of NULL when scanning the symbol hashes array in the ARM linker.
authorNick Clifton <nickc@redhat.com>
Tue, 6 Dec 2022 11:24:12 +0000 (11:24 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 6 Dec 2022 11:24:12 +0000 (11:24 +0000)
PR 29852
* elf32-arm.c (cmse_scan): Check for NULL entries in the
sym_hashes array.
(elf32_arm_gc_mark_extra_sections): Likewise.

bfd/ChangeLog
bfd/elf32-arm.c

index ee8eaf01d424fc1ac883c9701cd412a18b8fefba..da2a30a9463de68703e07506388ba38e3cd63deb 100644 (file)
@@ -1,3 +1,10 @@
+2022-12-06  Nick Clifton  <nickc@redhat.com>
+
+       PR 29852
+       * elf32-arm.c (cmse_scan): Check for NULL entries in the
+       sym_hashes array.
+       (elf32_arm_gc_mark_extra_sections): Likewise.
+
 2022-12-05  Nick Clifton  <nickc@redhat.com>
 
        PR 29848
index c7d73171e628185b09e45d88048e85034acf8c93..86cc961f73ab2b66bdc1d3499dba02b533feebf9 100644 (file)
@@ -6008,6 +6008,9 @@ cmse_scan (bfd *input_bfd, struct elf32_arm_link_hash_table *htab,
       else
        {
          cmse_hash = elf32_arm_hash_entry (sym_hashes[i - ext_start]);
+         if (cmse_hash == NULL)
+           continue;
+
          sym_name = (char *) cmse_hash->root.root.root.string;
          if (!startswith (sym_name, CMSE_PREFIX))
            continue;
@@ -15987,6 +15990,8 @@ elf32_arm_gc_mark_extra_sections (struct bfd_link_info *info,
              for (i = ext_start; i < sym_count; i++)
                {
                  cmse_hash = elf32_arm_hash_entry (sym_hashes[i - ext_start]);
+                 if (cmse_hash == NULL)
+                   continue;
 
                  /* Assume it is a special symbol.  If not, cmse_scan will
                     warn about it and user can do something about it.  */