[llvm] r323648 - Fix windows test failure caused by r323638

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 05:53:48 PST 2018


Author: labath
Date: Mon Jan 29 05:53:48 2018
New Revision: 323648

URL: http://llvm.org/viewvc/llvm-project?rev=323648&view=rev
Log:
Fix windows test failure caused by r323638

The test was failing because of an incorrect sizeof check in the name
index parsing code. This code was meant to check that we have enough
input to parse the fixed-size part of the dwarf header, which it did by
comparing the input to sizeof(Header). Originally struct Header only
contained the fixed-size part, but during review, we've moved additional
members into it, which rendered the sizeof check invalid.

I resolve this by moving the fixed-size part to a separate struct and
updating the sizeof-expression to use that.

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h?rev=323648&r1=323647&r2=323648&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h Mon Jan 29 05:53:48 2018
@@ -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);

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp?rev=323648&r1=323647&r2=323648&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Mon Jan 29 05:53:48 2018
@@ -331,7 +331,7 @@ void DWARFDebugNames::Header::dump(Scope
 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<StringError>("Section too small: cannot read header.",
                                    inconvertibleErrorCode());
 




More information about the llvm-commits mailing list