Using ld.gold, I see the following failure (for GCC 11.2.0): elflint /home/marxin/Programming/elfutils/tests/elfstrmerge section [17] '.rodata': merge flag set but entry size is zero FAIL run-strip-strmerge.sh (exit status: 1) I configured elfutils with -O2 -g.
That looks like a bug in ld.gold. tests/elfstrmerge is a simple ET_EXEC file. When SHF_MERGE is set, then sh_entsize should be set to the size of the elements that should be merged (unless SHF_STRING is also set). For me .rodata doesn't have the SHF_MERGE flag set: [15] .rodata PROGBITS 0000000000002d68 00002d68 00000837 0 A 0 0 8
Thank you for the analysis, can you please open gold bug for it?
It's likely caused by the following 2 sections that are in elfstrmerge.o: $ readelf -SW elfstrmerge.o | grep rodata Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al ... [ 5] .rodata.str1.1 PROGBITS 0000000000000000 000480 0002d0 01 AMS 0 0 1 [ 6] .rodata.str1.8 PROGBITS 0000000000000000 000750 0004df 01 AMS 0 0 8 ...
(In reply to Martin Liska from comment #3) > It's likely caused by the following 2 sections that are in elfstrmerge.o: > > $ readelf -SW elfstrmerge.o | grep rodata > Section Headers: > [Nr] Name Type Address Off Size ES > Flg Lk Inf Al > ... > [ 5] .rodata.str1.1 PROGBITS 0000000000000000 000480 0002d0 01 > AMS 0 0 1 > [ 6] .rodata.str1.8 PROGBITS 0000000000000000 000750 0004df 01 > AMS 0 0 8 > ... This is unrelated, it's a different file that is checked. So it fails for: $ /home/marxin/Programming/elfutils/src/elflint --gnu /home/marxin/Programming/elfutils/tests/elfstrmerge section [17] '.rodata': merge flag set but entry size is zero $ readelf -SW /home/marxin/Programming/elfutils/tests/elfstrmerge | grep roda [17] .rodata PROGBITS 0000000000402ea0 002ea0 0007bf 00 AMS 0 0 8 As seen the section has SHF_STRING flag, thus having sh_entsize == 0 should be fine. @Mark: Can you please take a look?
(In reply to Martin Liska from comment #4) > So it fails for: > $ /home/marxin/Programming/elfutils/src/elflint --gnu > /home/marxin/Programming/elfutils/tests/elfstrmerge > section [17] '.rodata': merge flag set but entry size is zero > > $ readelf -SW /home/marxin/Programming/elfutils/tests/elfstrmerge | grep roda > [17] .rodata PROGBITS 0000000000402ea0 002ea0 0007bf 00 > AMS 0 0 8 > > As seen the section has SHF_STRING flag, thus having sh_entsize == 0 should > be fine. > > @Mark: Can you please take a look? If both SHF_STRING and SHF_MERGE are set then sh_entsize is the char size (normally 1).
Ok, so it's a bug in gold which is not supported much anyway.