[llvm] r361582 - dwarfdump: Add a bit more DWARF64 support
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 18:05:52 PDT 2019
Author: dblaikie
Date: Thu May 23 18:05:52 2019
New Revision: 361582
URL: http://llvm.org/viewvc/llvm-project?rev=361582&view=rev
Log:
dwarfdump: Add a bit more DWARF64 support
This test case was incorrect because it mixed DWARF32 and DWARF64 for a
single unit (DWARF32 unit referencing a DWARF64 str_offsets section). So
fix enough of the unit parsing for DWARF64 and make the test valid.
(not sure if anyone needs DWARF64 support though - support in
libDebugInfoDWARF has been added piecemeal and LLVM doesn't produce it
at all)
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=361582&r1=361581&r2=361582&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Thu May 23 18:05:52 2019
@@ -48,7 +48,7 @@ class DWARFUnitHeader {
uint32_t Offset = 0;
// Version, address size, and DWARF format.
dwarf::FormParams FormParams;
- uint32_t Length = 0;
+ uint64_t Length = 0;
uint64_t AbbrOffset = 0;
// For DWO units only.
@@ -82,7 +82,7 @@ public:
uint8_t getDwarfOffsetByteSize() const {
return FormParams.getDwarfOffsetByteSize();
}
- uint32_t getLength() const { return Length; }
+ uint64_t getLength() const { return Length; }
uint64_t getAbbrOffset() const { return AbbrOffset; }
Optional<uint64_t> getDWOId() const { return DWOId; }
void setDWOId(uint64_t Id) {
@@ -97,8 +97,11 @@ public:
return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
}
uint8_t getSize() const { return Size; }
- // FIXME: Support DWARF64.
- uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
+ uint32_t getNextUnitOffset() const {
+ return Offset + Length +
+ (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) +
+ FormParams.getDwarfOffsetByteSize();
+ }
};
const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=361582&r1=361581&r2=361582&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Thu May 23 18:05:52 2019
@@ -242,16 +242,20 @@ bool DWARFUnitHeader::extract(DWARFConte
if (!IndexEntry && Index)
IndexEntry = Index->getFromOffset(*offset_ptr);
Length = debug_info.getU32(offset_ptr);
- // FIXME: Support DWARF64.
- unsigned SizeOfLength = 4;
FormParams.Format = DWARF32;
+ unsigned SizeOfLength = 4;
+ if (Length == 0xffffffff) {
+ Length = debug_info.getU64(offset_ptr);
+ FormParams.Format = DWARF64;
+ SizeOfLength = 8;
+ }
FormParams.Version = debug_info.getU16(offset_ptr);
if (FormParams.Version >= 5) {
UnitType = debug_info.getU8(offset_ptr);
FormParams.AddrSize = debug_info.getU8(offset_ptr);
- AbbrOffset = debug_info.getU32(offset_ptr);
+ AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
} else {
- AbbrOffset = debug_info.getRelocatedValue(4, offset_ptr);
+ AbbrOffset = debug_info.getRelocatedValue(FormParams.getDwarfOffsetByteSize(), offset_ptr);
FormParams.AddrSize = debug_info.getU8(offset_ptr);
// Fake a unit type based on the section type. This isn't perfect,
// but distinguishing compile and type units is generally enough.
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=361582&r1=361581&r2=361582&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Thu May 23 18:05:52 2019
@@ -100,7 +100,7 @@ bool DWARFVerifier::DieRangeInfo::inters
bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
uint32_t *Offset, unsigned UnitIndex,
uint8_t &UnitType, bool &isUnitDWARF64) {
- uint32_t AbbrOffset, Length;
+ uint64_t AbbrOffset, Length;
uint8_t AddrSize = 0;
uint16_t Version;
bool Success = true;
@@ -114,22 +114,19 @@ bool DWARFVerifier::verifyUnitHeader(con
uint32_t OffsetStart = *Offset;
Length = DebugInfoData.getU32(Offset);
if (Length == UINT32_MAX) {
+ Length = DebugInfoData.getU64(Offset);
isUnitDWARF64 = true;
- OS << format(
- "Unit[%d] is in 64-bit DWARF format; cannot verify from this point.\n",
- UnitIndex);
- return false;
}
Version = DebugInfoData.getU16(Offset);
if (Version >= 5) {
UnitType = DebugInfoData.getU8(Offset);
AddrSize = DebugInfoData.getU8(Offset);
- AbbrOffset = DebugInfoData.getU32(Offset);
+ AbbrOffset = isUnitDWARF64 ? DebugInfoData.getU64(Offset) : DebugInfoData.getU32(Offset);
ValidType = dwarf::isUnitType(UnitType);
} else {
UnitType = 0;
- AbbrOffset = DebugInfoData.getU32(Offset);
+ AbbrOffset = isUnitDWARF64 ? DebugInfoData.getU64(Offset) : DebugInfoData.getU32(Offset);
AddrSize = DebugInfoData.getU8(Offset);
}
@@ -157,7 +154,7 @@ bool DWARFVerifier::verifyUnitHeader(con
if (!ValidAddrSize)
note() << "The address size is unsupported.\n";
}
- *Offset = OffsetStart + Length + 4;
+ *Offset = OffsetStart + Length + (isUnitDWARF64 ? 12 : 4);
return Success;
}
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=361582&r1=361581&r2=361582&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s Thu May 23 18:05:52 2019
@@ -239,18 +239,19 @@ TypeDie:
CU1_5_end:
# DWARF v5 CU header
- .long CU2_5_end-CU2_5_version # Length of Unit
+ .long 0xffffffff
+ .quad CU2_5_end-CU2_5_version # Length of Unit
CU2_5_version:
.short 5 # DWARF version number
.byte 1 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
- .long .debug_abbrev # Offset Into Abbrev. Section
+ .quad .debug_abbrev # Offset Into Abbrev. Section
# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
# DW_AT_str_offsets and DW_AT_compdir.
.byte 1 # Abbreviation code
.byte 0 # The index of the producer string
.byte 1 # The index of the CU name string
- .long .debug_str_offsets_base1
+ .quad .debug_str_offsets_base1
.byte 2 # The index of the comp dir string
.byte 0 # NULL
CU2_5_end:
More information about the llvm-commits
mailing list