SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

5.4.2 Initial Executable Code Model

An example of the code for the initial executable TLS code model is shown below:

add:
        rd      %pc,%o1
        sethi   %pc22(_GLOBAL_OFFSET_TABLE_-(.L900000106-.)),%g1
        add     %g1,%pc10(_GLOBAL_OFFSET_TABLE_-(.L900000106-.)),%g1
        add     %g1,%o1,%o1
        sethi   %tie_hi22(sum),%o3
        add     %o3,%tie_lo10(sum),%o2
        ldx     [%o1+%o2],%g5,%tie_ldx(sum)
        add     %g7,%g5,%g3,%tie_add(sum)
        ld      [%g3],%g4
        add     %g4,%o0,%g2
        retl
        st      %g2,[%g3]

Here it takes four instructions to form a pointer to the GOT into register %o1, followed by two instruction to form the offset of the address of sum in the GOT.

The operators act as follows:

%tie_hi22(sum)R_SPARC_TLS_IE_HI22 relocation
%tie_lo10(sum)R_SPARC_TLS_IE_LO10
%tie_ldx(sum)R_SPARC_TLS_IE_LDX
%tie_add(sum)R_SPARC_TLS_IE_ADD