1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[dsymutil] Fix spurious warnings for missing symbols with thinLTO

Fix spurious warnings for missing symbols with thinLTO. The latter
appends a unique suffix to avoid collisions for exported private
symbols, resulting in dsymutil complaining it couldn't find the symbol
in the object file.

rdar://75434058

Differential revision: https://reviews.llvm.org/D99125
This commit is contained in:
Jonas Devlieghere 2021-03-22 16:33:01 -07:00
parent a2cee22477
commit e33ed822d1
7 changed files with 35 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,24 @@
$ cat foo.cpp
struct nontrivial {
nontrivial() { }
};
void function2()
{
static const nontrivial magic_static;
}
$ cat bar.cpp
void function2();
void function1()
{
function2();
}
$ xcrun clang++ -g -flto=thin -O2 foo.cpp bar.cpp -c
$ xcrun clang++ -flto=thin foo.o bar.o -Xlinker -object_path_lto -Xlinker lto -shared -o foobar.dylib
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/thinlto/foobar.dylib -o %t.dSYM 2>&1 | FileCheck %s --allow-empty
CHECK-NOT: could not find object file symbol for symbol __ZZ9function2vE12magic_static
CHECK-NOT: could not find object file symbol for symbol __ZGVZ9function2vE12magic_static

View File

@ -462,6 +462,17 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
}
}
// ThinLTO adds a unique suffix to exported private symbols.
for (auto Iter = CurrentObjectAddresses.begin();
Iter != CurrentObjectAddresses.end(); ++Iter) {
llvm::StringRef SymbolName = Iter->getKey();
auto Pos = SymbolName.rfind(".llvm.");
if (Pos != llvm::StringRef::npos && SymbolName.substr(0, Pos) == Name) {
ObjectSymIt = Iter;
break;
}
}
if (ObjectSymIt == CurrentObjectAddresses.end()) {
Warning("could not find object file symbol for symbol " + Twine(Name));
return;