aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2019-05-24 01:05:52 +0000
committerDavid Blaikie <dblaikie@gmail.com>2019-05-24 01:05:52 +0000
commit79872a88a0662ee91cdb194a8ea477c79a824e9f (patch)
tree7fc6776b6c6d3c2e891e9e86f1a3add0f65bb1b8 /llvm/lib
parent052f87ae36163cbd2033617eba655af7f1438733 (diff)
downloadllvm-79872a88a0662ee91cdb194a8ea477c79a824e9f.zip
llvm-79872a88a0662ee91cdb194a8ea477c79a824e9f.tar.gz
llvm-79872a88a0662ee91cdb194a8ea477c79a824e9f.tar.bz2
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) llvm-svn: 361582
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp12
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp13
2 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 65b118f..7bc5221 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -242,16 +242,20 @@ bool DWARFUnitHeader::extract(DWARFContext &Context,
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.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 8fea97a..c2b3189 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -100,7 +100,7 @@ bool DWARFVerifier::DieRangeInfo::intersects(const DieRangeInfo &RHS) const {
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(const DWARFDataExtractor DebugInfoData,
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(const DWARFDataExtractor DebugInfoData,
if (!ValidAddrSize)
note() << "The address size is unsupported.\n";
}
- *Offset = OffsetStart + Length + 4;
+ *Offset = OffsetStart + Length + (isUnitDWARF64 ? 12 : 4);
return Success;
}