[BOLT][DWARF] Fix high pc patching

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
https://github.com/rafaelauler/bolt-tests/pull/8

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Reviewed By: ayermolo

Differential Revision: https://reviews.llvm.org/D117217
This commit is contained in:
Vladislav Khmelevsky 2022-01-15 01:03:42 +03:00
parent 650fc40b6d
commit fb3b86fedc
1 changed files with 7 additions and 3 deletions

View File

@ -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(