This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Emit dynamic relocations for PIC non-preemptible static TLS
ClosedPublic

Authored by jrtc27 on Apr 27 2021, 10:00 AM.

Details

Summary

This is the same problem as 127176e59eb9, but for static TLS rather than
dynamic TLS. Although we know the symbol will be the one in our own TLS
segment, and thus the offset of it within that, we don't know where in
the static TLS block our data will be allocated and thus we must emit a
dynamic relocation for this case.

Diff Detail

Event Timeline

jrtc27 created this revision.Apr 27 2021, 10:00 AM
jrtc27 requested review of this revision.Apr 27 2021, 10:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2021, 10:00 AM
MaskRay added inline comments.Apr 27 2021, 10:08 AM
lld/ELF/SyntheticSections.cpp
1004

(Caveat: I know really little/nothing about mips)

if (s->isPreemptible || config->shared)?

For other targets, -pie don't need a dynamic relocation. See bool isLocalInExecutable = !sym.isPreemptible && !config->shared;

jrtc27 added inline comments.Apr 27 2021, 10:10 AM
lld/ELF/SyntheticSections.cpp
1004

Ah that's a good point, in my head I had BFD's definition of isPic here which is our shared. This seems like a systematic inefficiency in the TLS code here (of course, isPic _is_ normally right for the GOT, just not TLS...).

jrtc27 updated this revision to Diff 340900.Apr 27 2021, 10:21 AM

Rebase on top of D101382 and check shared not isPic

MaskRay accepted this revision.Apr 27 2021, 10:30 AM

Thanks! I feel like the mips TLS tests can be better organized. Many other targets use different files for LE/IE/LD/GD, which can usually improve clarity, but that is not your obligation to do it....

This revision is now accepted and ready to land.Apr 27 2021, 10:30 AM

Thanks! I feel like the mips TLS tests can be better organized. Many other targets use different files for LE/IE/LD/GD, which can usually improve clarity, but that is not your obligation to do it....

Yeah, updating these was a painful experience... so I won't complain if someone feels motivated to split them out :)

jrtc27 marked an inline comment as done.Apr 27 2021, 10:59 AM
This revision was landed with ongoing or failed builds.Apr 27 2021, 11:05 AM
This revision was automatically updated to reflect the committed changes.