Skip to content

Commit

Permalink
[BOLT][DWARF] Fix line info for empty CU DIEs
Browse files Browse the repository at this point in the history
Summary:
In some rare cases a compiler may generate DWARF that contains an empty
CU DIE that references a debug line fragment. That fragment will contain
no file name information, and we fail to register it. Then, as a result,
DW_AT_stmt_list is not updated for the CU. This may cause some
DWARF-processing tools to segfault.

As a solution/workaround, we register "<unknown>" file name for such
debug line tables.

(cherry picked from FBD9526705)
  • Loading branch information
maksfb committed Aug 28, 2018
1 parent a7e0704 commit 2511b09
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bolt/src/BinaryContext.cpp
Expand Up @@ -667,6 +667,11 @@ void BinaryContext::preprocessDebugInfo(
const auto CUID = CU->getOffset();
auto *LineTable = DwCtx->getLineTableForUnit(CU.get());
const auto &FileNames = LineTable->Prologue.FileNames;
// Make sure empty debug line tables are registered too.
if (FileNames.empty()) {
cantFail(Ctx->getDwarfFile("", "<unknown>", 0, nullptr, None, CUID));
continue;
}
for (size_t I = 0, Size = FileNames.size(); I != Size; ++I) {
// Dir indexes start at 1, as DWARF file numbers, and a dir index 0
// means empty dir.
Expand Down

0 comments on commit 2511b09

Please sign in to comment.