From 15fa44698cbf525d604961c82d72f54064ab4f40 Mon Sep 17 00:00:00 2001 From: Wolfgang Pieb Date: Tue, 9 May 2017 19:38:38 +0000 Subject: [DWARF] Fix a parsing issue with type unit headers. Reviewers: dblaikie Differential Revision: https://reviews.llvm.org/D32987 llvm-svn: 302574 --- llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/DebugInfo') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp index e0f81938328..25824f6eb83 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -24,7 +24,11 @@ bool DWARFTypeUnit::extractImpl(DataExtractor debug_info, return false; TypeHash = debug_info.getU64(offset_ptr); TypeOffset = debug_info.getU32(offset_ptr); - return TypeOffset < getLength(); + // TypeOffset is relative to the beginning of the header, + // so we have to account for the leading length field. + // FIXME: The size of the length field is 12 in DWARF64. + unsigned SizeOfLength = 4; + return TypeOffset < getLength() + SizeOfLength; } void DWARFTypeUnit::dump(raw_ostream &OS, bool SummarizeTypes) { -- cgit v1.2.3