PR 33018 segv in elf_x86_64_scan_relocs

	* elf64-x86-64.c (elf_x86_64_scan_relocs): Error on NULL howto.
	Use bfd_reloc_offset_in_range.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 1e08f2e..8a36eef 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2552,7 +2552,13 @@
 	}
 
       howto = elf_x86_64_rtype_to_howto (abfd, r_type);
-      if (rel->r_offset + bfd_get_reloc_size (howto) > sec->size)
+      if (howto == NULL)
+	{
+	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			      abfd, r_type);
+	  goto error_return;
+	}
+      if (!bfd_reloc_offset_in_range (howto, abfd, sec, rel->r_offset))
 	{
 	  /* xgettext:c-format */
 	  _bfd_error_handler