[llvm] r366887 - [DWARF][NFC] Add constants for reserved values of an initial length field.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 04:34:29 PDT 2019
Author: ikudrin
Date: Wed Jul 24 04:34:29 2019
New Revision: 366887
URL: http://llvm.org/viewvc/llvm-project?rev=366887&view=rev
Log:
[DWARF][NFC] Add constants for reserved values of an initial length field.
Differential Revision: https://reviews.llvm.org/D65039
Modified:
llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Wed Jul 24 04:34:29 2019
@@ -46,6 +46,11 @@ enum LLVMConstants : uint32_t {
DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
DW_MACINFO_invalid = ~0U, // Macinfo type for invalid results.
+ // Special values for an initial length field.
+ DW_LENGTH_lo_reserved = 0xfffffff0, // Lower bound of the reserved range.
+ DW_LENGTH_DWARF64 = 0xffffffff, // Indicator of 64-bit DWARF format.
+ DW_LENGTH_hi_reserved = 0xffffffff, // Upper bound of the reserved range.
+
// Other constants.
DWARF_VERSION = 4, // Default dwarf version we output.
DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes.
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp Wed Jul 24 04:34:29 2019
@@ -44,7 +44,7 @@ Error DWARFDebugAddrTable::extract(DWARF
Format = dwarf::DwarfFormat::DWARF32;
if (UnitVersion >= 5) {
HeaderData.Length = Data.getU32(OffsetPtr);
- if (HeaderData.Length == 0xffffffffu) {
+ if (HeaderData.Length == dwarf::DW_LENGTH_DWARF64) {
invalidateLength();
return createStringError(errc::not_supported,
"DWARF64 is not supported in .debug_addr at offset 0x%" PRIx32,
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp Wed Jul 24 04:34:29 2019
@@ -364,7 +364,7 @@ void DWARFDebugFrame::parse(DWARFDataExt
uint64_t Length = Data.getRelocatedValue(4, &Offset);
uint64_t Id;
- if (Length == UINT32_MAX) {
+ if (Length == dwarf::DW_LENGTH_DWARF64) {
// DWARF-64 is distinguished by the first 32 bits of the initial length
// field being 0xffffffff. Then, the next 64 bits are the actual entry
// length.
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Wed Jul 24 04:34:29 2019
@@ -332,10 +332,10 @@ Error DWARFDebugLine::Prologue::parse(co
clear();
TotalLength = DebugLineData.getRelocatedValue(4, OffsetPtr);
- if (TotalLength == UINT32_MAX) {
+ if (TotalLength == dwarf::DW_LENGTH_DWARF64) {
FormParams.Format = dwarf::DWARF64;
TotalLength = DebugLineData.getU64(OffsetPtr);
- } else if (TotalLength >= 0xfffffff0) {
+ } else if (TotalLength >= dwarf::DW_LENGTH_lo_reserved) {
return createStringError(errc::invalid_argument,
"parsing line table prologue at offset 0x%8.8" PRIx64
" unsupported reserved unit length found of value 0x%8.8" PRIx64,
@@ -1126,7 +1126,8 @@ DWARFDebugLine::SectionParser::SectionPa
}
bool DWARFDebugLine::Prologue::totalLengthIsValid() const {
- return TotalLength == 0xffffffff || TotalLength < 0xfffffff0;
+ return TotalLength == dwarf::DW_LENGTH_DWARF64 ||
+ TotalLength < dwarf::DW_LENGTH_lo_reserved;
}
DWARFDebugLine::LineTable DWARFDebugLine::SectionParser::parseNext(
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp Wed Jul 24 04:34:29 2019
@@ -26,7 +26,7 @@ Error DWARFListTableHeader::extract(DWAR
SectionName.data(), *OffsetPtr);
// TODO: Add support for DWARF64.
HeaderData.Length = Data.getRelocatedValue(4, OffsetPtr);
- if (HeaderData.Length == 0xffffffffu)
+ if (HeaderData.Length == dwarf::DW_LENGTH_DWARF64)
return createStringError(errc::not_supported,
"DWARF64 is not supported in %s at offset 0x%" PRIx32,
SectionName.data(), HeaderOffset);
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Wed Jul 24 04:34:29 2019
@@ -244,7 +244,7 @@ bool DWARFUnitHeader::extract(DWARFConte
Length = debug_info.getRelocatedValue(4, offset_ptr);
FormParams.Format = DWARF32;
unsigned SizeOfLength = 4;
- if (Length == 0xffffffff) {
+ if (Length == dwarf::DW_LENGTH_DWARF64) {
Length = debug_info.getU64(offset_ptr);
FormParams.Format = DWARF64;
SizeOfLength = 8;
@@ -784,7 +784,7 @@ parseDWARF64StringOffsetsTableHeader(DWA
if (!DA.isValidOffsetForDataOfSize(Offset, 16))
return createStringError(errc::invalid_argument, "section offset exceeds section size");
- if (DA.getU32(&Offset) != 0xffffffff)
+ if (DA.getU32(&Offset) != dwarf::DW_LENGTH_DWARF64)
return createStringError(errc::invalid_argument, "32 bit contribution referenced from a 64 bit unit");
uint64_t Size = DA.getU64(&Offset);
@@ -803,7 +803,7 @@ parseDWARF32StringOffsetsTableHeader(DWA
return createStringError(errc::invalid_argument, "section offset exceeds section size");
uint32_t ContributionSize = DA.getU32(&Offset);
- if (ContributionSize >= 0xfffffff0)
+ if (ContributionSize >= dwarf::DW_LENGTH_lo_reserved)
return createStringError(errc::invalid_argument, "invalid length");
uint8_t Version = DA.getU16(&Offset);
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Wed Jul 24 04:34:29 2019
@@ -113,7 +113,7 @@ bool DWARFVerifier::verifyUnitHeader(con
uint32_t OffsetStart = *Offset;
Length = DebugInfoData.getU32(Offset);
- if (Length == UINT32_MAX) {
+ if (Length == dwarf::DW_LENGTH_DWARF64) {
Length = DebugInfoData.getU64(Offset);
isUnitDWARF64 = true;
}
Modified: llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp?rev=366887&r1=366886&r2=366887&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp Wed Jul 24 04:34:29 2019
@@ -262,7 +262,7 @@ MCSymbol *dwarfgen::LineTable::writeDefa
MCSymbol *UnitStart = Asm.createTempSymbol("line_unit_start");
MCSymbol *UnitEnd = Asm.createTempSymbol("line_unit_end");
if (Format == DwarfFormat::DWARF64) {
- Asm.emitInt32(0xffffffff);
+ Asm.emitInt32(dwarf::DW_LENGTH_DWARF64);
Asm.EmitLabelDifference(UnitEnd, UnitStart, 8);
} else {
Asm.EmitLabelDifference(UnitEnd, UnitStart, 4);
@@ -288,7 +288,7 @@ MCSymbol *dwarfgen::LineTable::writeDefa
void dwarfgen::LineTable::writePrologue(AsmPrinter &Asm) const {
if (Format == DwarfFormat::DWARF64) {
- Asm.emitInt32(0xffffffff);
+ Asm.emitInt32(dwarf::DW_LENGTH_DWARF64);
Asm.emitInt64(Prologue->TotalLength);
} else {
Asm.emitInt32(Prologue->TotalLength);
More information about the llvm-commits
mailing list