[PATCH] D83669: [PowerPC] Support for R_PPC64_REL24_NOTOC calls where the caller has no TOC and the callee is not DSO local

Victor Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 08:44:54 PDT 2020


NeHuang marked 6 inline comments as done.
NeHuang added inline comments.


================
Comment at: lld/ELF/Thunks.cpp:1008
+  if (type == R_PPC64_REL24_NOTOC && s.isInPlt())
+    return make<PPC64R12SetupStub>(s);
+
----------------
sfertile wrote:
> I'll need to check what instruction we are using in the R12SetupStub, I see the comment says `pld` right now, but where is it loading from?
> `destination.getVA() - getThunkTargetSym()->getVA()` is the offset from the program counter to the (non-premptable) definition so I'm guessing its meant to be a paddi instead. Either way, that offset calculation is wrong for a symbol in the plt.  Instead we  want to load the address of the function from the plt.
Thanks Sean. 
- Updated the patch to load the address of function from the plt. 
- The offset is computed by `destination.getGotPltVA() - getThunkTargetSym()->getVA();` instead. 


================
Comment at: lld/test/ELF/ppc64-pcrel-call-to-extern.s:47
+# CHECK-LABEL: __global_entry_point_setup_callee_global_stother0
+# CHECK:       pld 12
+# CHECK-NEXT:  mtctr 12
----------------
sfertile wrote:
> Whats the offset that gets encoded into the instruction?  What offset are you expecting?
- The offset computed is from the program counter to the plt entry address storing the address of the callee function. 
- Updated the test case to check if the offset properly computed.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83669





More information about the llvm-commits mailing list