aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/MachODump.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2017-06-19 19:38:22 +0000
committerKevin Enderby <enderby@apple.com>2017-06-19 19:38:22 +0000
commitdf0d6dabb24d05cd51fe5560ac34d69abe6157b6 (patch)
treead3c0adbdc3b223344f3841c054636b50d1b0da3 /llvm/tools/llvm-objdump/MachODump.cpp
parent42175cb0d7c8f329ee184cfa41c0b34ae3447608 (diff)
downloadllvm-df0d6dabb24d05cd51fe5560ac34d69abe6157b6.zip
llvm-df0d6dabb24d05cd51fe5560ac34d69abe6157b6.tar.gz
llvm-df0d6dabb24d05cd51fe5560ac34d69abe6157b6.tar.bz2
Change llvm-nm for Mach-O files to use dyld info in some cases when printing symbols.
In order to reduce swift binary sizes, Apple is now stripping swift symbols from the nlist symbol table. llvm-nm currently only looks at the nlist symbol table and misses symbols that are present in dyld info. This makes it hard to know the set of symbols for a binary using just llvm-nm. Unless you know to run llvm-objdump -exports-trie that can output the exported symbols in the dyld info from the export trie, which does so but in a different format. Also moving forward the time may come a when a fully linked Mach-O file that uses dyld will no longer have an nlist symbol table to avoid duplicating the symbol information. This change adds three flags to llvm-nm, -add-dyldinfo, -no-dyldinfo, and -dyldinfo-only. The first, -add-dyldinfo, has the same effect as when the new bit in the Mach-O header, MH_NLIST_OUTOFSYNC_WITH_DYLDINFO, appears in a binary. In that it looks through the dyld info from the export trie and adds symbols to be printed that are not already in its internal SymbolList variable. The -no-dyldinfo option turns this behavior off. The -dyldinfo-only option only looks at the dyld information and recreates the symbol table from the dyld info from the export trie and binding information. As if it the Mach-O file had no nlist symbol table. Also fixed a few bugs with Mach-O N_INDR symbols not correctly printing the indirect name, or in the same format as the old nm-classic program. rdar://32021551 llvm-svn: 305733
Diffstat (limited to 'llvm/tools/llvm-objdump/MachODump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 8927f57..40b5e25 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -7634,6 +7634,10 @@ static void PrintMachHeader(uint32_t magic, uint32_t cputype,
outs() << " APP_EXTENSION_SAFE";
f &= ~MachO::MH_APP_EXTENSION_SAFE;
}
+ if (f & MachO::MH_NLIST_OUTOFSYNC_WITH_DYLDINFO) {
+ outs() << " NLIST_OUTOFSYNC_WITH_DYLDINFO";
+ f &= ~MachO::MH_NLIST_OUTOFSYNC_WITH_DYLDINFO;
+ }
if (f != 0 || flags == 0)
outs() << format(" 0x%08" PRIx32, f);
} else {