[dfsan] Move combineShadows to DFSanFunction in preparation for it to use a domtree.
[oota-llvm.git] / tools / macho-dump / macho-dump.cpp
index beeef5b176765a679be942e19fc4859e1724611c..760097974dbdcef0b2fb7ae10e4d05690e10dd3f 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/system_error.h"
+#include <system_error>
 using namespace llvm;
 using namespace llvm::object;
 
@@ -319,6 +319,26 @@ DumpLinkerOptionsCommand(const MachOObjectFile &Obj,
   return 0;
 }
 
+static int
+DumpVersionMin(const MachOObjectFile &Obj,
+               const MachOObjectFile::LoadCommandInfo &LCI) {
+  MachO::version_min_command VMLC = Obj.getVersionMinLoadCommand(LCI);
+  outs() << "  ('version, " << VMLC.version << ")\n"
+         << "  ('reserved, " << VMLC.reserved << ")\n";
+  return 0;
+}
+
+static int
+DumpDylibID(const MachOObjectFile &Obj,
+            const MachOObjectFile::LoadCommandInfo &LCI) {
+  MachO::dylib_command DLLC = Obj.getDylibIDLoadCommand(LCI);
+  outs() << "  ('install_name', '" << LCI.Ptr + DLLC.dylib.name << "')\n"
+         << "  ('timestamp, " << DLLC.dylib.timestamp << ")\n"
+         << "  ('cur_version, " << DLLC.dylib.current_version << ")\n"
+         << "  ('compat_version, " << DLLC.dylib.compatibility_version << ")\n";
+  return 0;
+}
+
 static int DumpLoadCommand(const MachOObjectFile &Obj,
                            MachOObjectFile::LoadCommandInfo &LCI) {
   switch (LCI.C.cmd) {
@@ -338,6 +358,11 @@ static int DumpLoadCommand(const MachOObjectFile &Obj,
     return DumpDataInCodeDataCommand(Obj, LCI);
   case MachO::LC_LINKER_OPTIONS:
     return DumpLinkerOptionsCommand(Obj, LCI);
+  case MachO::LC_VERSION_MIN_IPHONEOS:
+  case MachO::LC_VERSION_MIN_MACOSX:
+    return DumpVersionMin(Obj, LCI);
+  case MachO::LC_ID_DYLIB:
+    return DumpDylibID(Obj, LCI);
   default:
     Warning("unknown load command: " + Twine(LCI.C.cmd));
     return 0;
@@ -379,7 +404,7 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv, "llvm Mach-O dumping tool\n");
 
   ErrorOr<Binary *> BinaryOrErr = createBinary(InputFile);
-  if (error_code EC = BinaryOrErr.getError())
+  if (std::error_code EC = BinaryOrErr.getError())
     return Error("unable to read input: '" + EC.message() + "'");
   std::unique_ptr<Binary> Binary(BinaryOrErr.get());