diff options
Diffstat (limited to 'llvm/tools/llvm-objdump/MachODump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index ac4de27..aa71998 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -16,7 +16,6 @@ #include "llvm-c/Disassembler.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" #include "llvm/BinaryFormat/MachO.h" #include "llvm/Config/config.h" @@ -178,11 +177,7 @@ static cl::list<std::string> ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), cl::ZeroOrMore, cl::cat(MachOCat)); -namespace llvm { - -extern StringSet<> FoundSectionSet; - -bool ArchAll = false; +static bool ArchAll = false; static std::string ThumbTripleName; @@ -224,6 +219,7 @@ static const Target *GetTarget(const MachOObjectFile *MachOObj, return nullptr; } +namespace { struct SymbolSorter { bool operator()(const SymbolRef &A, const SymbolRef &B) { Expected<SymbolRef::Type> ATypeOrErr = A.getType(); @@ -239,6 +235,7 @@ struct SymbolSorter { return AAddr < BAddr; } }; +} // namespace // Types for the storted data in code table that is built before disassembly // and the predicate function to sort them. @@ -488,9 +485,9 @@ static void printRelocationTargetName(const MachOObjectFile *O, Fmt << S; } -Error getMachORelocationValueString(const MachOObjectFile *Obj, - const RelocationRef &RelRef, - SmallVectorImpl<char> &Result) { +Error objdump::getMachORelocationValueString(const MachOObjectFile *Obj, + const RelocationRef &RelRef, + SmallVectorImpl<char> &Result) { DataRefImpl Rel = RelRef.getRawDataRefImpl(); MachO::any_relocation_info RE = Obj->getRelocation(Rel); @@ -2313,7 +2310,7 @@ static bool ValidateArchFlags() { // -arch flags selecting just those slices as specified by them and also parses // archive files. Then for each individual Mach-O file ProcessMachO() is // called to process the file based on the command line options. -void parseInputMachO(StringRef Filename) { +void objdump::parseInputMachO(StringRef Filename) { if (!ValidateArchFlags()) return; @@ -2371,7 +2368,7 @@ void parseInputMachO(StringRef Filename) { llvm_unreachable("Input object can't be invalid at this point"); } -void parseInputMachO(MachOUniversalBinary *UB) { +void objdump::parseInputMachO(MachOUniversalBinary *UB) { if (!ValidateArchFlags()) return; @@ -2557,6 +2554,7 @@ void parseInputMachO(MachOUniversalBinary *UB) { } } +namespace { // The block of info used by the Symbolizer call backs. struct DisassembleInfo { DisassembleInfo(MachOObjectFile *O, SymbolAddressMap *AddrMap, @@ -2576,6 +2574,7 @@ struct DisassembleInfo { std::unique_ptr<SymbolAddressMap> bindtable; uint32_t depth = 0; }; +} // namespace // SymbolizerGetOpInfo() is the operand information call back function. // This is called to get the symbolic information for operand(s) of an @@ -3384,6 +3383,8 @@ static const char *get_symbol_32(uint32_t sect_offset, SectionRef S, return get_symbol_64(sect_offset, S, info, n_value64, ReferenceValue); } +namespace { + // These are structs in the Objective-C meta data and read to produce the // comments for disassembly. While these are part of the ABI they are no // public defintions. So the are here not in include/llvm/BinaryFormat/MachO.h @@ -3969,6 +3970,8 @@ inline void swapStruct(struct objc_method_description_t &md) { sys::swapByteOrder(md.types); } +} // namespace + static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue, struct DisassembleInfo *info); @@ -6468,7 +6471,7 @@ static void DumpProtocolSection(MachOObjectFile *O, const char *sect, } #ifdef HAVE_LIBXAR -inline void swapStruct(struct xar_header &xar) { +static inline void swapStruct(struct xar_header &xar) { sys::swapByteOrder(xar.magic); sys::swapByteOrder(xar.size); sys::swapByteOrder(xar.version); @@ -8189,7 +8192,7 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj, } } -void printMachOUnwindInfo(const MachOObjectFile *Obj) { +void objdump::printMachOUnwindInfo(const MachOObjectFile *Obj) { std::map<uint64_t, SymbolRef> Symbols; for (const SymbolRef &SymRef : Obj->symbols()) { // Discard any undefined or absolute symbols. They're not going to take part @@ -10197,12 +10200,12 @@ static void PrintMachHeader(const MachOObjectFile *Obj, bool verbose) { } } -void printMachOFileHeader(const object::ObjectFile *Obj) { +void objdump::printMachOFileHeader(const object::ObjectFile *Obj) { const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj); PrintMachHeader(file, !NonVerbose); } -void printMachOLoadCommands(const object::ObjectFile *Obj) { +void objdump::printMachOLoadCommands(const object::ObjectFile *Obj) { const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj); uint32_t filetype = 0; uint32_t cputype = 0; @@ -10224,7 +10227,7 @@ void printMachOLoadCommands(const object::ObjectFile *Obj) { // export trie dumping //===----------------------------------------------------------------------===// -void printMachOExportsTrie(const object::MachOObjectFile *Obj) { +static void printMachOExportsTrie(const object::MachOObjectFile *Obj) { uint64_t BaseSegmentAddress = 0; for (const auto &Command : Obj->load_commands()) { if (Command.C.cmd == MachO::LC_SEGMENT) { @@ -10303,7 +10306,7 @@ void printMachOExportsTrie(const object::MachOObjectFile *Obj) { // rebase table dumping //===----------------------------------------------------------------------===// -void printMachORebaseTable(object::MachOObjectFile *Obj) { +static void printMachORebaseTable(object::MachOObjectFile *Obj) { outs() << "segment section address type\n"; Error Err = Error::success(); for (const object::MachORebaseEntry &Entry : Obj->rebaseTable(Err)) { @@ -10345,7 +10348,7 @@ static StringRef ordinalName(const object::MachOObjectFile *Obj, int Ordinal) { // bind table dumping //===----------------------------------------------------------------------===// -void printMachOBindTable(object::MachOObjectFile *Obj) { +static void printMachOBindTable(object::MachOObjectFile *Obj) { // Build table of sections so names can used in final output. outs() << "segment section address type " "addend dylib symbol\n"; @@ -10376,7 +10379,7 @@ void printMachOBindTable(object::MachOObjectFile *Obj) { // lazy bind table dumping //===----------------------------------------------------------------------===// -void printMachOLazyBindTable(object::MachOObjectFile *Obj) { +static void printMachOLazyBindTable(object::MachOObjectFile *Obj) { outs() << "segment section address " "dylib symbol\n"; Error Err = Error::success(); @@ -10401,7 +10404,7 @@ void printMachOLazyBindTable(object::MachOObjectFile *Obj) { // weak bind table dumping //===----------------------------------------------------------------------===// -void printMachOWeakBindTable(object::MachOObjectFile *Obj) { +static void printMachOWeakBindTable(object::MachOObjectFile *Obj) { outs() << "segment section address " "type addend symbol\n"; Error Err = Error::success(); @@ -10451,7 +10454,7 @@ static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue, return !name.empty() ? name.data() : nullptr; } -void printLazyBindTable(ObjectFile *o) { +void objdump::printLazyBindTable(ObjectFile *o) { outs() << "Lazy bind table:\n"; if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o)) printMachOLazyBindTable(MachO); @@ -10461,7 +10464,7 @@ void printLazyBindTable(ObjectFile *o) { "for Mach-O executable files.\n"; } -void printWeakBindTable(ObjectFile *o) { +void objdump::printWeakBindTable(ObjectFile *o) { outs() << "Weak bind table:\n"; if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o)) printMachOWeakBindTable(MachO); @@ -10471,7 +10474,7 @@ void printWeakBindTable(ObjectFile *o) { "for Mach-O executable files.\n"; } -void printExportsTrie(const ObjectFile *o) { +void objdump::printExportsTrie(const ObjectFile *o) { outs() << "Exports trie:\n"; if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o)) printMachOExportsTrie(MachO); @@ -10481,7 +10484,7 @@ void printExportsTrie(const ObjectFile *o) { "for Mach-O executable files.\n"; } -void printRebaseTable(ObjectFile *o) { +void objdump::printRebaseTable(ObjectFile *o) { outs() << "Rebase table:\n"; if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o)) printMachORebaseTable(MachO); @@ -10491,7 +10494,7 @@ void printRebaseTable(ObjectFile *o) { "for Mach-O executable files.\n"; } -void printBindTable(ObjectFile *o) { +void objdump::printBindTable(ObjectFile *o) { outs() << "Bind table:\n"; if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o)) printMachOBindTable(MachO); @@ -10500,4 +10503,3 @@ void printBindTable(ObjectFile *o) { << "This operation is only currently supported " "for Mach-O executable files.\n"; } -} // namespace llvm |