linker script, /DISCARD/ section and SHT_GROUP
Serge Guelton
sguelton@redhat.com
Wed Nov 13 09:52:00 GMT 2019
Hi folks,
While digging in the interaction between linker script's /DISCARD/ section and
groups, I found the following behavior:
$ gcc -c a.s
$ readelf -WS a.o
[ bunch of sections, including ]
[ 5] .myanote.foo NOTE 0000000000000000 000054 000001 00 AG 0 0 1
[ 6] .mytext.foo PROGBITS 0000000000000000 000055 000001 00 AXG 0 0 1
$ ld -T a.script -o a2.o a.o
$ readelf -WS a.o
[ bunch of sections, including ]
[ 6] .mytext.foo PROGBITS 0000000000000000 000055 000001 00 AXG 0 0 1
where :
<< a.script >>
SECTIONS { /DISCARD/ : { *(.myanote.foo) }}
<< a.s >>
.globl anote_foo, foo, bss_foo, note_foo
.section .myanote.foo,"aG",@note,foo,comdat
anote_foo:
.byte 0
.section .mytext.foo,"axG",@progbits,foo,comdat
foo:
.byte 0
.section .mybss.foo,"awG",@nobits,foo,comdat
bss_foo:
.byte 0
.section .mynote.foo,"G",@note,foo,comdat
note_foo:
.byte 0
.section .mynote.bar,"",@note
I find this behavior relatively strange with respect to group semantic: we end
up with a group with one of its member stripped, and the others happily living
around.
Surely, the /DISCARD/ section is incomplete, but I would have expected a
warning, if not an error, in that case.
Is my understanding correct or am I missing something?
More information about the Binutils
mailing list