[llvm-nm][MachO] Don't call getFlags on redacted symbols
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Sat, 5 Dec 2020 04:10:06 +0000 (20:10 -0800)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Sat, 5 Dec 2020 05:48:53 +0000 (21:48 -0800)
commit3d381a710220100722465ead9c64874621edead4
tree84b8b8f3fc5439e9fc70845444584ce0c40fd13c
parent2dc4a14e4d5fee5acb2ae43866ce03c028509257
[llvm-nm][MachO] Don't call getFlags on redacted symbols

Avoid calling getFlags on a non-existent symbol.

The way this is triggered is by calling strip -N on a binary, which sets
the MH_NLIST_OUTOFSYNC_WITH_DYLDINFO header flag. Then, in the
LC_FUNCTION_STARTS command, nm is trying to print the stripped symbols
and needs the proper checks.
llvm/test/tools/llvm-nm/AArch64/Inputs/redacted-function.macho-aarch64 [new file with mode: 0755]
llvm/test/tools/llvm-nm/AArch64/macho-redacted-function.test [new file with mode: 0644]
llvm/tools/llvm-nm/llvm-nm.cpp