diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/bar.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/bar.o new file mode 100644 index 0000000000000..26d795f44e1ac Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/bar.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foo.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foo.o new file mode 100644 index 0000000000000..b7dcab5c27ba5 Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foo.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foobar.dylib b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foobar.dylib new file mode 100755 index 0000000000000..75b22f3772379 Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foobar.dylib differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/0.x86_64.thinlto.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/0.x86_64.thinlto.o new file mode 100644 index 0000000000000..119b9268e539d Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/0.x86_64.thinlto.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/1.x86_64.thinlto.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/1.x86_64.thinlto.o new file mode 100644 index 0000000000000..1c207a7e8515c Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/1.x86_64.thinlto.o differ diff --git a/llvm/test/tools/dsymutil/X86/thinlto.test b/llvm/test/tools/dsymutil/X86/thinlto.test new file mode 100644 index 0000000000000..ebd4068a5c127 --- /dev/null +++ b/llvm/test/tools/dsymutil/X86/thinlto.test @@ -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 diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index fccf2f5406a9c..7d45b2f5e6239 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -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;