From: Jonas Devlieghere Date: Thu, 15 Oct 2020 03:10:55 +0000 (-0700) Subject: [dsymutil] Fix handling of aliases to private external symbols X-Git-Tag: llvmorg-13-init~9227 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9fb9da36c34d2745b74dc30e6c26f7d3f48466c;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/test/tools/dsymutil/ARM/private-extern-alias.test b/llvm/test/tools/dsymutil/ARM/private-extern-alias.test new file mode 100644 index 0000000..99301fe --- /dev/null +++ b/llvm/test/tools/dsymutil/ARM/private-extern-alias.test @@ -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 } diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/main.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/main.o new file mode 100644 index 0000000..d9cf74e Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/main.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.o new file mode 100644 index 0000000..b7f1a6a Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.out b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.out new file mode 100755 index 0000000..fff5df1 Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/private_extern/private_extern.out differ diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index 617b708..3323a05 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -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 NameOrErr = Sym.getName();