[llvm] 99960de - [DWARF] Get rid of DWARFDebugNames::HeaderPOD. NFC.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 00:14:27 PST 2020
Author: Igor Kudrin
Date: 2020-01-23T15:11:58+07:00
New Revision: 99960de7414a350a2953008875e904a0b70df171
URL: https://github.com/llvm/llvm-project/commit/99960de7414a350a2953008875e904a0b70df171
DIFF: https://github.com/llvm/llvm-project/commit/99960de7414a350a2953008875e904a0b70df171.diff
LOG: [DWARF] Get rid of DWARFDebugNames::HeaderPOD. NFC.
This structure was used to get the size of the fixed-size part of a Name
Index header for 32-bit DWARF. It is unsuitable for 64-bit DWARF because
the size of the unit length field is different.
Differential Revision: https://reviews.llvm.org/D73040
Added:
Modified:
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
index c9042e593260..b60aef90871d 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -222,8 +222,13 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
/// referenced by the name table and interpreted with the help of the
/// abbreviation table.
class DWARFDebugNames : public DWARFAcceleratorTable {
- /// The fixed-size part of a DWARF v5 Name Index header
- struct HeaderPOD {
+public:
+ class NameIndex;
+ class NameIterator;
+ class ValueIterator;
+
+ /// DWARF v5 Name Index header.
+ struct Header {
uint32_t UnitLength;
uint16_t Version;
uint16_t Padding;
@@ -234,15 +239,6 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
uint32_t NameCount;
uint32_t AbbrevTableSize;
uint32_t AugmentationStringSize;
- };
-
-public:
- class NameIndex;
- class NameIterator;
- class ValueIterator;
-
- /// DWARF v5 Name Index header.
- struct Header : public HeaderPOD {
SmallString<8> AugmentationString;
Error extract(const DWARFDataExtractor &AS, uint64_t *Offset);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 575edba51ee8..07760a8ec78f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -378,8 +378,20 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const {
Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS,
uint64_t *Offset) {
+ // These fields are the same for 32-bit and 64-bit DWARF formats.
+ constexpr unsigned CommonHeaderSize = 2 + // Version
+ 2 + // Padding
+ 4 + // CU count
+ 4 + // Local TU count
+ 4 + // Foreign TU count
+ 4 + // Bucket count
+ 4 + // Name count
+ 4 + // Abbreviations table size
+ 4; // Augmentation string size
+ static const unsigned DWARF32HeaderFixedPartSize =
+ dwarf::getUnitLengthFieldByteSize(dwarf::DWARF32) + CommonHeaderSize;
// Check that we can read the fixed-size part.
- if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1))
+ if (!AS.isValidOffsetForDataOfSize(*Offset, DWARF32HeaderFixedPartSize))
return createStringError(errc::illegal_byte_sequence,
"Section too small: cannot read header.");
More information about the llvm-commits
mailing list