This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] Fix ARM TLS global dynamic TlsOffsetRel for non-preemtible symbols
ClosedPublic

Authored by peter.smith on Apr 6 2017, 3:29 AM.

Details

Summary

When the target of the TlsOffsetRel is non-preemptible we can write the offset directly into the GOT without needing a dynamic relocation. This is optional for dynamically linked executables but is required for static linking.

We used to rely on the GOTSection::writeTo member function to get the TLS offset of the symbol when writing the VA of the symbol. However in r288107 the GOTSection::writeTo was changed to only use relocations for writing values. Unfortunately we were missing the GOT relocation so all TLS offsets were being written as 0. This change adds the relocation to the GOT entry and a test case for non-0 offsets.

This was split out of D31672, it is based off the refactoring change in D31748.

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.Apr 6 2017, 3:29 AM
rafael accepted this revision.Apr 6 2017, 3:07 PM

LGTM assuming the previous one is approved.

This revision is now accepted and ready to land.Apr 6 2017, 3:07 PM
ruiu added inline comments.Apr 6 2017, 6:42 PM
ELF/Relocations.cpp
192 ↗(On Diff #94341)

Can this be more regular relocation rathe rthan TlsOffsetRel? What we want to do is to set a symbol value to the got offset, so it doesn't have to be a TLS relocation, no?

This revision was automatically updated to reflect the committed changes.

I've used the regular relocation code for this change.

ELF/Relocations.cpp
192 ↗(On Diff #94341)

It can be, but doing so makes the later refactoring to have one AddTlsReloc() function more difficult as we can give that function the same relocation code in both cases. Given that refactoring D31751 isn't approved yet I'll use a more regular code, we can always change it back in D31751.