[llvm] r337993 - [DWARF v5] Don't report an error when the .debug_rnglists section is empty or non-existent. Fixes PR38297.

Wolfgang Pieb via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 18:12:41 PDT 2018


Author: wolfgangp
Date: Wed Jul 25 18:12:41 2018
New Revision: 337993

URL: http://llvm.org/viewvc/llvm-project?rev=337993&view=rev
Log:
[DWARF v5] Don't report an error when the .debug_rnglists section is empty or non-existent. Fixes PR38297.

Reviewer: JDevlieghere

Differential Revision: https://reviews.llvm.org/D49815
 

Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
    llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=337993&r1=337992&r2=337993&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Wed Jul 25 18:12:41 2018
@@ -314,22 +314,24 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo
       else
         setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
                          toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));
-      // Parse the range list table header. Individual range lists are
-      // extracted lazily.
-      DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
-                                  isLittleEndian, 0);
-      if (auto TableOrError =
-              parseRngListTableHeader(RangesDA, RangeSectionBase))
-        RngListTable = TableOrError.get();
-      else
-        WithColor::error() << "parsing a range list table: "
-                           << toString(TableOrError.takeError())
-                           << '\n';
+      if (RangeSection->Data.size()) {
+        // Parse the range list table header. Individual range lists are
+        // extracted lazily.
+        DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
+                                    isLittleEndian, 0);
+        if (auto TableOrError =
+                parseRngListTableHeader(RangesDA, RangeSectionBase))
+          RngListTable = TableOrError.get();
+        else
+          WithColor::error() << "parsing a range list table: "
+                             << toString(TableOrError.takeError())
+                             << '\n';
 
-      // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
-      // Adjust RangeSectionBase to point past the table header.
-      if (isDWO && RngListTable)
-        RangeSectionBase = RngListTable->getHeaderSize();
+        // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
+        // Adjust RangeSectionBase to point past the table header.
+        if (isDWO && RngListTable)
+          RangeSectionBase = RngListTable->getHeaderSize();
+      }
     }
 
     // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for

Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s?rev=337993&r1=337992&r2=337993&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s Wed Jul 25 18:12:41 2018
@@ -1,5 +1,8 @@
 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
-# RUN: llvm-dwarfdump -v %t.o | FileCheck --check-prefix=COMMON --check-prefix=SPLIT %s
+# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefix=COMMON --check-prefix=SPLIT %s
+# 
+# Check that we don't report an error on a non-existent range list table.
+# RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err
 
 # Test object to verify dwarfdump handles v5 string offset tables.
 # We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU.
@@ -382,3 +385,5 @@ TU_split_5_end:
 # SPLIT-NEXT:  0x00000010: 00000034 "/home/test/splitCU"
 # SPLIT-NEXT:  0x00000014: 00000047 "V5_split_type_unit"
 # SPLIT-NEXT:  0x00000018: 0000005a "V5_split_Mystruct"
+
+# ERR-NOT: parsing a range list table:




More information about the llvm-commits mailing list