File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed
include/llvm/DebugInfo/DWARF Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff 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.
224224class 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);
Original file line number Diff line number Diff line change @@ -378,8 +378,20 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const {
378378
379379Error 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
You can’t perform that action at this time.
0 commit comments