[PATCH] D87318: [LLD][PowerPC] Add support for R_PPC64_GOT_TLSGD_PCREL34 used in TLS General Dynamic

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 11:50:50 PDT 2020


stefanp created this revision.
stefanp added reviewers: nemanjai, NeHuang, sfertile, MaskRay, hfinkel.
Herald added subscribers: shchenz, kbarton, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
stefanp requested review of this revision.

Add Thread Local Storage support for the 34 bit relocation R_PPC64_GOT_TLSGD_PCREL34 used in General Dynamic.

The compiler will produce code that looks like:

  pla r3, x at got@tlsgd at pcrel            R_PPC64_GOT_TLSGD34
  bl __tls_get_addr at notoc(x at tlsgd)     R_PPC64_TLSGD
                                       R_PPC64_REL24_NOTOC

LLD should be able to correctly compute the relocation for  R_PPC64_GOT_TLSGD34 as well as do the following two relaxations where possible:
General Dynamic to Local Exec:

  paddi r3, r13, x at tprel
  nop

and General Dynamic to Initial Exec:

  pld r3, x at got@tprel at pcrel
  add r3, r3, r13

Note:
This patch adds support for the PC Relative (no TOC) version of General Dynamic on top of the existing support for the TOC version of General Dynamic.
The ABI does not provide any way to tell by looking only at the relocation `R_PPC64_TLSGD` when it is being used in a TOC instruction sequence or and when it is being used in a no TOC sequence. The TOC sequence should always be 4 byte aligned. This patch adds one to the offset of the relocation when it is being used in a no TOC sequence. In this way LLD can tell by looking at the alignment of the offset of `R_PPC64_TLSGD` whether or not it is being used as part of a TOC or no TOC sequence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87318

Files:
  lld/ELF/Arch/PPC64.cpp
  lld/ELF/Relocations.cpp
  lld/test/ELF/ppc64-tls-pcrel-gd.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87318.290538.patch
Type: text/x-patch
Size: 11104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200908/c77aca25/attachment.bin>


More information about the llvm-commits mailing list