This is an archive of the discontinued LLVM Phabricator instance.

[PPC64] Support relaxing R_PPC64_TLSGD16 in TlsGdtoLe relaxation
ClosedPublic

Authored by sfertile on Sep 13 2018, 1:04 PM.

Details

Summary

A General-dynamic tls access can be written using a R_PPC64_TLSGD16 relocation if the target got entry is within 16 bits of the TOC-base. This patch adds support for R_PPC64_TLSGD16 by relaxing it the same as a R_PPC64_GOT_TLSGD16_LO, ie rewriting the instruction to an addis 3, 13, a@tprel@ha. The full transformation is:

gd: le:

addi 3,2,a@got@tlsgd                           --> addis 3, 13, a@tprel@ha
bl __tls_get_addr(a@tlsgd)                   --> nop
nop                                                             --> addi 3, 3, a@tprel@l

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

sfertile created this revision.Sep 13 2018, 1:04 PM
ruiu accepted this revision.Sep 13 2018, 1:06 PM

LGTM

This revision is now accepted and ready to land.Sep 13 2018, 1:06 PM
MaskRay added inline comments.Sep 14 2018, 2:56 PM
test/ELF/ppc64-tls-gd-le-small.s
8

Do not have a strong opinion here.. But do you want to use the short form -r?

--wide -W is actually an ignored option in llvm-readelf.

https://github.com/llvm-mirror/llvm/tree/master/tools/llvm-readobj/llvm-readobj.cpp#L52

MaskRay accepted this revision.Sep 14 2018, 2:56 PM
This revision was automatically updated to reflect the committed changes.
sfertile added inline comments.Sep 17 2018, 2:03 PM
test/ELF/ppc64-tls-gd-le-small.s
8

I removed the --wide, but left the --relocations for now following the discussion on D52124.