This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ARM] Add support for static TLS to ARM
ClosedPublic

Authored by peter.smith on Nov 29 2016, 7:00 AM.

Details

Summary

Building on top of https://reviews.llvm.org/D27158 this adds support static linking for ARM TLS.

To do this we add support for the module index relocation R_ARM_DTPMOD32 to be resolved at static link time. The module index for the executable is always 1 so this is trivial to resolve.

The logic in handleNoRelaxTlsRelocation remains the same for Mips as it has its own custom GOT writing code. For ARM we add the module index relocation to the GOT when it can be resolved statically.

In addition to this change I noticed that the type of the RelExpr for the TlsGotRel should be R_TLS and not R_ABS as we need to include the size of the thread control block in the calculation. I wrote a comment in Phab yesterday on D27158 but it doesn't look like it got submitted, my apologies for the mixup.

Addresses the TLS part of PR30218.

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith retitled this revision from to [LLD][ARM] Add support for static TLS to ARM.
peter.smith updated this object.
peter.smith added reviewers: ruiu, rafael, atanasyan.
peter.smith added a subscriber: llvm-commits.
ruiu added inline comments.Nov 29 2016, 8:00 AM
ELF/Relocations.cpp
97 ↗(On Diff #79553)

Code looks fine, but it needs comments for future readers as to why we need this.

Thanks for the review. I've added a comment as requested.

atanasyan accepted this revision.Nov 29 2016, 8:17 AM
atanasyan edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 29 2016, 8:17 AM
This revision was automatically updated to reflect the committed changes.