Skip to content

Commit 11f52f7

Browse files
authored
[BOLT][DWARF] Fix invalid address ranges (#71474)
When NOP instructions are removed by BOLT and a DWARF address range falls past the removed instructions, it may lead to invalid DWARF ranges in the output binary. E.g. the range may fall outside of the basic block boundaries. This fix makes sure the modified range fits within the containing basic block. A proper fix requires tracking instructions within the block and will come in a different PR.
1 parent 679cc16 commit 11f52f7

File tree

2 files changed

+394
-1
lines changed

2 files changed

+394
-1
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4306,7 +4306,7 @@ BinaryFunction::translateInputToOutputRange(DebugAddressRange InRange) const {
43064306
// block boundaries.
43074307
auto translateBlockOffset = [&](const uint64_t Offset) {
43084308
const uint64_t OutAddress = BB.getOutputAddressRange().first + Offset;
4309-
return OutAddress;
4309+
return std::min(OutAddress, BB.getOutputAddressRange().second);
43104310
};
43114311

43124312
uint64_t OutLowPC = BB.getOutputAddressRange().first;

0 commit comments

Comments
 (0)