diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index d7da90afe564..517f7a483545 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -164,9 +164,8 @@ public: /// referenced by the name table and interpreted with the help of the /// abbreviation table. class DWARFDebugNames : public DWARFAcceleratorTable { -public: - /// Dwarf 5 Name Index header. - struct Header { + /// The fixed-size part of a Dwarf 5 Name Index header + struct HeaderPOD { uint32_t UnitLength; uint16_t Version; uint16_t Padding; @@ -177,6 +176,11 @@ public: uint32_t NameCount; uint32_t AbbrevTableSize; uint32_t AugmentationStringSize; + }; + +public: + /// Dwarf 5 Name Index header. + struct Header : public HeaderPOD { SmallString<8> AugmentationString; Error extract(const DWARFDataExtractor &AS, uint32_t *Offset); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index 203f88499742..9111d732a8fe 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -331,7 +331,7 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const { llvm::Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS, uint32_t *Offset) { // Check that we can read the fixed-size part. - if (!AS.isValidOffset(*Offset + sizeof(Header) - 1)) + if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1)) return make_error("Section too small: cannot read header.", inconvertibleErrorCode());