32-bit x86: Local Executable (LE)
This code sequence implements the LE
model described in Thread-Local Storage Access Models.
Table 16-14 32-bit x86: Local Executable Thread-Local Variable Access Codes
Code Sequence |
Initial Relocations |
Symbol |
0x00 movl %gs:0, %eax 0x06 leal x@ntpoff(%eax), %eax # %eax - contains address of TLS variable |
<none> R_386_TLS_LE |
x |
The movl
instruction generates a R_386_TLS_LE_32
relocation. The link-editor binds this relocation directly to the static TLS offset for the symbol defined in the executable. No processing is required at runtime.
The contents of variable x
, rather then the address, can be accessed with the same relocation by using the following instruction sequence.
Table 16-15 32-bit x86: Local Executable Thread-Local Variable Access Codes
Code Sequence |
Initial Relocations |
Symbol |
0x00 movl %gs:0, %eax 0x06 movl x@ntpoff(%eax), %eax # %eax - contains address of TLS variable |
<none> R_386_TLS_LE |
x |
Rather than computing the address of the variable, a load from the variable or store to the variable can be accomplished using the following sequence. Note, the x@ntpoff
expression is not used as an immediate value, but as an absolute address.
Table 16-16 32-bit x86: Local Executable Thread-Local Variable Access Codes
Code Sequence |
Initial Relocations |
Symbol |
0x00 movl %gs:x@ntpoff, %eax # %eax - contains address of TLS variable |
R_386_TLS_LE |
x |