An example of the local dynamic TLS code model is shown below:
add: save %sp,-176,%sp .L900000107: rd %pc,%i3 sethi %pc22(_GLOBAL_OFFSET_TABLE_-(.L900000107-.)),%g1 add %g1,%pc10(_GLOBAL_OFFSET_TABLE_-(.L900000107-.)),%g1 add %g1,%i3,%i3 sethi %tldm_hi22(sum),%i2 add %i2,%tldm_lo10(sum),%i1 add %i3,%i1,%o0,%tldm_add(sum) call __tls_get_addr,%tldm_call(sum) nop sethi %tldo_hix22(sum),%l7 xor %l7,%tldo_lox10(sum),%l6 add %o0,%l6,%l4,%tldo_add(sum) ld [%l4],%l5 add %l5,%i0,%l3 st %l3,[%l4] ret restore %g0,%g0,%g0
Notice that we could not have a leaf routine because of the call instruction.
There are four instructions to form a pointer to the GOT into register %i3. Then it takes two more instructions to form the offset of the address of sum in the GOT, and another instruction to add those to the address of the GOT to form the address of the GOT slot for sum. This address is passed to function __tls_get_addr that returns the address for local module's TLS data in register %o0. Three more instructions form the offset of sum in the module data and to add that to the module data address. Note that the module data address can be reused to access multiple TLS variables.
The operators act as follows:
|