[llvm] 467c251 - llvm-dwarfdump: Don't try to parse a debug_loclist contribution if this CU has no DW_AT_loclists_base
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 15:54:23 PDT 2020
Author: David Blaikie
Date: 2020-04-14T15:54:13-07:00
New Revision: 467c2514eb82aef4ec394d1dca5f4de11d33a830
URL: https://github.com/llvm/llvm-project/commit/467c2514eb82aef4ec394d1dca5f4de11d33a830
DIFF: https://github.com/llvm/llvm-project/commit/467c2514eb82aef4ec394d1dca5f4de11d33a830.diff
LOG: llvm-dwarfdump: Don't try to parse a debug_loclist contribution if this CU has no DW_AT_loclists_base
llvm-dwarfdump was trying to parse debug_loclists even in the absence of
a loclists_base if there was a loclists section at all.
Added:
llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_nouse.s
Modified:
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 31c5cc8c076d..30eb0174fc9c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -527,14 +527,20 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
// In a split dwarf unit, there is no DW_AT_loclists_base attribute.
// Setting LocSectionBase to point past the table header.
- if (IsDWO)
- setLocSection(&Context.getDWARFObj().getLoclistsDWOSection(),
+ if (IsDWO) {
+ auto &DWOSection = Context.getDWARFObj().getLoclistsDWOSection();
+ if (DWOSection.Data.empty())
+ return Error::success();
+ setLocSection(&DWOSection,
DWARFListTableHeader::getHeaderSize(Header.getFormat()));
- else
+ } else if (auto X = UnitDie.find(DW_AT_loclists_base)) {
setLocSection(&Context.getDWARFObj().getLoclistsSection(),
- toSectionOffset(UnitDie.find(DW_AT_loclists_base), 0));
+ toSectionOffset(X, 0));
+ } else {
+ return Error::success();
+ }
- if (LocSection->Data.size()) {
+ if (LocSection) {
if (IsDWO)
LoclistTableHeader.emplace(".debug_loclists.dwo", "locations");
else
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_nouse.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_nouse.s
new file mode 100644
index 000000000000..0b9a08747151
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_nouse.s
@@ -0,0 +1,25 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
+# RUN: llvm-dwarfdump %t.o | FileCheck %s
+
+# CHECK: 0x00000000: Compile Unit: length = 0x00000009 version = 0x0005 unit_type = DW_UT_compile abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000000d)
+# CHECK: 0x0000000c: DW_TAG_compile_unit
+
+ .section .debug_abbrev,"", at progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_info,"", at progbits
+.Lcu_begin0:
+ .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+ .short 5 # DWARF version number
+ .byte 1 # DWARF Unit Type
+ .byte 8 # Address Size (in bytes)
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 1 # Abbrev [1] 0xc:0x22 DW_TAG_compile_unit
+.Ldebug_info_end0:
+ .section .debug_loclists,"", at progbits
+ .byte 0
More information about the llvm-commits
mailing list