[llvm] 8f6d52c - DWARFVerifier: Don't error on missing ranges in Split DWARF

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 20:35:27 PST 2021


Author: David Blaikie
Date: 2021-12-16T20:34:44-08:00
New Revision: 8f6d52c8db31eff6bcf54d90a4043882993c54f2

URL: https://github.com/llvm/llvm-project/commit/8f6d52c8db31eff6bcf54d90a4043882993c54f2
DIFF: https://github.com/llvm/llvm-project/commit/8f6d52c8db31eff6bcf54d90a4043882993c54f2.diff

LOG: 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).

Added: 
    llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu_ranges.s

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 4ec0fce3c4432..99255f6b5b661 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -403,10 +403,13 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie &Die,
   if (!Die.isValid())
     return NumErrors;
 
+  DWARFUnit *Unit = Die.getDwarfUnit();
+
   auto RangesOrError = Die.getAddressRanges();
   if (!RangesOrError) {
     // FIXME: Report the error.
-    ++NumErrors;
+    if (!Unit->isDWOUnit())
+      ++NumErrors;
     llvm::consumeError(RangesOrError.takeError());
     return NumErrors;
   }
@@ -505,10 +508,12 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
   case DW_AT_ranges:
     // Make sure the offset in the DW_AT_ranges attribute is valid.
     if (auto SectionOffset = AttrValue.Value.getAsSectionOffset()) {
-      unsigned DwarfVersion = Die.getDwarfUnit()->getVersion();
+      unsigned DwarfVersion = U->getVersion();
       const DWARFSection &RangeSection = DwarfVersion < 5
                                              ? DObj.getRangesSection()
                                              : DObj.getRnglistsSection();
+      if (U->isDWOUnit() && RangeSection.Data.empty())
+        break;
       if (*SectionOffset >= RangeSection.Data.size())
         ReportError(
             "DW_AT_ranges offset is beyond " +
@@ -531,7 +536,6 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
   case DW_AT_location: {
     if (Expected<std::vector<DWARFLocationExpression>> Loc =
             Die.getLocations(DW_AT_location)) {
-      DWARFUnit *U = Die.getDwarfUnit();
       for (const auto &Entry : *Loc) {
         DataExtractor Data(toStringRef(Entry.Expr), DCtx.isLittleEndian(), 0);
         DWARFExpression Expression(Data, U->getAddressByteSize(),

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu_ranges.s b/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu_ranges.s
new file mode 100644
index 0000000000000..d5a15cfb64bc7
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/verify_split_cu_ranges.s
@@ -0,0 +1,25 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-linux-gnu -o - \
+# RUN: | llvm-dwarfdump -verify - 2>&1 \
+# RUN: | FileCheck %s --implicit-check-not=error --implicit-check-not=warning
+
+# CHECK: Verifying dwo Units...
+# CHECK: No errors.
+
+	.section	.debug_info.dwo,"e", at progbits
+	.long	.Ldebug_info_dwo_end6-.Ldebug_info_dwo_start6 # Length of Unit
+.Ldebug_info_dwo_start6:
+	.short	4                               # DWARF version number
+	.long	0                               # Offset Into Abbrev. Section
+	.byte	8                               # Address Size (in bytes)
+	.byte	1                               # Abbrev [4] DW_TAG_compile_unit
+	.byte	1                               # DW_AT_ranges
+.Ldebug_info_dwo_end6:
+	.section	.debug_abbrev.dwo,"e", at progbits
+	.byte	1                               # Abbreviation Code
+	.byte	17                              # DW_TAG_compile_unit
+	.byte	0                               # DW_CHILDREN_no
+	.byte	85                              # DW_AT_ranges
+	.byte	23                              # DW_FORM_sec_offset
+	.byte	0                               # EOM(1)
+	.byte	0                               # EOM(2)
+	.byte	0                               # EOM(3)


        


More information about the llvm-commits mailing list