[llvm] r202466 - llvm-objdump: Fix crash bug with printing unwind info on stripped file.

Rui Ueyama ruiu at google.com
Thu Feb 27 21:21:29 PST 2014


Author: ruiu
Date: Thu Feb 27 23:21:29 2014
New Revision: 202466

URL: http://llvm.org/viewvc/llvm-project?rev=202466&view=rev
Log:
llvm-objdump: Fix crash bug with printing unwind info on stripped file.

The current COFF unwind printer tries to print SEH handler function names,
assuming that it can always find function names in string table. It crashes
if file being read has no symbol table (i.e. executable).

With this patch, llvm-objdump prints SEH handler's RVA if there's no symbol
table entry for that RVA.

Modified:
    llvm/trunk/tools/llvm-objdump/COFFDump.cpp

Modified: llvm/trunk/tools/llvm-objdump/COFFDump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/COFFDump.cpp?rev=202466&r1=202465&r2=202466&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Thu Feb 27 23:21:29 2014
@@ -182,10 +182,10 @@ static error_code resolveSymbol(const st
       return EC;
     if (Ofs == Offset) {
       Sym = *I->getSymbol();
-      break;
+      return object_error::success;
     }
   }
-  return object_error::success;
+  return object_error::parse_failed;
 }
 
 // Given a vector of relocations for a section and an offset into this section
@@ -225,11 +225,13 @@ static void printCOFFSymbolAddress(llvm:
                                    const std::vector<RelocationRef> &Rels,
                                    uint64_t Offset, uint32_t Disp) {
   StringRef Sym;
-  if (error(resolveSymbolName(Rels, Offset, Sym)))
-    return;
-  Out << Sym;
-  if (Disp > 0)
-    Out << format(" + 0x%04x", Disp);
+  if (!resolveSymbolName(Rels, Offset, Sym)) {
+    Out << Sym;
+    if (Disp > 0)
+      Out << format(" + 0x%04x", Disp);
+  } else {
+    Out << format("0x%04x", Disp);
+  }
 }
 
 static void





More information about the llvm-commits mailing list