readobj: Dump PE/COFF optional records.

These records are mandatory for executables and are used by the loader.

Reviewers: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D939

llvm-svn: 183852
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp
index 201899f..a149770 100644
--- a/llvm/lib/Object/Binary.cpp
+++ b/llvm/lib/Object/Binary.cpp
@@ -84,8 +84,10 @@
     }
     case sys::fs::file_magic::coff_object:
     case sys::fs::file_magic::pecoff_executable: {
-      OwningPtr<Binary> ret(new COFFObjectFile(scopedSource.take(), ec));
-      if (ec) return ec;
+      OwningPtr<Binary> ret(
+          ObjectFile::createCOFFObjectFile(scopedSource.take()));
+      if (!ret)
+        return object_error::invalid_file_type;
       Result.swap(ret);
       return object_error::success;
     }