--- binutils.orig/bfd/elf.c 2023-10-13 11:38:25.159530287 +0100 +++ binutils-2.41/bfd/elf.c 2023-10-13 11:41:23.290898228 +0100 @@ -9479,6 +9479,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd if (elf_use_dt_symtab_p (abfd)) iverneed->vn_filename = elf_tdata (abfd)->dt_strtab + iverneed->vn_file; + else if (hdr == NULL) + goto error_return_bad_verref; else iverneed->vn_filename = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, @@ -9516,6 +9518,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd if (elf_use_dt_symtab_p (abfd)) ivernaux->vna_nodename = elf_tdata (abfd)->dt_strtab + ivernaux->vna_name; + else if (hdr == NULL) + goto error_return_bad_verref; else ivernaux->vna_nodename = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, @@ -9546,7 +9550,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd iverneed->vn_nextref = NULL; if (iverneed->vn_next == 0) break; - if (i + 1 < hdr->sh_info) + if (hdr != NULL && (i + 1 < hdr->sh_info)) iverneed->vn_nextref = iverneed + 1; if (iverneed->vn_next