[all-commits] [llvm/llvm-project] 88f2fe: Raland D87318 [LLD][PowerPC] Add support for R_PPC...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Oct 1 12:36:54 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 88f2fe5cad6cc3a3830448cb8a88b52ee449f2d1
      https://github.com/llvm/llvm-project/commit/88f2fe5cad6cc3a3830448cb8a88b52ee449f2d1
  Author: Fangrui Song <i at maskray.me>
  Date:   2020-10-01 (Thu, 01 Oct 2020)

  Changed paths:
    M lld/ELF/Arch/PPC64.cpp
    M lld/ELF/Relocations.cpp
    A lld/test/ELF/ppc64-tls-pcrel-gd.s

  Log Message:
  -----------
  Raland D87318 [LLD][PowerPC] Add support for R_PPC64_GOT_TLSGD_PCREL34 used in TLS General Dynamic

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_TLSGD_PCREL34
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_TLSGD_PCREL34 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.

Reviewed By: NeHuang, sfertile, MaskRay

Differential Revision: https://reviews.llvm.org/D87318




More information about the All-commits mailing list