[PowerPC] Add support for R_PPC64_GOT_TPREL_PCREL34 used in TLS Initial Exec
authorStefan Pintilie <stefanp@ca.ibm.com>
Fri, 18 Sep 2020 18:08:46 +0000 (13:08 -0500)
committerStefan Pintilie <stefanp@ca.ibm.com>
Tue, 22 Sep 2020 10:48:43 +0000 (05:48 -0500)
commitc0071862bb426689acef09491b01b1edca9d747e
treea80485b795bad5c06c0c6c4053b72a333e42d041
parentf835779160ec30340676918915526615a07e826e
[PowerPC] Add support for R_PPC64_GOT_TPREL_PCREL34 used in TLS Initial Exec

Add Thread Local Storage Initial Exec support to LLD.

This patch adds the computation for the relocations as well as the relaxation from Initial Exec to Local Exec.

Initial Exec:
```
pld r9, x@got@tprel@pcrel
add r9, r9, x@tls@pcrel
```
or
```
pld r9, x@got@tprel@pcrel
lbzx r10, r9, x@tls@pcrel
```
Note that @tls@pcrel is actually encoded as R_PPC64_TLS with a one byte displacement.

For the above examples relaxing Intitial Exec to Local Exec:
```
paddi r9, r9, x@tprel
nop
```
or
```
paddi r9, r13, x@tprel
lbz r10, 0(r9)
```

Reviewed By: nemanjai, MaskRay, #powerpc

Differential Revision: https://reviews.llvm.org/D86893
lld/ELF/Arch/PPC64.cpp
lld/test/ELF/ppc64-tls-pcrel-ie.s [new file with mode: 0644]