Bug 20520

Summary: ld terminated with signal 11 [Segmentation fault]
Product: binutils Reporter: Richard Biener <rguenth>
Component: ldAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: amodra, i
Priority: P2    
Version: 2.26   
Target Milestone: 2.28   
Host: Target:
Build: Last reconfirmed:
Attachments: object file

Description Richard Biener 2016-08-26 09:05:51 UTC
Created attachment 9478 [details]
object file

I get

/home/abuild/rguenther/obj-early-lto-debug-g/gcc/testsuite/g++/../../xg++ -B /home/abuild/rguenther/obj-early-lto-debug-g/gcc/testsuite/g++/../../ -B /home/abuild/rguenther/obj-early-lto-debug-g/x86_64-pc-linux-gnu/./libstdc++-v3/src/.libs -B /home/abuild/rguenther/obj-early-lto-debug-g/x86_64-pc-linux-gnu/./libitm/ -mtune=generic -march=x86-64 -r -nostdlib -o /tmp/ccdeKWVsdebugobj /tmp/cc5vbUMkdebugobjtem
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
compilation terminated.

on arguably invalid input (a GROUP section referencing SHT_NULL sections).

I expect a diagnostic instead.  Object file attached.
Comment 1 Sourceware Commits 2016-08-27 01:02:41 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 53720c495c7c25f9b0f4bfce3269c6c8a7696522
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 27 09:43:42 2016 +0930

    Lack of SHF_GROUP sections result in ld segfault
    
    	PR 20520
    	* elf.c (_bfd_elf_setup_sections): Check that SHT_GROUP sections
    	have corresponding SHF_GROUP sections.
    	(bfd_elf_set_group_contents): Comment.
Comment 2 Alan Modra 2016-08-27 01:35:42 UTC
Fixed
Comment 3 Fangrui Song 2024-06-06 00:39:56 UTC
A section group without any member is valid and should ideally be supported. ld before 53720c495c7c25f9b0f4bfce3269c6c8a7696522 crashed while ld versions after the commit report: `file not recognized: file format not recognized`
Comment 4 Alan Modra 2024-06-27 13:04:00 UTC
(In reply to Fangrui Song from comment #3)
> A section group without any member is valid and should ideally be supported.
As of commit f67619822044 that should be supported.