Skip to content

Commit 8f6d52c

Browse files
committed
DWARFVerifier: Don't error on missing ranges in Split DWARF
When verifying dwo files address ranges won't be able to be resolved due to missing debug_addr (or missing debug_ranges in the case of DWARFv4 Split DWARF).
1 parent b239b2b commit 8f6d52c

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,13 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie &Die,
403403
if (!Die.isValid())
404404
return NumErrors;
405405

406+
DWARFUnit *Unit = Die.getDwarfUnit();
407+
406408
auto RangesOrError = Die.getAddressRanges();
407409
if (!RangesOrError) {
408410
// FIXME: Report the error.
409-
++NumErrors;
411+
if (!Unit->isDWOUnit())
412+
++NumErrors;
410413
llvm::consumeError(RangesOrError.takeError());
411414
return NumErrors;
412415
}
@@ -505,10 +508,12 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
505508
case DW_AT_ranges:
506509
// Make sure the offset in the DW_AT_ranges attribute is valid.
507510
if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) {
508-
unsigned DwarfVersion = Die.getDwarfUnit()->getVersion();
511+
unsigned DwarfVersion = U->getVersion();
509512
const DWARFSection &RangeSection = DwarfVersion < 5
510513
? DObj.getRangesSection()
511514
: DObj.getRnglistsSection();
515+
if (U->isDWOUnit() && RangeSection.Data.empty())
516+
break;
512517
if (*SectionOffset >= RangeSection.Data.size())
513518
ReportError(
514519
"DW_AT_ranges offset is beyond " +
@@ -531,7 +536,6 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
531536
case DW_AT_location: {
532537
if (Expected<std::vector<DWARFLocationExpression>> Loc =
533538
Die.getLocations(DW_AT_location)) {
534-
DWARFUnit *U = Die.getDwarfUnit();
535539
for (const auto &Entry : *Loc) {
536540
DataExtractor Data(toStringRef(Entry.Expr), DCtx.isLittleEndian(), 0);
537541
DWARFExpression Expression(Data, U->getAddressByteSize(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# RUN: llvm-mc %s -filetype obj -triple x86_64-linux-gnu -o - \
2+
# RUN: | llvm-dwarfdump -verify - 2>&1 \
3+
# RUN: | FileCheck %s --implicit-check-not=error --implicit-check-not=warning
4+
5+
# CHECK: Verifying dwo Units...
6+
# CHECK: No errors.
7+
8+
.section .debug_info.dwo,"e",@progbits
9+
.long .Ldebug_info_dwo_end6-.Ldebug_info_dwo_start6 # Length of Unit
10+
.Ldebug_info_dwo_start6:
11+
.short 4 # DWARF version number
12+
.long 0 # Offset Into Abbrev. Section
13+
.byte 8 # Address Size (in bytes)
14+
.byte 1 # Abbrev [4] DW_TAG_compile_unit
15+
.byte 1 # DW_AT_ranges
16+
.Ldebug_info_dwo_end6:
17+
.section .debug_abbrev.dwo,"e",@progbits
18+
.byte 1 # Abbreviation Code
19+
.byte 17 # DW_TAG_compile_unit
20+
.byte 0 # DW_CHILDREN_no
21+
.byte 85 # DW_AT_ranges
22+
.byte 23 # DW_FORM_sec_offset
23+
.byte 0 # EOM(1)
24+
.byte 0 # EOM(2)
25+
.byte 0 # EOM(3)

0 commit comments

Comments
 (0)