Skip to content

Commit 8a243da

Browse files
committed
[dsymutil] Fix handling of aliases to private external symbols
dsymutil was incorrectly ignoring aliases to private extern symbols in the MachODebugMapParser. This resulted in spurious warnings about not being able to find symbols. rdar://49652389 Differential revision: https://reviews.llvm.org/D89444 (cherry picked from commit f9fb9da)
1 parent 2d0b083 commit 8a243da

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
$ cat private_extern.c
2+
__attribute__((visibility("hidden")))
3+
int* foo() {
4+
int i = 10;
5+
volatile int* j = &i;
6+
return j;
7+
}
8+
9+
int* bar() {
10+
return foo();
11+
}
12+
13+
$ cat main.c
14+
int* bar();
15+
int main() {
16+
return *bar();
17+
}
18+
19+
$ cat alias_list
20+
_foo _baz
21+
22+
$ xcrun --sdk iphoneos clang -g private_extern.c -c -o private_extern.o -target arm64-apple-ios14.0
23+
$ xcrun --sdk iphoneos clang -g main.c -c -o main.o -target arm64-apple-ios14.0
24+
$ xcrun --sdk iphoneos clang private_extern.o main.o -target arm64-apple-ios14.0 -o private_extern.out -Xlinker -alias_list -Xlinker alias_list
25+
26+
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/private_extern/private_extern.out -o %t.dSYM --verbose 2>&1 | FileCheck %s
27+
CHECK-NOT: could not find object file symbol for symbol _baz
28+
CHECK: { sym: _foo, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000020 }
29+
CHECK: { sym: _baz, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000000 }
Binary file not shown.
Binary file not shown.
Binary file not shown.

llvm/tools/dsymutil/MachODebugMapParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ void MachODebugMapParser::loadMainBinarySymbols(
562562
continue;
563563
}
564564
Section = *SectionOrErr;
565-
if (Section == MainBinary.section_end() || Section->isText())
565+
if ((Section == MainBinary.section_end() || Section->isText()) &&
566+
!(SymType &
567+
MachO::N_PEXT)) // Alias to non-external (was a private external)
566568
continue;
567569
uint64_t Addr = cantFail(Sym.getValue());
568570
Expected<StringRef> NameOrErr = Sym.getName();

0 commit comments

Comments
 (0)