Skip to content

Commit 99960de

Browse files
committed
[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
1 parent 62c221b commit 99960de

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,13 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
222222
/// referenced by the name table and interpreted with the help of the
223223
/// abbreviation table.
224224
class DWARFDebugNames : public DWARFAcceleratorTable {
225-
/// The fixed-size part of a DWARF v5 Name Index header
226-
struct HeaderPOD {
225+
public:
226+
class NameIndex;
227+
class NameIterator;
228+
class ValueIterator;
229+
230+
/// DWARF v5 Name Index header.
231+
struct Header {
227232
uint32_t UnitLength;
228233
uint16_t Version;
229234
uint16_t Padding;
@@ -234,15 +239,6 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
234239
uint32_t NameCount;
235240
uint32_t AbbrevTableSize;
236241
uint32_t AugmentationStringSize;
237-
};
238-
239-
public:
240-
class NameIndex;
241-
class NameIterator;
242-
class ValueIterator;
243-
244-
/// DWARF v5 Name Index header.
245-
struct Header : public HeaderPOD {
246242
SmallString<8> AugmentationString;
247243

248244
Error extract(const DWARFDataExtractor &AS, uint64_t *Offset);

llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,20 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const {
378378

379379
Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS,
380380
uint64_t *Offset) {
381+
// These fields are the same for 32-bit and 64-bit DWARF formats.
382+
constexpr unsigned CommonHeaderSize = 2 + // Version
383+
2 + // Padding
384+
4 + // CU count
385+
4 + // Local TU count
386+
4 + // Foreign TU count
387+
4 + // Bucket count
388+
4 + // Name count
389+
4 + // Abbreviations table size
390+
4; // Augmentation string size
391+
static const unsigned DWARF32HeaderFixedPartSize =
392+
dwarf::getUnitLengthFieldByteSize(dwarf::DWARF32) + CommonHeaderSize;
381393
// Check that we can read the fixed-size part.
382-
if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1))
394+
if (!AS.isValidOffsetForDataOfSize(*Offset, DWARF32HeaderFixedPartSize))
383395
return createStringError(errc::illegal_byte_sequence,
384396
"Section too small: cannot read header.");
385397

0 commit comments

Comments
 (0)