This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Support creating N_SO stab for DWARF5 compile units
ClosedPublic

Authored by BertalanD on Jul 26 2022, 3:17 AM.

Details

Summary

In DWARF5, the DW_AT_name and DW_AT_comp_dir attributes are encoded
using the strx* forms, which specify an index into __debug_str_offs.
This commit adds that section to DwarfObject, so the debug info parser
can resolve these references.

The test case was manually adapted from stabs-icf.s.

Fixes https://github.com/llvm/llvm-project/issues/51668

Diff Detail

Event Timeline

BertalanD created this revision.Jul 26 2022, 3:17 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 26 2022, 3:17 AM
BertalanD requested review of this revision.Jul 26 2022, 3:17 AM
thakis added a subscriber: thakis.Jul 26 2022, 9:00 AM

Per chat: Given that dwarf5 doesn't currently work in lldb on mac, and probably doesn't work in dsymutil, I'm not sure how useful it is to support this in the linker if the platform (apparently) isn't interested in it.

What does ld64 do with dwarf5 info?

BertalanD added a comment.EditedJul 26 2022, 9:24 AM

What does ld64 do with dwarf5 info?

ld64's dwarf parser is able to understand the strx* forms: https://github.com/apple-opensource/ld64/blob/e28c028b20af187a16a7161d89e91868a450cadc/src/ld/parsers/macho_relocatable_file.cpp#L3721-L3762. Running my test though ld64 produces a sensible result.

@phosek what's the DWARF5 use case that motivated https://github.com/llvm/llvm-project/issues/51668?

We use DWARF5 on all platforms except for macOS so mostly consistency. We use debug info primarily with LLVM tools like llvm-readobj so the lack of support in dsymutil or lldb is less of a concern to us.

int3 accepted this revision.Jul 26 2022, 7:38 PM

lgtm

lld/test/MachO/stabs-dwarf5.s
28

could you include in a comment the C source used to generate this assembly?

This revision is now accepted and ready to land.Jul 26 2022, 7:38 PM
BertalanD added inline comments.Jul 26 2022, 11:07 PM
lld/test/MachO/stabs-dwarf5.s
28

There isn't really one. The debug info was modified by hand from stabs-icf.s.

thakis accepted this revision.Jul 27 2022, 7:47 AM

Meh :)

This revision was landed with ongoing or failed builds.Jul 28 2022, 1:00 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2022, 1:00 AM