summaryrefslogtreecommitdiff
path: root/tools/macho-dump
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-11-27 06:19:17 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-11-27 06:19:17 +0000
commitad1252498d37fdf32c92569fe35bf09bb6e78caa (patch)
tree8e913a5f310776b6a9b9999fb0d9552a3339a43f /tools/macho-dump
parent75373ac0c3cd299cfb45514d5bc0bc0761233fdd (diff)
macho-dump: More sketching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/macho-dump')
-rw-r--r--tools/macho-dump/macho-dump.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp
index 7825b112438..945406a5019 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<std::string>
InputFile(cl::Positional, cl::desc("<input file>"), cl::init("-"));
+static cl::opt<bool>
+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<MemoryBuffer> InputBuffer(
+ MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorStr));
+ if (!InputBuffer) {
+ errs() << ProgramName << ": " << "unable to read input: '"
+ << ErrorStr << "'\n";
+ return 1;
+ }
+
+ // Construct the Mach-O wrapper object.
+ OwningPtr<MachOObject> InputObject(
+ MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr));
+ if (!InputObject) {
+ errs() << ProgramName << ": " << "unable to load object: '"
+ << ErrorStr << "'\n";
+ return 1;
+ }
+
+ errs() << "ok\n";
+ return 0;
}