This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

re: ld fails to handle empty group sections


> On Fri, Jul 07, 2017 at 10:44:14AM +0200, Pierre Lebleu wrote:
> > With the "trunk" version, I got this message :
> [snip]
> > staging_dir/toolchain-mips_mips32_gcc-5.3.0_uClibc-0.9.33.2/bin/mips-openwrt-linux-uclibc-ld:
> > /usr/localdisk/vant-f_5.02/openwrt/build_dir/target-mips_mips32_uClibc-0.9.33.2/linux-brcm63xx-tch_VANTF/paragon-9.4.4/ifslinux/ufsd.o:
> > SHT_GROUP section [index 110] has no SHF_GROUP sections
> [snip]
> > The problem seems to be those *empty* GROUP sections :
> > COMDAT group section [  110] `.group'
> > [wm4.prealloc.h.7.3f44507fe709a4206e0a16687993bc55] contains 0 sections:
> >    [Index]    Name
> 
> Right.  How is the ufsd.o file being generated?  Strictly speaking, I
> don't think there is anything in the ELF gABI that precludes an emtpy
> group, but such a construct is useless.  Rather than modifying the
> linker to deal with them, I'd rather they weren't created in the first
> place.  If the problem is some objcopy or ld -r linking stage that
> removes sections, then it is probably better to remove empty groups at
> that point rather than trying to deal with them later.
> 
> --
> Alan Modra
> Australia Development Lab, IBM

I've been able to reproduce this and narrow it down to the following minimal
testcase:

$ cat testcase.s
        .section .text.foo,"axG",%progbits,foo_group,comdat
        .global foo
foo:
        .word 0

        .section .data.foo,"awG",%progbits,foo_group,comdat
        .global bar
bar:
        .word 1

        .section .debug_macro,"G",%progbits,bar_group,comdat
        .word 2

$ cat Makefile
GAS=./gas/as-new
GLD=./ld/ld-new
GOBJDUMP=./binutils/objdump
TESTCASE ?= testcase.s

all:
        $(GAS) -mips32 -msoft-float $(TESTCASE) -o testcase.o
        $(GLD) -m elf32btsmip -s -O2 -d -x -X -r -o testcase testcase.o
        $(GOBJDUMP) -h testcase

$ make
./gas/as-new -mips32 -msoft-float group-5.s -o testcase.o
./ld/ld-new -m elf32btsmip -s -O2 -d -x -X -r -o testcase testcase.o
./binutils/objdump -h testcase
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: SHT_GROUP section [index 2] has no SHF_GROUP sections
./binutils/objdump: testcase: File format not recognized
make: *** [all] Error 1

$ readelf -g testcase

COMDAT group section [    1] `.group' [foo_group] contains 2 sections:
   [Index]    Name
   [    6]   .text.foo
   [    8]   .data.foo

COMDAT group section [    2] `.group' [bar_group] contains 0 sections:
   [Index]    Name

Tried it on a build from git from yesterday.

Seems like something is going wrong when combining the stripping with groups
that only contain debug info.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]