This is an archive of the discontinued LLVM Phabricator instance.

[lld][ELF][SPARC] Support TLS IE relocations
AbandonedPublic

Authored by LemonBoy on May 21 2021, 2:38 AM.

Details

Reviewers
MaskRay
jrtc27
Summary

Implement the Initial-Executable model and its relaxation to the Local-Executable one.

Diff Detail

Event Timeline

LemonBoy created this revision.May 21 2021, 2:38 AM
LemonBoy requested review of this revision.May 21 2021, 2:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2021, 2:38 AM
MaskRay added inline comments.May 21 2021, 7:30 PM
lld/test/ELF/sparcv9-tls-ie.s
10

align the instructions

See the style of new tests.

33

Useful to check the addend 0x0

LemonBoy updated this revision to Diff 347177.May 22 2021, 12:36 AM

Fix test formatting.
Force use of rela over rel, forgot to commit this change with the previous patch.

MaskRay accepted this revision.May 22 2021, 3:12 PM

Looks great!

This revision is now accepted and ready to land.May 22 2021, 3:12 PM
jrtc27 added inline comments.May 22 2021, 3:16 PM
lld/ELF/Arch/SPARCV9.cpp
220
lld/ELF/Driver.cpp
929 ↗(On Diff #347177)

This should probably be its own commit, it's unrelated to TLS.

lld/test/ELF/sparcv9-tls-ie.s
26

All directives are normally indented to the same level

jrtc27 requested changes to this revision.May 22 2021, 3:16 PM
This revision now requires changes to proceed.May 22 2021, 3:16 PM
LemonBoy added inline comments.May 22 2021, 11:39 PM
lld/ELF/Driver.cpp
929 ↗(On Diff #347177)

This _is_ related to TLS as, without this change, the R_SPARC_TLS_TPOFF64 would end up in REL form and the resulting program be rejected by ld.so.

LemonBoy updated this revision to Diff 347241.May 23 2021, 3:39 AM

Reserve 3 slots in the GOT, this detail was well-hidden in the documentation.
Address some stylistic nits.

jrtc27 added inline comments.May 23 2021, 7:03 AM
lld/ELF/Driver.cpp
929 ↗(On Diff #347177)

Why is R_SPARC_TLS_TPOFF64 special? Surely that's true of any dynamic relocation.

LemonBoy added inline comments.May 23 2021, 7:17 AM
lld/ELF/Driver.cpp
929 ↗(On Diff #347177)

It's not special, it's only the first dynamic relocation that's covered by a test (for the SPARC target, that is). Splitting this patch into many interdependent pieces is going to be a pain, especially since I already have other patches rebased on top of this.

LemonBoy updated this revision to Diff 347248.May 23 2021, 7:36 AM

I apparently misunderstood the description about reserved GOT entries.

jrtc27 added inline comments.May 23 2021, 7:37 AM
lld/ELF/Driver.cpp
929 ↗(On Diff #347177)

So this is a bug fix for the fact that LLD already emits ABI-violating binaries (e.g. just have static int x; static int *p = &x; and link that as a shared object, then you'll get an R_SPARC_RELATIVE as rel rather than rela). Hence why this should be decoupled. It's a trivial one-line patch to commit.

LemonBoy updated this revision to Diff 347251.May 23 2021, 9:04 AM

Make this patch depend on D102985

LemonBoy abandoned this revision.Jun 19 2022, 1:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2022, 1:38 AM
Herald added a subscriber: StephenFan. · View Herald Transcript