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 {
222
222
// / referenced by the name table and interpreted with the help of the
223
223
// / abbreviation table.
224
224
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 {
227
232
uint32_t UnitLength;
228
233
uint16_t Version;
229
234
uint16_t Padding;
@@ -234,15 +239,6 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
234
239
uint32_t NameCount;
235
240
uint32_t AbbrevTableSize;
236
241
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 {
246
242
SmallString<8 > AugmentationString;
247
243
248
244
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 {
378
378
379
379
Error DWARFDebugNames::Header::extract (const DWARFDataExtractor &AS,
380
380
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;
381
393
// Check that we can read the fixed-size part.
382
- if (!AS.isValidOffset (*Offset + sizeof (HeaderPOD) - 1 ))
394
+ if (!AS.isValidOffsetForDataOfSize (*Offset, DWARF32HeaderFixedPartSize ))
383
395
return createStringError (errc::illegal_byte_sequence,
384
396
" Section too small: cannot read header." );
385
397
You can’t perform that action at this time.
0 commit comments