[PATCH] D122039: [BOLT] Fix plt relocations symbol match

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 12:23:53 PDT 2022


yota9 added inline comments.


================
Comment at: bolt/lib/Rewrite/RewriteInstance.cpp:1886-1897
     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 e.g.
+        // memcpy@@GLIBC_2.17
+        SymbolName = SymbolName.substr(0, End);
----------------
maksfb wrote:
> Could you please factor out the code above? Why is it AArch64-specific?
Sorry you want me to remove IsAArch64 check? I didn't check it on X86. AFAIU there is no need for x86 to have this code since this is used for aarch64 because there are instruction pairs like adrp + add, which give us the final symbol value in pair, but the X86 may use extracted value for single instruction


================
Comment at: bolt/test/runtime/plt_gnu_ld.test:10
+// RUN: llvm-bolt %t.bfd.exe -o %t.bfd.bolt.exe -use-old-text=0 -lite=0
+// RUN: %t.bfd.bolt.exe
----------------
maksfb wrote:
> Hi @yota9, could you please make the checks for properly updated PLT explicit instead of relying on executing the binary?
I will try t


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122039/new/

https://reviews.llvm.org/D122039



More information about the llvm-commits mailing list