1 //===------ utils/obj2yaml.cpp - obj2yaml conversion tool -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "llvm/Object/Archive.h"
12 #include "llvm/Object/COFF.h"
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Support/ManagedStatic.h"
15 #include "llvm/Support/PrettyStackTrace.h"
16 #include "llvm/Support/Signals.h"
26 cl::opt<ObjectFileType> InputFormat(
27 cl::desc("Choose input format"),
28 cl::values(clEnumVal(coff, "process COFF object files"), clEnumValEnd));
30 cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input file>"),
33 int main(int argc, char *argv[]) {
34 cl::ParseCommandLineOptions(argc, argv);
35 sys::PrintStackTraceOnErrorSignal();
36 PrettyStackTraceProgram X(argc, argv);
37 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
39 // Process the input file
40 std::unique_ptr<MemoryBuffer> buf;
42 // TODO: If this is an archive, then burst it and dump each entry
43 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, buf)) {
44 errs() << "Error: '" << ec.message() << "' opening file '" << InputFilename
47 ec = coff2yaml(outs(), buf.release());
49 errs() << "Error: " << ec.message() << " dumping COFF file\n";