[binutils-gdb] PR 33018 segv in elf_x86_64_scan_relocs

Alan Modra amodra@sourceware.org
Wed May 28 06:27:43 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=04395ea00492a63a586459acd834af8ab1a02546

commit 04395ea00492a63a586459acd834af8ab1a02546
Author: Alan Modra <amodra@gmail.com>
Date:   Wed May 28 09:44:26 2025 +0930

    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:
---
 bfd/elf64-x86-64.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 1e08f2e7125..8a36eef9c7d 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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


More information about the Binutils-cvs mailing list