Fetch source files from here:
https://github.com/emaste/binutils-gdb/blob/master/binutils/testsuite/binutils-all/group.s
https://github.com/emaste/binutils-gdb/blob/master/binutils/testsuite/binutils-all/group-2.s
https://github.com/emaste/binutils-gdb/blob/master/binutils/testsuite/binutils-all/group-3.s
https://github.com/emaste/binutils-gdb/blob/master/binutils/testsuite/binutils-all/group-4.s
Build them all
% as -o group.o group.s
% as -o group-2.o group-2.s
% as -o group-3.o group-3.s
% as -o group-4.o group-4.s
Strip them
% elfcopy/strip --strip-unneeded group.o
% elfcopy/strip --strip-unneeded group-2.o
% elfcopy/strip --strip-unneeded group-3.o
% elfcopy/strip --strip-unneeded group-4.o
Examine with readelf:
% readelf -Sg --wide group.o
There are 10 section headers, starting at offset 0xa0:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] foo_group GROUP 0000000000000000 000040 00000c 04 8 0 4
[ 2] .text PROGBITS 0000000000000000 00004c 000000 00 AX 0 0 4
[ 3] .data PROGBITS 0000000000000000 00004c 000000 00 WA 0 0 4
[ 4] .bss NOBITS 0000000000000000 00004c 000000 00 WA 0 0 4
[ 5] .text.foo PROGBITS 0000000000000000 00004c 000002 00 AXG 0 0 1
[ 6] .data.foo PROGBITS 0000000000000000 00004e 000002 00 WAG 0 0 1
[ 7] .shstrtab STRTAB 0000000000000000 000050 00004a 00 0 0 1
[ 8] .symtab SYMTAB 0000000000000000 000320 0000d8 18 9 7 8
[ 9] .strtab STRTAB 0000000000000000 0003f8 000009 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
COMDAT group section [ 1] `foo_group' [] contains 2 sections:
[Index] Name
[ 5] .text.foo
[ 6] .data.foo
Actual output from group{,-2,-3,-4}.o is
COMDAT group section [ 1] `foo_group' [] contains 2 sections:
COMDAT group section [ 1] `.group' [] contains 2 sections:
COMDAT group section [ 1] `.group' [foo3] contains 2 sections:
readelf: Error: Bad sh_link in group section `.group'
while the expected (copied from the test cases) is
COMDAT group section \[[ 0-9]+\] `\.group' \[foo_group\] contains 2 sections:
COMDAT group section \[[ 0-9]+\] `.group' \[.text.foo\] contains 2 sections:
COMDAT group section \[[ 0-9]+\] `.group' \[foo3\] contains 2 sections:
COMDAT group section \[[ 0-9]+\] `.group' \[foo4\] contains 2 sections:
Should be fixed by [r3221].
Related
Commit: [r3221]
Confirmed, these GNU binutils tests now pass (with my checkout at [r3222]).
Related
Commit: [r3222]