Skip to content

[dsymutil] Fix handling of aliases to private external symbols #1970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions llvm/test/tools/dsymutil/ARM/private-extern-alias.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$ cat private_extern.c
__attribute__((visibility("hidden")))
int* foo() {
int i = 10;
volatile int* j = &i;
return j;
}

int* bar() {
return foo();
}

$ cat main.c
int* bar();
int main() {
return *bar();
}

$ cat alias_list
_foo _baz

$ xcrun --sdk iphoneos clang -g private_extern.c -c -o private_extern.o -target arm64-apple-ios14.0
$ xcrun --sdk iphoneos clang -g main.c -c -o main.o -target arm64-apple-ios14.0
$ xcrun --sdk iphoneos clang private_extern.o main.o -target arm64-apple-ios14.0 -o private_extern.out -Xlinker -alias_list -Xlinker alias_list

RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/private_extern/private_extern.out -o %t.dSYM --verbose 2>&1 | FileCheck %s
CHECK-NOT: could not find object file symbol for symbol _baz
CHECK: { sym: _foo, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000020 }
CHECK: { sym: _baz, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000000 }
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion llvm/tools/dsymutil/MachODebugMapParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ void MachODebugMapParser::loadMainBinarySymbols(
continue;
}
Section = *SectionOrErr;
if (Section == MainBinary.section_end() || Section->isText())
if ((Section == MainBinary.section_end() || Section->isText()) &&
!(SymType &
MachO::N_PEXT)) // Alias to non-external (was a private external)
continue;
uint64_t Addr = cantFail(Sym.getValue());
Expected<StringRef> NameOrErr = Sym.getName();
Expand Down