[llvm] r328820 - For llvm-nm and Mach-O files that are fully stripped, special case a redacted LC_MAIN
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 29 13:04:29 PDT 2018
Author: enderby
Date: Thu Mar 29 13:04:29 2018
New Revision: 328820
URL: http://llvm.org/viewvc/llvm-project?rev=328820&view=rev
Log:
For llvm-nm and Mach-O files that are fully stripped, special case a redacted LC_MAIN
As a further refinement on:
r328274 - For llvm-nm and Mach-O files also use function starts info in some cases when printing symbols
we want to special case a redacted LC_MAIN so it is easier to find.
rdar://38978929
Added:
llvm/trunk/test/tools/llvm-nm/X86/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64 (with props)
Modified:
llvm/trunk/test/tools/llvm-nm/X86/dyldinfo.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Added: llvm/trunk/test/tools/llvm-nm/X86/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64?rev=328820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-nm/X86/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64
------------------------------------------------------------------------------
svn:executable = *
Propchange: llvm/trunk/test/tools/llvm-nm/X86/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: llvm/trunk/test/tools/llvm-nm/X86/dyldinfo.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/dyldinfo.test?rev=328820&r1=328819&r2=328820&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/X86/dyldinfo.test (original)
+++ llvm/trunk/test/tools/llvm-nm/X86/dyldinfo.test Thu Mar 29 13:04:29 2018
@@ -2,6 +2,7 @@
# RUN: llvm-nm -no-dyldinfo %p/Inputs/Strip-ST.dylib.macho-x86_64 | FileCheck --check-prefix=NO-DYLDINFO %s
# RUN: llvm-nm -dyldinfo-only %p/Inputs/Strip-ST.dylib.macho-x86_64 | FileCheck --check-prefix=DYLDINFO-ONLY %s
# RUN: llvm-nm %p/Inputs/Strip-N.hello.exe.macho-x86_64 | FileCheck --check-prefix=FUNC-STARTS %s
+# RUN: llvm-nm %p/Inputs/Strip-N.LC_MAIN.exe.macho-x86_64 | FileCheck --check-prefix=LC-MAIN %s
# DEFAULT: 0000000000000f90 T __Bob_is_slow
# DEFAULT: 0000000000001008 D __T0ims_data
@@ -24,3 +25,8 @@
# FUNC-STARTS: 0000000100000f30 T _main
# FUNC-STARTS: U _printf
# FUNC-STARTS: U dyld_stub_binder
+
+# LC-MAIN: 0000000100000f50 t <redacted LC_MAIN>
+# LC-MAIN: 0000000100000000 T __mh_execute_header
+# LC-MAIN: U _printf
+# LC-MAIN: U dyld_stub_binder
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=328820&r1=328819&r2=328820&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Mar 29 13:04:29 2018
@@ -1588,8 +1588,10 @@ dumpSymbolNamesFromObject(SymbolicFile &
}
}
- // Trying adding symbol from the function starts table.
+ // Trying adding symbol from the function starts table and LC_MAIN entry
+ // point.
SmallVector<uint64_t, 8> FoundFns;
+ int64_t lc_main_offset = -1;
for (const auto &Command : MachO->load_commands()) {
if (Command.C.cmd == MachO::LC_FUNCTION_STARTS) {
// We found a function starts segment, parse the addresses for
@@ -1598,6 +1600,10 @@ dumpSymbolNamesFromObject(SymbolicFile &
MachO->getLinkeditDataLoadCommand(Command);
MachO->ReadULEB128s(LLC.dataoff, FoundFns);
+ } else if (Command.C.cmd == MachO::LC_MAIN) {
+ MachO::entry_point_command LCmain =
+ MachO->getEntryPointCommand(Command);
+ lc_main_offset = LCmain.entryoff;
}
}
// See if these addresses are already in the symbol table.
@@ -1647,7 +1653,10 @@ dumpSymbolNamesFromObject(SymbolicFile &
F.NDesc = 0;
F.IndirectName = StringRef();
SymbolList.push_back(F);
- FOS << "<redacted function " << f << ">";
+ if (FoundFns[f] == (uint64_t)lc_main_offset)
+ FOS << "<redacted LC_MAIN>";
+ else
+ FOS << "<redacted function " << f << ">";
FOS << '\0';
FunctionStartsAdded++;
}
More information about the llvm-commits
mailing list