From: Wolfgang Pieb Date: Thu, 26 Jul 2018 01:12:41 +0000 (+0000) Subject: [DWARF v5] Don't report an error when the .debug_rnglists section is empty or non... X-Git-Tag: llvmorg-7.0.0-rc1~555 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d56b4ae40c6dc7bbf6ec6917c986ae5210d1b70;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 337993 --- diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 51d0865..3b40885 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -314,22 +314,24 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { 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 diff --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s index 749f4f1..e68f08b 100644 --- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s +++ b/llvm/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 @@ 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: