# 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
# 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
}
}
- // 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
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.
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++;
}