[binutils-gdb] PR32858 ld segfault on fuzzed object

Alan Modra amodra@sourceware.org
Thu Apr 10 10:17:55 GMT 2025


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

commit d1458933830456e54223d9fc61f0d9b3a19256f5
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Apr 10 19:41:49 2025 +0930

    PR32858 ld segfault on fuzzed object
    
    We missed one place where it is necessary to check for empty groups.
    
            PR 32858
            * elflink.c (elf_gc_sweep): Protect against empty group.

Diff:
---
 bfd/elflink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index a76e8e38da7..549b7b7dd92 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -14408,7 +14408,8 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
 	  if (o->flags & SEC_GROUP)
 	    {
 	      asection *first = elf_next_in_group (o);
-	      o->gc_mark = first->gc_mark;
+	      if (first != NULL)
+		o->gc_mark = first->gc_mark;
 	    }
 
 	  if (o->gc_mark)


More information about the Binutils-cvs mailing list