This code sequence implements the LE model described in Thread-Local Storage Access Models.
Table 8–22 x64: Local Executable Thread-Local Variable Access Codes
Code Sequence |
Initial Relocations |
Symbol |
0x00 movq %fs:0, %rax 0x06 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 8–23 x64: Local Executable Thread-Local Variable Access Codes II
Code Sequence |
Initial Relocations |
Symbol |
0x00 movq %fs:0, %rax 0x06 movq x@tpoff(%rax), %rax # %rax - contains contents of TLS variable |
<none> R_AMD64_TPOFF32 |
x |
The following sequence is even shorter.
Table 8–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 |