diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -1885,6 +1885,13 @@ // Check for PLT entry registered with symbol name if (!SymbolAddress && IsAArch64) { BinaryData *BD = BC->getBinaryDataByName(SymbolName + "@PLT"); + size_t End; + if ((!BD) && ((End = SymbolName.find("@")) != std::string::npos)) { + // The symbol might contain its versioning in name + SymbolName = SymbolName.substr(0, End); + BD = BC->getBinaryDataByName(SymbolName + "@PLT"); + } + SymbolAddress = BD ? BD->getAddress() : 0; } } diff --git a/bolt/test/runtime/AArch64/plt.c b/bolt/test/runtime/AArch64/plt.c --- a/bolt/test/runtime/AArch64/plt.c +++ b/bolt/test/runtime/AArch64/plt.c @@ -1,6 +1,8 @@ // This test checks that the pointers to PLT are properly updated. +// Use bfd linker since it may add versioning string to the symbol +// names in symbtab. -// RUN: %clang %cflags %s -fuse-ld=lld \ +// RUN: %clang %cflags %s -fuse-ld=bfd \ // RUN: -o %t.exe -Wl,-q // RUN: llvm-bolt %t.exe -o %t.bolt.exe -use-old-text=0 -lite=0 // RUN: %t.bolt.exe