Object/llvm-objdump: allow dumping of mach-o exports trie
MachOObjectFile in lib/Object currently has no support for parsing the rebase, binding, and export information from the LC_DYLD_INFO load command in final linked mach-o images. This patch adds support for parsing the exports trie data structure. It also adds an option to llvm-objdump to dump that export info. I did the exports parsing first because it is the hardest. The information is encoded in a trie structure, but the standard ObjectFile way to inspect content is through iterators. So I needed to make an iterator that would do a non-recursive walk through the trie and maintain the concatenation of edges needed for the current string prefix. I plan to add similar support in MachOObjectFile and llvm-objdump to parse/display the rebasing and binding info too. llvm-svn: 216808
This commit is contained in:
@@ -84,6 +84,9 @@ SectionContents("s", cl::desc("Display the content of each section"));
|
||||
static cl::opt<bool>
|
||||
SymbolTable("t", cl::desc("Display the symbol table"));
|
||||
|
||||
static cl::opt<bool>
|
||||
ExportsTrie("exports-trie", cl::desc("Display mach-o exported symbols"));
|
||||
|
||||
static cl::opt<bool>
|
||||
MachOOpt("macho", cl::desc("Use MachO specific object file parser"));
|
||||
static cl::alias
|
||||
@@ -829,6 +832,17 @@ static void PrintUnwindInfo(const ObjectFile *o) {
|
||||
}
|
||||
}
|
||||
|
||||
static void printExportsTrie(const ObjectFile *o) {
|
||||
outs() << "Exports trie:\n";
|
||||
if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
|
||||
printMachOExportsTrie(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()) {
|
||||
printELFFileHeader(o);
|
||||
@@ -858,6 +872,8 @@ static void DumpObject(const ObjectFile *o) {
|
||||
PrintUnwindInfo(o);
|
||||
if (PrivateHeaders)
|
||||
printPrivateFileHeader(o);
|
||||
if (ExportsTrie)
|
||||
printExportsTrie(o);
|
||||
}
|
||||
|
||||
/// @brief Dump each object file in \a a;
|
||||
@@ -939,7 +955,8 @@ int main(int argc, char **argv) {
|
||||
&& !SectionContents
|
||||
&& !SymbolTable
|
||||
&& !UnwindInfo
|
||||
&& !PrivateHeaders) {
|
||||
&& !PrivateHeaders
|
||||
&& !ExportsTrie) {
|
||||
cl::PrintHelpMessage();
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user