Skip to content

Commit

Permalink
Create DW_AT_ranges for compile units.
Browse files Browse the repository at this point in the history
Summary:
Some compile unit DIEs might be missing DW_AT_ranges because they were
compiled without "-ffunction-sections" option. This diff adds the
attribute to all compile units.

If the section is not present, we need to create it. Will do it in a
separate diff.

(cherry picked from FBD3314984)
  • Loading branch information
maksfb committed May 18, 2016
1 parent f047b9d commit 7ab3db1
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions bolt/RewriteInstance.cpp
Expand Up @@ -2133,33 +2133,22 @@ void RewriteInstance::updateDebugInfo() {

updateLocationLists();

auto &DebugInfoSI = SectionMM->NoteSectionInfo[".debug_info"];
updateDWARFAddressRanges();
}

void RewriteInstance::updateDWARFAddressRanges() {
// Update DW_AT_ranges for all compilation units.
for (const auto &CU : BC->DwCtx->compile_units()) {
const auto CUID = CU->getOffset();

// Update DW_AT_ranges
auto RangesFieldOffset =
BC->DwCtx->getAttrFieldOffsetForUnit(CU.get(), dwarf::DW_AT_ranges);
if (RangesFieldOffset) {
DEBUG(dbgs() << "BOLT-DEBUG: adding relocation for DW_AT_ranges for "
<< "compile unit in .debug_info\n");
const auto RSOI = RangesSectionsWriter.getRangesOffsetCUMap().find(CUID);
if (RSOI != RangesSectionsWriter.getRangesOffsetCUMap().end()) {
auto Offset = RSOI->second;
DebugInfoSI.PendingRelocs.emplace_back(
SectionInfo::Reloc{RangesFieldOffset, 4, 0,
Offset + DebugRangesSize});
} else {
DEBUG(dbgs() << "BOLT-DEBUG: no .debug_ranges entry found for CU "
<< CUID << '\n');
}
const auto RSOI = RangesSectionsWriter.getRangesOffsetCUMap().find(CUID);
if (RSOI != RangesSectionsWriter.getRangesOffsetCUMap().end()) {
auto Offset = RSOI->second;
updateDWARFObjectAddressRanges(Offset + DebugRangesSize,
CU.get(),
CU->getUnitDIE());
}
}

updateDWARFAddressRanges();
}

void RewriteInstance::updateDWARFAddressRanges() {
// Update address ranges of functions.
for (const auto &BFI : BinaryFunctions) {
const auto &Function = BFI.second;
Expand Down

0 comments on commit 7ab3db1

Please sign in to comment.