[PATCH] D49815: [DWARF v5] Don't report an error when the .debug_rnglists section is empty or non-existent (PR 38297)
Wolfgang Pieb via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 25 11:56:12 PDT 2018
wolfgangp created this revision.
wolfgangp added reviewers: dblaikie, probinson, aprantl, JDevlieghere.
When we are parsing a CU DIE we do attempt to find a valid range lists table header (the ranges are extracted on-demand). We fail to ignore a non-existent or empty .debug_rnglists section and report an error.
This doesn't address the larger question whether we should exit from llvm-dwarfdump with a non-zero code whenever an error is reported, whether verification is requested or not.
https://bugs.llvm.org/show_bug.cgi?id=38297
https://reviews.llvm.org/D49815
Files:
lib/DebugInfo/DWARF/DWARFUnit.cpp
test/DebugInfo/X86/dwarfdump-str-offsets.s
Index: test/DebugInfo/X86/dwarfdump-str-offsets.s
===================================================================
--- test/DebugInfo/X86/dwarfdump-str-offsets.s
+++ test/DebugInfo/X86/dwarfdump-str-offsets.s
@@ -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 @@
# 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:
Index: lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -314,22 +314,24 @@
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';
-
- // 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();
+ 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();
+ }
}
// Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49815.157330.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180725/357ad2de/attachment.bin>
More information about the llvm-commits
mailing list