From ad1252498d37fdf32c92569fe35bf09bb6e78caa Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 27 Nov 2010 06:19:17 +0000 Subject: macho-dump: More sketching. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120192 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/macho-dump/macho-dump.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'tools/macho-dump') diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp index 7825b11243..945406a501 100644 --- a/tools/macho-dump/macho-dump.cpp +++ b/tools/macho-dump/macho-dump.cpp @@ -11,20 +11,46 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Object/MachOObject.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; +using namespace llvm::object; static cl::opt InputFile(cl::Positional, cl::desc(""), cl::init("-")); +static cl::opt +DumpSectionData("dump-section-data", cl::desc("Dump the contents of sections"), + cl::init(false)); + int main(int argc, char **argv) { const char *ProgramName = argv[0]; llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm Mach-O dumping tool\n"); - errs() << ProgramName << ": " << "not yet implemented!" << "\n"; - return 1; + // Load the input file. + std::string ErrorStr; + OwningPtr InputBuffer( + MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorStr)); + if (!InputBuffer) { + errs() << ProgramName << ": " << "unable to read input: '" + << ErrorStr << "'\n"; + return 1; + } + + // Construct the Mach-O wrapper object. + OwningPtr InputObject( + MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); + if (!InputObject) { + errs() << ProgramName << ": " << "unable to load object: '" + << ErrorStr << "'\n"; + return 1; + } + + errs() << "ok\n"; + return 0; } -- cgit v1.2.3-18-g5258