This is an archive of the discontinued LLVM Phabricator instance.

API to get Address Offset Section
AbandonedPublic

Authored by ayermolo on Jun 15 2021, 4:39 PM.

Details

Reviewers
dblaikie
Summary

I am adding DWP support to BOLT. At the moment DWP as input, later see if parts of llvm-dwp can be re-used to output DWP directly from bolt.
The Address information is in the main binary, so when DWO CU is created from DWP it is not available. I am exposing a set API so that from user code this can be set.
Example of how I am creating CU from DWP file. https://github.com/facebookincubator/BOLT/blob/0c14e20238604a4c05e174e71676857d45c60a0f/bolt/src/BinaryContext.cpp#L1472
Example of usage of the new API:
Optional<uint64_t> addrOffBase = DwarfUnit->getAddrOffsetSectionBase();
assert(addrOffBase && "Address Offset Section Base is not set.");
DWOCU->setAddrOffsetSection(DwarfUnit->getAddrOffsetSection(), *addrOffBase);
Test Plan:

Diff Detail

Event Timeline

ayermolo created this revision.Jun 15 2021, 4:39 PM
ayermolo requested review of this revision.Jun 15 2021, 4:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2021, 4:39 PM

Can you instead use the API more like the way llvm-symbolizer does - starting with the skeleton CU in the executable and it'll be able to load the dwp itself? (this codepath is already present and more tested, covers other sections like rnglists, etc, that you'll need too)

Can you instead use the API more like the way llvm-symbolizer does - starting with the skeleton CU in the executable and it'll be able to load the dwp itself? (this codepath is already present and more tested, covers other sections like rnglists, etc, that you'll need too)

Hmm. I thought way below is it.

Only relevant code. DwCtx is context of binary.

DWPContext = DwCtx->getDWOContext(opts::DWPPath.c_str());
llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()
DWARFCompileUnit *DWOCU = DWPContext.get()->getDWOCompileUnitForHash(*DWOId);

Let me poke around llvm-symbolizer some more. Last time I looked I don't remember seeing low level APIs, and more high level ones.

Can you instead use the API more like the way llvm-symbolizer does - starting with the skeleton CU in the executable and it'll be able to load the dwp itself? (this codepath is already present and more tested, covers other sections like rnglists, etc, that you'll need too)

Hmm. I thought way below is it.

Only relevant code. DwCtx is context of binary.

DWPContext = DwCtx->getDWOContext(opts::DWPPath.c_str());
llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()
DWARFCompileUnit *DWOCU = DWPContext.get()->getDWOCompileUnitForHash(*DWOId);

Let me poke around llvm-symbolizer some more. Last time I looked I don't remember seeing low level APIs, and more high level ones.

Yeah, most of the symbolizers APIs are higher level - but what I mean is that the symbolizer libraries use the libDebugInfo[DWARF] APIs in such a way as to correctly wire up the everything when they start from the executables context (rather than the dwp/dwo context) - so doing things the same way (& hopefully sharing as much code as possible) is probably a good direction to look at.

Can you instead use the API more like the way llvm-symbolizer does - starting with the skeleton CU in the executable and it'll be able to load the dwp itself? (this codepath is already present and more tested, covers other sections like rnglists, etc, that you'll need too)

Hmm. I thought way below is it.

Only relevant code. DwCtx is context of binary.

DWPContext = DwCtx->getDWOContext(opts::DWPPath.c_str());
llvm::Optional<uint64_t> DWOId = DwarfUnit->getDWOId()
DWARFCompileUnit *DWOCU = DWPContext.get()->getDWOCompileUnitForHash(*DWOId);

Let me poke around llvm-symbolizer some more. Last time I looked I don't remember seeing low level APIs, and more high level ones.

Yeah, most of the symbolizers APIs are higher level - but what I mean is that the symbolizer libraries use the libDebugInfo[DWARF] APIs in such a way as to correctly wire up the everything when they start from the executables context (rather than the dwp/dwo context) - so doing things the same way (& hopefully sharing as much code as possible) is probably a good direction to look at.

Ah, figured it out. Thanks! This diff can be abandoned.

You can mark it abandoned by choosing that action just above the feedback text box

ayermolo abandoned this revision.Jun 16 2021, 8:37 AM