diff --git a/llvm/docs/CommandGuide/llvm-objdump.rst b/llvm/docs/CommandGuide/llvm-objdump.rst --- a/llvm/docs/CommandGuide/llvm-objdump.rst +++ b/llvm/docs/CommandGuide/llvm-objdump.rst @@ -302,6 +302,11 @@ Disassemble just the specified symbol's instructions. +.. option:: --dyld_info + + Print bind and rebase information used by dyld to resolve external + references in a final linked binary. + .. option:: --dylibs-used Display the shared libraries used for linked files. diff --git a/llvm/test/tools/llvm-objdump/MachO/dyld_info.test b/llvm/test/tools/llvm-objdump/MachO/dyld_info.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/MachO/dyld_info.test @@ -0,0 +1,7 @@ +RUN: llvm-objdump --macho --dyld_info %p/Inputs/bind.macho-x86_64 \ +RUN: | FileCheck %s --match-full-lines --strict-whitespace \ +RUN: --implicit-check-not={{.}} + +CHECK:{{.*}}bind.macho-x86_64: +CHECK-NEXT:dyld information: +CHECK-NEXT:[not yet implemented]. diff --git a/llvm/tools/llvm-objdump/MachODump.h b/llvm/tools/llvm-objdump/MachODump.h --- a/llvm/tools/llvm-objdump/MachODump.h +++ b/llvm/tools/llvm-objdump/MachODump.h @@ -36,6 +36,7 @@ extern bool Bind; extern bool DataInCode; extern std::string DisSymName; +extern bool DyldInfo; extern bool DylibId; extern bool DylibsUsed; extern bool ExportsTrie; diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -81,6 +81,7 @@ bool objdump::FunctionStarts; bool objdump::LinkOptHints; bool objdump::InfoPlist; +bool objdump::DyldInfo; bool objdump::DylibsUsed; bool objdump::DylibId; bool objdump::Verbose; @@ -111,6 +112,7 @@ FunctionStarts = InputArgs.hasArg(OBJDUMP_function_starts); LinkOptHints = InputArgs.hasArg(OBJDUMP_link_opt_hints); InfoPlist = InputArgs.hasArg(OBJDUMP_info_plist); + DyldInfo = InputArgs.hasArg(OBJDUMP_dyld_info); DylibsUsed = InputArgs.hasArg(OBJDUMP_dylibs_used); DylibId = InputArgs.hasArg(OBJDUMP_dylib_id); Verbose = !InputArgs.hasArg(OBJDUMP_non_verbose); @@ -1182,6 +1184,11 @@ } } +static void PrintDyldInfo(MachOObjectFile *O) { + outs() << "dyld information:\n"; + outs() << "[not yet implemented].\n"; +} + static void PrintDylibs(MachOObjectFile *O, bool JustId) { unsigned Index = 0; for (const auto &Load : O->load_commands()) { @@ -1900,8 +1907,8 @@ // UniversalHeaders or ArchiveHeaders. if (Disassemble || Relocations || PrivateHeaders || ExportsTrie || Rebase || Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols || - DataInCode || FunctionStarts || LinkOptHints || DylibsUsed || DylibId || - Rpaths || ObjcMetaData || (!FilterSections.empty())) { + DataInCode || FunctionStarts || LinkOptHints || DyldInfo || DylibsUsed || + DylibId || Rpaths || ObjcMetaData || (!FilterSections.empty())) { if (LeadingHeaders) { outs() << Name; if (!ArchiveMemberName.empty()) @@ -1970,6 +1977,8 @@ DumpSectionContents(FileName, MachOOF, Verbose); if (InfoPlist) DumpInfoPlistSectionContents(FileName, MachOOF); + if (DyldInfo) + PrintDyldInfo(MachOOF); if (DylibsUsed) PrintDylibs(MachOOF, false); if (DylibId) diff --git a/llvm/tools/llvm-objdump/ObjdumpOpts.td b/llvm/tools/llvm-objdump/ObjdumpOpts.td --- a/llvm/tools/llvm-objdump/ObjdumpOpts.td +++ b/llvm/tools/llvm-objdump/ObjdumpOpts.td @@ -296,6 +296,12 @@ "Mach-O objects (requires --macho)">, Group; +def dyld_info : Flag<["--"], "dyld_info">, + HelpText<"Print bind and rebase information used by dyld to resolve " + "external references in a final linked binary " + "(requires --macho)">, + Group; + def dylibs_used : Flag<["--"], "dylibs-used">, HelpText<"Print the shared libraries used for linked " "Mach-O files (requires --macho)">, diff --git a/llvm/tools/llvm-objdump/OtoolOpts.td b/llvm/tools/llvm-objdump/OtoolOpts.td --- a/llvm/tools/llvm-objdump/OtoolOpts.td +++ b/llvm/tools/llvm-objdump/OtoolOpts.td @@ -47,7 +47,6 @@ // -addr_slide=arg // -function_offsets - // Obsolete and unsupported: def grp_obsolete : OptionGroup<"kind">, HelpText<"Obsolete and unsupported flags">; diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2760,11 +2760,11 @@ !DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST && !Relocations && !SectionHeaders && !SectionContents && !SymbolTable && !DynamicSymbolTable && !UnwindInfo && !FaultMapSection && - !(MachOOpt && - (Bind || DataInCode || DylibId || DylibsUsed || ExportsTrie || - FirstPrivateHeader || FunctionStarts || IndirectSymbols || InfoPlist || - LazyBind || LinkOptHints || ObjcMetaData || Rebase || Rpaths || - UniversalHeaders || WeakBind || !FilterSections.empty()))) { + !(MachOOpt && (Bind || DataInCode || DyldInfo || DylibId || DylibsUsed || + ExportsTrie || FirstPrivateHeader || FunctionStarts || + IndirectSymbols || InfoPlist || LazyBind || LinkOptHints || + ObjcMetaData || Rebase || Rpaths || UniversalHeaders || + WeakBind || !FilterSections.empty()))) { T->printHelp(ToolName); return 2; }