[PATCH] D35444: [DWARF] Modification of code for the verification of .debug_info section.

Spyridoula Gravani via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 18:22:18 PDT 2017


sgravani updated this revision to Diff 106742.
sgravani added a comment.

Minor, yet very important, change to the previous diff. 
OffsetStart has to be equal to the beginning of the unit before verifying the contents of the unit...


https://reviews.llvm.org/D35444

Files:
  include/llvm/DebugInfo/DWARF/DWARFVerifier.h
  lib/DebugInfo/DWARF/DWARFVerifier.cpp


Index: lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -25,8 +25,8 @@
 using namespace object;
 
 bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
-                               uint32_t *Offset, unsigned UnitIndex,
-                               bool &isUnitDWARF64) {
+                                     uint32_t *Offset, unsigned UnitIndex,
+                                     uint8_t &UnitType, bool &isUnitDWARF64) {
   uint32_t AbbrOffset, Length;
   uint8_t AddrSize = 0;
   uint16_t Version;
@@ -109,11 +109,14 @@
   DWARFDataExtractor DebugInfoData(DCtx.getInfoSection(), DCtx.isLittleEndian(),
                                    0);
   uint32_t OffsetStart = 0, Offset = 0, UnitIdx = 0;
+  uint8_t UnitType = 0;
   bool isUnitDWARF64 = false;
   bool Success = true;
   bool hasDIE = DebugInfoData.isValidOffset(Offset);
   while (hasDIE) {
-    if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, isUnitDWARF64)) {
+    OffsetStart = Offset;
+    if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, UnitType,
+                          isUnitDWARF64)) {
       Success = false;
       if (isUnitDWARF64)
         break;
Index: include/llvm/DebugInfo/DWARF/DWARFVerifier.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFVerifier.h
+++ include/llvm/DebugInfo/DWARF/DWARFVerifier.h
@@ -34,7 +34,6 @@
   uint32_t NumDebugInfoErrors = 0;
   uint32_t NumDebugLineErrors = 0;
   uint32_t NumAppleNamesErrors = 0;
-  uint32_t UnitType = 0;
 
   /// Verifies the header of a unit in the .debug_info section.
   ///
@@ -51,12 +50,13 @@
   /// \param Offset A reference to the offset start of the unit. The offset will
   /// be updated to point to the next unit in .debug_info
   /// \param UnitIndex The index of the unit to be verified
+  /// \param UnitType A reference to the type of the unit
   /// \param isUnitDWARF64 A reference to a flag that shows whether the unit is
   /// in 64-bit format.
   ///
   /// \returns true if the header is verified successfully, false otherwise.
   bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
-                        uint32_t *Offset, unsigned UnitIndex,
+                        uint32_t *Offset, unsigned UnitIndex, uint8_t &UnitType,
                         bool &isUnitDWARF64);
 
   bool verifyUnitContents(DWARFUnit Unit);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35444.106742.patch
Type: text/x-patch
Size: 2537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170715/6ce6b5cd/attachment.bin>


More information about the llvm-commits mailing list