x64: Local Executable (LE)
This code sequence implements the LE
model described in Thread-Local Storage Access Models.
Table 16-22 x64: Local Executable Thread-Local Variable Access Codes
Code Sequence |
Initial Relocations |
Symbol |
0x00 movq %fs:0, %rax 0x09 leaq x@tpoff(%rax), %rax # %rax - contains address of TLS variable |
<none> R_AMD64_TPOFF32 |
x |
To load the contents of a TLS variable instead of the address of a TLS variable, the following sequence can be used.
Table 16-23 x64: Local Executable Thread-Local Variable Access Codes II
Code Sequence |
Initial Relocations |
Symbol |
0x00 movq %fs:0, %rax 0x09 movq x@tpoff(%rax), %rax # %rax - contains contents of TLS variable |
<none> R_AMD64_TPOFF32 |
x |
The following sequence is even shorter.
Table 16-24 x64: Local Executable Thread-Local Variable Access Codes III
Code Sequence |
Initial Relocations |
Symbol |
0x00 movq %fs:x@tpoff, %rax # %rax - contains contents of TLS variable |
R_AMD64_TPOFF32 |
x |