forked from OSchip/llvm-project
Add a (nonfunctional) -dyld_info flag to llvm-objdump.
Darwin otool implements this flag as a one-stop solution for displaying bind and rebase info. As I am working on upstreaming chained fixup support this command will be useful to write testcases. Differential Revision: https://reviews.llvm.org/D113573
This commit is contained in:
parent
de2cc2a002
commit
621e2de138
|
@ -302,6 +302,11 @@ MACH-O ONLY OPTIONS AND COMMANDS
|
||||||
|
|
||||||
Disassemble just the specified symbol's instructions.
|
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
|
.. option:: --dylibs-used
|
||||||
|
|
||||||
Display the shared libraries used for linked files.
|
Display the shared libraries used for linked files.
|
||||||
|
|
|
@ -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].
|
|
@ -81,6 +81,7 @@ bool objdump::DataInCode;
|
||||||
bool objdump::FunctionStarts;
|
bool objdump::FunctionStarts;
|
||||||
bool objdump::LinkOptHints;
|
bool objdump::LinkOptHints;
|
||||||
bool objdump::InfoPlist;
|
bool objdump::InfoPlist;
|
||||||
|
bool objdump::DyldInfo;
|
||||||
bool objdump::DylibsUsed;
|
bool objdump::DylibsUsed;
|
||||||
bool objdump::DylibId;
|
bool objdump::DylibId;
|
||||||
bool objdump::Verbose;
|
bool objdump::Verbose;
|
||||||
|
@ -111,6 +112,7 @@ void objdump::parseMachOOptions(const llvm::opt::InputArgList &InputArgs) {
|
||||||
FunctionStarts = InputArgs.hasArg(OBJDUMP_function_starts);
|
FunctionStarts = InputArgs.hasArg(OBJDUMP_function_starts);
|
||||||
LinkOptHints = InputArgs.hasArg(OBJDUMP_link_opt_hints);
|
LinkOptHints = InputArgs.hasArg(OBJDUMP_link_opt_hints);
|
||||||
InfoPlist = InputArgs.hasArg(OBJDUMP_info_plist);
|
InfoPlist = InputArgs.hasArg(OBJDUMP_info_plist);
|
||||||
|
DyldInfo = InputArgs.hasArg(OBJDUMP_dyld_info);
|
||||||
DylibsUsed = InputArgs.hasArg(OBJDUMP_dylibs_used);
|
DylibsUsed = InputArgs.hasArg(OBJDUMP_dylibs_used);
|
||||||
DylibId = InputArgs.hasArg(OBJDUMP_dylib_id);
|
DylibId = InputArgs.hasArg(OBJDUMP_dylib_id);
|
||||||
Verbose = !InputArgs.hasArg(OBJDUMP_non_verbose);
|
Verbose = !InputArgs.hasArg(OBJDUMP_non_verbose);
|
||||||
|
@ -1182,6 +1184,11 @@ static void PrintLinkOptHints(MachOObjectFile *O) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrintDyldInfo(MachOObjectFile *O) {
|
||||||
|
outs() << "dyld information:\n";
|
||||||
|
outs() << "[not yet implemented].\n";
|
||||||
|
}
|
||||||
|
|
||||||
static void PrintDylibs(MachOObjectFile *O, bool JustId) {
|
static void PrintDylibs(MachOObjectFile *O, bool JustId) {
|
||||||
unsigned Index = 0;
|
unsigned Index = 0;
|
||||||
for (const auto &Load : O->load_commands()) {
|
for (const auto &Load : O->load_commands()) {
|
||||||
|
@ -1900,8 +1907,8 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
|
||||||
// UniversalHeaders or ArchiveHeaders.
|
// UniversalHeaders or ArchiveHeaders.
|
||||||
if (Disassemble || Relocations || PrivateHeaders || ExportsTrie || Rebase ||
|
if (Disassemble || Relocations || PrivateHeaders || ExportsTrie || Rebase ||
|
||||||
Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols ||
|
Bind || SymbolTable || LazyBind || WeakBind || IndirectSymbols ||
|
||||||
DataInCode || FunctionStarts || LinkOptHints || DylibsUsed || DylibId ||
|
DataInCode || FunctionStarts || LinkOptHints || DyldInfo || DylibsUsed ||
|
||||||
Rpaths || ObjcMetaData || (!FilterSections.empty())) {
|
DylibId || Rpaths || ObjcMetaData || (!FilterSections.empty())) {
|
||||||
if (LeadingHeaders) {
|
if (LeadingHeaders) {
|
||||||
outs() << Name;
|
outs() << Name;
|
||||||
if (!ArchiveMemberName.empty())
|
if (!ArchiveMemberName.empty())
|
||||||
|
@ -1970,6 +1977,8 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
|
||||||
DumpSectionContents(FileName, MachOOF, Verbose);
|
DumpSectionContents(FileName, MachOOF, Verbose);
|
||||||
if (InfoPlist)
|
if (InfoPlist)
|
||||||
DumpInfoPlistSectionContents(FileName, MachOOF);
|
DumpInfoPlistSectionContents(FileName, MachOOF);
|
||||||
|
if (DyldInfo)
|
||||||
|
PrintDyldInfo(MachOOF);
|
||||||
if (DylibsUsed)
|
if (DylibsUsed)
|
||||||
PrintDylibs(MachOOF, false);
|
PrintDylibs(MachOOF, false);
|
||||||
if (DylibId)
|
if (DylibId)
|
||||||
|
|
|
@ -36,6 +36,7 @@ void parseMachOOptions(const llvm::opt::InputArgList &InputArgs);
|
||||||
extern bool Bind;
|
extern bool Bind;
|
||||||
extern bool DataInCode;
|
extern bool DataInCode;
|
||||||
extern std::string DisSymName;
|
extern std::string DisSymName;
|
||||||
|
extern bool DyldInfo;
|
||||||
extern bool DylibId;
|
extern bool DylibId;
|
||||||
extern bool DylibsUsed;
|
extern bool DylibsUsed;
|
||||||
extern bool ExportsTrie;
|
extern bool ExportsTrie;
|
||||||
|
|
|
@ -296,6 +296,12 @@ def info_plist : Flag<["--"], "info-plist">,
|
||||||
"Mach-O objects (requires --macho)">,
|
"Mach-O objects (requires --macho)">,
|
||||||
Group<grp_mach_o>;
|
Group<grp_mach_o>;
|
||||||
|
|
||||||
|
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<grp_mach_o>;
|
||||||
|
|
||||||
def dylibs_used : Flag<["--"], "dylibs-used">,
|
def dylibs_used : Flag<["--"], "dylibs-used">,
|
||||||
HelpText<"Print the shared libraries used for linked "
|
HelpText<"Print the shared libraries used for linked "
|
||||||
"Mach-O files (requires --macho)">,
|
"Mach-O files (requires --macho)">,
|
||||||
|
|
|
@ -47,7 +47,6 @@ def X : Flag<["-"], "X">, HelpText<"omit leading addresses or headers">;
|
||||||
// -addr_slide=arg
|
// -addr_slide=arg
|
||||||
// -function_offsets
|
// -function_offsets
|
||||||
|
|
||||||
|
|
||||||
// Obsolete and unsupported:
|
// Obsolete and unsupported:
|
||||||
def grp_obsolete : OptionGroup<"kind">,
|
def grp_obsolete : OptionGroup<"kind">,
|
||||||
HelpText<"Obsolete and unsupported flags">;
|
HelpText<"Obsolete and unsupported flags">;
|
||||||
|
|
|
@ -2760,11 +2760,11 @@ int main(int argc, char **argv) {
|
||||||
!DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST &&
|
!DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST &&
|
||||||
!Relocations && !SectionHeaders && !SectionContents && !SymbolTable &&
|
!Relocations && !SectionHeaders && !SectionContents && !SymbolTable &&
|
||||||
!DynamicSymbolTable && !UnwindInfo && !FaultMapSection &&
|
!DynamicSymbolTable && !UnwindInfo && !FaultMapSection &&
|
||||||
!(MachOOpt &&
|
!(MachOOpt && (Bind || DataInCode || DyldInfo || DylibId || DylibsUsed ||
|
||||||
(Bind || DataInCode || DylibId || DylibsUsed || ExportsTrie ||
|
ExportsTrie || FirstPrivateHeader || FunctionStarts ||
|
||||||
FirstPrivateHeader || FunctionStarts || IndirectSymbols || InfoPlist ||
|
IndirectSymbols || InfoPlist || LazyBind || LinkOptHints ||
|
||||||
LazyBind || LinkOptHints || ObjcMetaData || Rebase || Rpaths ||
|
ObjcMetaData || Rebase || Rpaths || UniversalHeaders ||
|
||||||
UniversalHeaders || WeakBind || !FilterSections.empty()))) {
|
WeakBind || !FilterSections.empty()))) {
|
||||||
T->printHelp(ToolName);
|
T->printHelp(ToolName);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue