[llvm] r201179 - make llvm-dwarfdump a little more resilient when parsing .debug_loc

Adrian Prantl aprantl at apple.com
Tue Feb 11 13:22:54 PST 2014


Author: adrian
Date: Tue Feb 11 15:22:53 2014
New Revision: 201179

URL: http://llvm.org/viewvc/llvm-project?rev=201179&view=rev
Log:
make llvm-dwarfdump a little more resilient when parsing .debug_loc
sections. The call to data.getUnsigned(&Offset, AddressSize) only
increments Offset if the read succeeds, which will result in an infinite
loop.

Modified:
    llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp?rev=201179&r1=201178&r2=201179&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugLoc.cpp Tue Feb 11 15:22:53 2014
@@ -36,7 +36,7 @@ void DWARFDebugLoc::dump(raw_ostream &OS
 
 void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) {
   uint32_t Offset = 0;
-  while (data.isValidOffset(Offset)) {
+  while (data.isValidOffset(Offset+AddressSize-1)) {
     Locations.resize(Locations.size() + 1);
     LocationList &Loc = Locations.back();
     Loc.Offset = Offset;
@@ -71,4 +71,6 @@ void DWARFDebugLoc::parse(DataExtractor
       Loc.Entries.push_back(llvm_move(E));
     }
   }
+  if (data.isValidOffset(Offset))
+    llvm::errs() << "error: failed to consume entire .debug_loc section\n";
 }





More information about the llvm-commits mailing list