Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,11 @@ void BinaryContext::preprocessDWODebugInfo() {
DwarfUnit->getUnitDIE().find(
{dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
"");
if (*DWOId == 0) {
this->outs() << "BOLT-WARNING: Found DWO file of ID 0: '" << DWOName
<< "', it will not be processed.\n";
continue;
}
SmallString<16> AbsolutePath;
if (!opts::CompDirOverride.empty()) {
sys::path::append(AbsolutePath, opts::CompDirOverride);
Expand Down Expand Up @@ -1722,11 +1727,12 @@ void BinaryContext::preprocessDebugInfo() {
StringRef GlobalPrefix = AsmInfo->getPrivateGlobalPrefix();
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
const uint64_t CUID = CU->getOffset();
std::optional<uint64_t> DWOID = CU->getDWOId();
DwarfLineTable &BinaryLineTable = getDwarfLineTable(CUID);
BinaryLineTable.setLabel(Ctx->getOrCreateSymbol(
GlobalPrefix + "line_table_start" + Twine(CUID)));

if (!ProcessedCUs.count(CU.get()))
if (!ProcessedCUs.count(CU.get()) || (DWOID && *DWOID == 0))
continue;

const DWARFDebugLine::LineTable *LineTable =
Expand All @@ -1741,7 +1747,7 @@ void BinaryContext::preprocessDebugInfo() {
Checksum = LineTable->Prologue.FileNames[0].Checksum;
std::optional<const char *> Name =
dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
if (std::optional<uint64_t> DWOID = CU->getDWOId()) {
if (DWOID) {
auto Iter = DWOCUs.find(*DWOID);
if (Iter == DWOCUs.end()) {
this->errs() << "BOLT-ERROR: DWO CU was not found for " << Name
Expand Down
3 changes: 3 additions & 0 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ DWARFDie DIEBuilder::resolveDIEReference(
uint64_t TmpRefOffset = RefOffset;
if ((RefCU =
getUnitForOffset(*this, *DwarfContext, TmpRefOffset, AttrSpec))) {
std::optional<uint64_t> DWOId = RefCU->getDWOId();
if (DWOId && *DWOId == 0)
return DWARFDie();
/// Trying to add to current working set in case it's cross CU reference.
registerUnit(*RefCU, true);
DWARFDataExtractor DebugInfoData = RefCU->getDebugInfoExtractor();
Expand Down
5 changes: 4 additions & 1 deletion bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ static CUPartitionVector partitionCUs(DWARFContext &DwCtx) {
unsigned Counter = 0;
const DWARFDebugAbbrev *Abbr = DwCtx.getDebugAbbrev();
for (std::unique_ptr<DWARFUnit> &CU : DwCtx.compile_units()) {
std::optional<uint64_t> DWOId = CU->getDWOId();
if (DWOId && *DWOId == 0)
continue;
Expected<const DWARFAbbreviationDeclarationSet *> AbbrDeclSet =
Abbr->getAbbreviationDeclarationSet(CU->getAbbreviationsOffset());
if (!AbbrDeclSet) {
Expand Down Expand Up @@ -732,7 +735,7 @@ void DWARFRewriter::updateDebugInfo() {
createRangeLocListAddressWriters(*CU);
std::optional<DWARFUnit *> SplitCU;
std::optional<uint64_t> DWOId = CU->getDWOId();
if (DWOId)
if (DWOId && *DWOId != 0)
SplitCU = BC.getDWOCU(*DWOId);
if (!SplitCU)
continue;
Expand Down
Loading
Loading