[llvm] r199340 - llvm-objdump: Don't print "Import table:" header if there's no import table.

Rui Ueyama ruiu at google.com
Wed Jan 15 15:46:19 PST 2014


Author: ruiu
Date: Wed Jan 15 17:46:18 2014
New Revision: 199340

URL: http://llvm.org/viewvc/llvm-project?rev=199340&view=rev
Log:
llvm-objdump: Don't print "Import table:" header if there's no import table.

If a binary does not depend on any DLL, it does not contain import table at
all. Printing the section title without contents looks wrong, so we shouldn't
print it in that case.

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=199340&r1=199339&r2=199340&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Wed Jan 15 17:46:18 2014
@@ -230,11 +230,13 @@ static void printCOFFSymbolAddress(llvm:
 // Prints import tables. The import table is a table containing the list of
 // DLL name and symbol names which will be linked by the loader.
 static void printImportTables(const COFFObjectFile *Obj) {
+  import_directory_iterator i = Obj->import_directory_begin();
+  import_directory_iterator e = Obj->import_directory_end();
+  if (i == e)
+    return;
   outs() << "The Import Tables:\n";
   error_code ec;
-  for (import_directory_iterator i = Obj->import_directory_begin(),
-                                 e = Obj->import_directory_end();
-       i != e; i = i.increment(ec)) {
+  for (; i != e; i = i.increment(ec)) {
     if (ec)
       return;
 





More information about the llvm-commits mailing list