Skip to content

Commit

Permalink
[BOLT][DWARF] Fix high pc patching
Browse files Browse the repository at this point in the history
The DW_FORM_addr form of highPC address is written in absolute addres,
the data form is written in offset-from-low pc format.

Due to the large test binary the test is prepared separately in
rafaelauler/bolt-tests#8

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Reviewed By: ayermolo

Differential Revision: https://reviews.llvm.org/D117217
  • Loading branch information
yota9 committed Jan 14, 2022
1 parent 650fc40 commit fb3b86f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bolt/lib/Rewrite/DWARFRewriter.cpp
Expand Up @@ -1502,11 +1502,15 @@ void DWARFRewriter::patchLowHigh(DWARFDie DIE, DebugAddressRange Range,
TempDebugPatcher->addLE64Patch(LowPCOffset, Range.LowPC);
}

uint64_t HighPC = Range.HighPC;
// The DW_FORM_data* is delta between high and low pc
if (HighPCVal->V.getForm() != dwarf::Form::DW_FORM_addr)
HighPC -= Range.LowPC;

if (isHighPcFormEightBytes(HighPCVal->V.getForm()))
TempDebugPatcher->addLE64Patch(HighPCOffset, Range.HighPC - Range.LowPC);
TempDebugPatcher->addLE64Patch(HighPCOffset, HighPC);
else
TempDebugPatcher->addLE32Patch(HighPCOffset, Range.HighPC - Range.LowPC,
HighPCVal->Size);
TempDebugPatcher->addLE32Patch(HighPCOffset, HighPC);
}

void DWARFRewriter::convertToRangesPatchAbbrev(
Expand Down

0 comments on commit fb3b86f

Please sign in to comment.