diff options
author | Stephen Hines <srhines@google.com> | 2014-04-23 16:57:46 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-04-24 15:53:16 -0700 |
commit | 36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch) | |
tree | e6cfb69fbbd937f450eeb83bfb83b9da3b01275a /tools/macho-dump | |
parent | 69a8640022b04415ae9fac62f8ab090601d8f889 (diff) | |
download | external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2 |
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'tools/macho-dump')
-rw-r--r-- | tools/macho-dump/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tools/macho-dump/macho-dump.cpp | 28 |
2 files changed, 24 insertions, 9 deletions
diff --git a/tools/macho-dump/CMakeLists.txt b/tools/macho-dump/CMakeLists.txt index d55e1d5..bc2dfbf 100644 --- a/tools/macho-dump/CMakeLists.txt +++ b/tools/macho-dump/CMakeLists.txt @@ -1,4 +1,7 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support object) +set(LLVM_LINK_COMPONENTS + Object + Support + ) add_llvm_tool(macho-dump macho-dump.cpp diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp index 0dfbd5f..886487b 100644 --- a/tools/macho-dump/macho-dump.cpp +++ b/tools/macho-dump/macho-dump.cpp @@ -96,9 +96,9 @@ static int DumpSectionData(const MachOObjectFile &Obj, unsigned Index, // Dump the relocation entries. outs() << " ('_relocations', [\n"; unsigned RelNum = 0; - error_code EC; for (relocation_iterator I = Obj.section_rel_begin(Index), - E = Obj.section_rel_end(Index); I != E; I.increment(EC), ++RelNum) { + E = Obj.section_rel_end(Index); + I != E; ++I, ++RelNum) { MachO::any_relocation_info RE = Obj.getRelocation(I->getRawDataRefImpl()); outs() << " # Relocation " << RelNum << "\n"; outs() << " (('word-0', " << format("0x%x", RE.r_word0) << "),\n"; @@ -201,11 +201,9 @@ static int DumpSymtabCommand(const MachOObjectFile &Obj) { // Dump the symbol table. outs() << " ('_symbols', [\n"; - error_code EC; unsigned SymNum = 0; - for (symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E; - I.increment(EC), ++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, @@ -217,6 +215,7 @@ static int DumpSymtabCommand(const MachOObjectFile &Obj) { STE.n_sect, STE.n_desc, STE.n_value, StringTable); } + SymNum++; } outs() << " ])\n"; @@ -320,6 +319,15 @@ 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 DumpLoadCommand(const MachOObjectFile &Obj, MachOObjectFile::LoadCommandInfo &LCI) { switch (LCI.C.cmd) { @@ -339,6 +347,9 @@ 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); default: Warning("unknown load command: " + Twine(LCI.C.cmd)); return 0; @@ -379,9 +390,10 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm Mach-O dumping tool\n"); - OwningPtr<Binary> Binary; - if (error_code EC = createBinary(InputFile, Binary)) + ErrorOr<Binary *> BinaryOrErr = createBinary(InputFile); + if (error_code EC = BinaryOrErr.getError()) return Error("unable to read input: '" + EC.message() + "'"); + std::unique_ptr<Binary> Binary(BinaryOrErr.get()); const MachOObjectFile *InputObject = dyn_cast<MachOObjectFile>(Binary.get()); if (!InputObject) |