#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;
// Dump the symbol table.
outs() << " ('_symbols', [\n";
unsigned SymNum = 0;
- for (symbol_iterator I = Obj.symbol_begin(), E = Obj.symbol_end(); I != E;
- ++I, ++SymNum) {
- DataRefImpl DRI = I->getRawDataRefImpl();
+ for (const SymbolRef &Symbol : Obj.symbols()) {
+ DataRefImpl DRI = Symbol.getRawDataRefImpl();
if (Obj.is64Bit()) {
MachO::nlist_64 STE = Obj.getSymbol64TableEntry(DRI);
DumpSymbolTableEntryData(Obj, SymNum, STE.n_strx, STE.n_type,
STE.n_sect, STE.n_desc, STE.n_value,
StringTable);
}
+ SymNum++;
}
outs() << " ])\n";
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) {
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;
cl::ParseCommandLineOptions(argc, argv, "llvm Mach-O dumping tool\n");
- ErrorOr<Binary *> BinaryOrErr = createBinary(InputFile);
- if (error_code EC = BinaryOrErr.getError())
+ ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(InputFile);
+ if (std::error_code EC = BinaryOrErr.getError())
return Error("unable to read input: '" + EC.message() + "'");
- std::unique_ptr<Binary> Binary(BinaryOrErr.get());
+ std::unique_ptr<Binary> Binary = std::move((BinaryOrErr.get()));
const MachOObjectFile *InputObject = dyn_cast<MachOObjectFile>(Binary.get());
if (!InputObject)