Bug 28608 - elflint elfstrmerge fails with ld.gold
Summary: elflint elfstrmerge fails with ld.gold
Status: RESOLVED INVALID
Alias: None
Product: elfutils
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-19 10:50 UTC by Martin Liska
Modified: 2023-01-16 10:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2023-01-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liska 2021-11-19 10:50:45 UTC
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.
Comment 1 Mark Wielaard 2021-11-21 16:45:02 UTC
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
Comment 2 Martin Liska 2021-11-22 08:20:32 UTC
Thank you for the analysis, can you please open gold bug for it?
Comment 3 Martin Liska 2021-11-22 08:38:45 UTC
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
...
Comment 4 Martin Liska 2023-01-13 08:55:52 UTC
(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?
Comment 5 Mark Wielaard 2023-01-13 09:58:56 UTC
(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).
Comment 6 Martin Liska 2023-01-16 10:33:09 UTC
Ok, so it's a bug in gold which is not supported much anyway.