Skip to content

Commit

Permalink
[BOLT][DWARF] Add support for DW_FORM_addr for DW_AT_call_return_pc
Browse files Browse the repository at this point in the history
GCC 12 produces DW_FORM_addr for DW_AT_call_return_pc. Added support for that.
Fixes facebookarchive/BOLT#307

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D136204
  • Loading branch information
ayermolo committed Oct 19, 2022
1 parent 262a332 commit fcd7717
Show file tree
Hide file tree
Showing 3 changed files with 588 additions and 12 deletions.
24 changes: 12 additions & 12 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,20 +498,20 @@ void DWARFRewriter::updateUnitDebugInfo(
Optional<uint64_t> Address = AttrVal.V.getAsAddress();
const BinaryFunction *Function =
BC.getBinaryFunctionContainingAddress(*Address);
uint32_t Index = 0;
// Preserving original address instead of using whatever ends up at this
// index.
if (!Function) {
Index = AddrWriter->getIndexFromAddress(*Address, Unit);
} else {
const uint64_t UpdatedAddress =
Function->translateInputToOutputAddress(*Address);
Index = AddrWriter->getIndexFromAddress(UpdatedAddress, Unit);
}
if (AttrVal.V.getForm() == dwarf::DW_FORM_addrx)
uint64_t UpdatedAddress = *Address;
if (Function)
UpdatedAddress =
Function->translateInputToOutputAddress(UpdatedAddress);

if (AttrVal.V.getForm() == dwarf::DW_FORM_addrx) {
const uint32_t Index =
AddrWriter->getIndexFromAddress(UpdatedAddress, Unit);
DebugInfoPatcher.addUDataPatch(AttrVal.Offset, Index, AttrVal.Size);
else
} else if (AttrVal.V.getForm() == dwarf::DW_FORM_addr) {
DebugInfoPatcher.addLE32Patch(AttrVal.Offset, UpdatedAddress);
} else {
errs() << "BOLT-ERROR: unsupported form for " << Entry << "\n";
}
};

if (Optional<AttrInfo> AttrVal =
Expand Down
Loading

0 comments on commit fcd7717

Please sign in to comment.