Skip to content

Commit b66205e

Browse files
authored
Merge pull request #2192 from apple/PR-71242773
[llvm-nm][MachO] Don't call getFlags on redacted symbols
2 parents 3e3b352 + 639e67c commit b66205e

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
RUN: llvm-nm %p/Inputs/redacted-function.macho-aarch64 | FileCheck %s
2+
3+
CHECK: <redacted function 1>
4+
5+
# Generated with:
6+
# $ cat /tmp/a.c
7+
# static int i(void) {
8+
# return 0;
9+
# }
10+
#
11+
# int main(void) {
12+
# return i();
13+
# }
14+
#
15+
# $ xcrun -sdk watchos clang -arch arm64_32 /tmp/a.c -o /tmp/redacted-function.macho-aarch64
16+
# $ xcrun -sdk watchos strip -N /tmp/redacted-function.macho-aarch64

llvm/tools/llvm-nm/llvm-nm.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,20 @@ struct NMSymbol {
316316
static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
317317
bool ADefined;
318318
// Symbol flags have been checked in the caller.
319-
uint32_t AFlags = cantFail(A.Sym.getFlags());
320-
if (A.Sym.getRawDataRefImpl().p)
319+
if (A.Sym.getRawDataRefImpl().p) {
320+
uint32_t AFlags = cantFail(A.Sym.getFlags());
321321
ADefined = !(AFlags & SymbolRef::SF_Undefined);
322-
else
322+
} else {
323323
ADefined = A.TypeChar != 'U';
324+
}
324325
bool BDefined;
325326
// Symbol flags have been checked in the caller.
326-
uint32_t BFlags = cantFail(B.Sym.getFlags());
327-
if (B.Sym.getRawDataRefImpl().p)
327+
if (B.Sym.getRawDataRefImpl().p) {
328+
uint32_t BFlags = cantFail(B.Sym.getFlags());
328329
BDefined = !(BFlags & SymbolRef::SF_Undefined);
329-
else
330+
} else {
330331
BDefined = B.TypeChar != 'U';
332+
}
331333
return std::make_tuple(ADefined, A.Address, A.Name, A.Size) <
332334
std::make_tuple(BDefined, B.Address, B.Name, B.Size);
333335
}

0 commit comments

Comments
 (0)