From 56ebef45efe4807fba24d61f97eface88a6e2b46 Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Tue, 16 Sep 2014 01:41:51 +0000 Subject: [llvm-objdump] for mach-o add -bind, -lazy-bind, and -weak-bind options This finishes the ability of llvm-objdump to print out all information from the LC_DYLD_INFO load command. The -bind option prints out symbolic references that dyld must resolve immediately. The -lazy-bind option prints out symbolc reference that are lazily resolved on first use. The -weak-bind option prints out information about symbols which dyld must try to coalesce across images. llvm-svn: 217853 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 52 +++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp') diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 790d08a1fc2..12cf1f72b09 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -84,6 +84,15 @@ ExportsTrie("exports-trie", cl::desc("Display mach-o exported symbols")); static cl::opt Rebase("rebase", cl::desc("Display mach-o rebasing info")); +static cl::opt +Bind("bind", cl::desc("Display mach-o binding info")); + +static cl::opt +LazyBind("lazy-bind", cl::desc("Display mach-o lazy binding info")); + +static cl::opt +WeakBind("weak-bind", cl::desc("Display mach-o weak binding info")); + static cl::opt MachOOpt("macho", cl::desc("Use MachO specific object file parser")); static cl::alias @@ -736,6 +745,38 @@ static void printRebaseTable(const ObjectFile *o) { } } +static void printBindTable(const ObjectFile *o) { + outs() << "Bind table:\n"; + if (const MachOObjectFile *MachO = dyn_cast(o)) + printMachOBindTable(MachO); + else { + errs() << "This operation is only currently supported " + "for Mach-O executable files.\n"; + return; + } +} + +static void printLazyBindTable(const ObjectFile *o) { + outs() << "Lazy bind table:\n"; + if (const MachOObjectFile *MachO = dyn_cast(o)) + printMachOLazyBindTable(MachO); + else { + errs() << "This operation is only currently supported " + "for Mach-O executable files.\n"; + return; + } +} + +static void printWeakBindTable(const ObjectFile *o) { + outs() << "Weak bind table:\n"; + if (const MachOObjectFile *MachO = dyn_cast(o)) + printMachOWeakBindTable(MachO); + else { + errs() << "This operation is only currently supported " + "for Mach-O executable files.\n"; + return; + } +} static void printPrivateFileHeader(const ObjectFile *o) { if (o->isELF()) { @@ -770,6 +811,12 @@ static void DumpObject(const ObjectFile *o) { printExportsTrie(o); if (Rebase) printRebaseTable(o); + if (Bind) + printBindTable(o); + if (LazyBind) + printLazyBindTable(o); + if (WeakBind) + printWeakBindTable(o); } /// @brief Dump each object file in \a a; @@ -853,7 +900,10 @@ int main(int argc, char **argv) { && !UnwindInfo && !PrivateHeaders && !ExportsTrie - && !Rebase) { + && !Rebase + && !Bind + && !LazyBind + && !WeakBind) { cl::PrintHelpMessage(); return 2; } -- cgit v1.2.3