This is an archive of the discontinued LLVM Phabricator instance.

[ELF/x86] Implemented R_386_TLS_LE_32, R_386_TLS_LE relocations.
ClosedPublic

Authored by grimar on Nov 23 2015, 9:58 AM.

Details

Summary

This patch implements next relocations:
R_386_TLS_LE - Negative offset relative to static TLS (GNU version).
R_386_TLS_LE_32 - Offset relative to static TLS block.

These ones are created when using next code sequences:

  • @tpoff - The operator must be used to compute an immediate value. The linker will report

an error if the referenced variable is not defined or it is not code for the executable
itself. No GOT entry is created in this case.

  • @ntpoff Calculate the negative offset of the variable it is added to relative to the static TLS block.

The operator must be used to compute an immediate value. The linker will report
an error if the referenced variable is not defined or it is not code for the executable
itself. No GOT entry is created in this case.

Information was found in Ulrich Drepper, ELF Handling For Thread-Local Storage, http://www.akkadia.org/drepper/tls.pdf, (6.2, p76)

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 40947.Nov 23 2015, 9:58 AM
grimar retitled this revision from to [ELF/x86] Implemented R_386_TLS_LE_32, R_386_TLS_LE relocations..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
emaste added a subscriber: emaste.Nov 23 2015, 9:59 AM
ruiu edited edge metadata.Nov 23 2015, 10:06 AM

Can you write a description of this change to the commit message?

grimar updated this object.Nov 23 2015, 3:31 PM
grimar edited edge metadata.
In D14930#295165, @ruiu wrote:

Can you write a description of this change to the commit message?

Updated description. Is it fine now or should I extend it ?

grimar updated this object.Nov 24 2015, 1:39 AM
ruiu added inline comments.Nov 24 2015, 12:07 PM
ELF/InputSection.cpp
150 ↗(On Diff #40947)

require -> requires (since we use "needs" in other places.)

But maybe isTlsDynReloc is better?

ELF/OutputSections.cpp
245 ↗(On Diff #40947)

replaceDynReloc -> getDynReloc

grimar updated this revision to Diff 41132.Nov 25 2015, 4:55 AM

Review comments addressed.

ELF/InputSection.cpp
150 ↗(On Diff #40947)

Changed to isTlsDynReloc, thats shorter.

ELF/OutputSections.cpp
245 ↗(On Diff #40947)

Done.

ruiu accepted this revision.Nov 25 2015, 10:20 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 25 2015, 10:20 AM
This revision was automatically updated to reflect the committed changes.