This is an archive of the discontinued LLVM Phabricator instance.

[lib/MC] - Set SHF_EXCLUDE flag for .dwo sections.
ClosedPublic

Authored by grimar on Sep 20 2018, 6:47 AM.

Details

Summary

Currently .dwo sections are usually emitted to .dwo file.
I am working on a single file split case, which is mentioned in
the DWARF5 spec. It says that

"The sections that do not require relocation, however, can be written
to the relocatable object (.o) file but ignored by the
the linker or they can be written to a separate DWARF object (.dwo) file
that need not be accessed by the linker."

Nice way to make linker to ignore them is to set SHF_EXCLUDE flag.
I believe it is not harmful to always set it for .dwo sections.
That is what this patch does.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Sep 20 2018, 6:47 AM

Have you tested this with binutils dwp tool? Given the overlap between linking and dwp (binutils dwp uses parts of the gold linker implementation I think) - I could imagine marking these as ignore might even end up applying to the dwp tool & breaking that process.

Have you tested this with binutils dwp tool? Given the overlap between linking and dwp (binutils dwp uses parts of the gold linker implementation I think) - I could imagine marking these as ignore might even end up applying to the dwp tool & breaking that process.

Thanks for the suggestion, I tested it today.

So I took a .dwo produced with the use of this patch, it contained SHF_EXCLUDE .dwo sections:

Size              EntSize          Flags  Link  Info  Align
[ 0]                   NULL             0000000000000000  00000000
     0000000000000000  0000000000000000           0     0     0
[ 1] .strtab           STRTAB           0000000000000000  0000016b
     0000000000000060  0000000000000000           0     0     1
[ 2] .debug_loc.dwo    PROGBITS         0000000000000000  00000040
     0000000000000000  0000000000000000   E       0     0     1
[ 3] .debug_str_offset PROGBITS         0000000000000000  00000040
     0000000000000028  0000000000000000   E       0     0     1
[ 4] .debug_str.dwo    PROGBITS         0000000000000000  00000068
     000000000000005c  0000000000000001 MSE       0     0     1
[ 5] .debug_info.dwo   PROGBITS         0000000000000000  000000c4
     000000000000004a  0000000000000000   E       0     0     1
[ 6] .debug_abbrev.dwo PROGBITS         0000000000000000  0000010e
     000000000000005d  0000000000000000   E       0     0     1

Then I run dwp (GNU dwp (GNU Binutils) 2.30.51.20180326):

dwp file.dwo -o out

The resulting file had the expected set of debug sections I think:
(It dropped all the flags though, but I think it always does that)

[ 0]                   NULL             0000000000000000  00000000
     0000000000000000  0000000000000000           0     0     0
[ 1] .debug_abbrev.dwo PROGBITS         0000000000000000  00000040
     000000000000005d  0000000000000000           0     0     1
[ 2] .debug_loc.dwo    PROGBITS         0000000000000000  00000000
     0000000000000000  0000000000000000           0     0     1
[ 3] .debug_str_offset PROGBITS         0000000000000000  0000009d
     0000000000000028  0000000000000000           0     0     1
[ 4] .debug_str.dwo    PROGBITS         0000000000000000  000000c5
     000000000000005c  0000000000000000           0     0     1
[ 5] .debug_cu_index   PROGBITS         0000000000000000  00000128
     0000000000000010  0000000000000000           0     0     8
[ 6] .debug_tu_index   PROGBITS         0000000000000000  00000138
     0000000000000010  0000000000000000           0     0     8
[ 7] .shstrtab         STRTAB           0000000000000000  00000148
     0000000000000072  0000000000000000           0     0     1
dblaikie accepted this revision.Sep 21 2018, 9:08 AM

Seems good to me, then.

This revision is now accepted and ready to land.Sep 21 2018, 9:08 AM
This revision was automatically updated to reflect the committed changes.