]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR 33018 segv in elf_x86_64_scan_relocs
authorAlan Modra <amodra@gmail.com>
Wed, 28 May 2025 00:14:26 +0000 (09:44 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 28 May 2025 05:53:46 +0000 (15:23 +0930)
* elf64-x86-64.c (elf_x86_64_scan_relocs): Error on NULL howto.
Use bfd_reloc_offset_in_range.

bfd/elf64-x86-64.c

index 1e08f2e7125424f6409bcfdaabcda8761e4f558a..8a36eef9c7dc0b504a7b34bb473cf6535f61f086 100644 (file)
@@ -2552,7 +2552,13 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
        }
 
       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