SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

5.2.5 64–Bit With 32–Bit PIC

The 64-bit with 32-bit PIC code for add() might look as follows:

add:
         .L900000106:
         rd      %pc,%o1
         sethi   %pc22(_GLOBAL_OFFSET_TABLE_-(.L900000106-.)),%g1
         sethi   %got22(sum),%o3
         add     %g1,%pc10(_GLOBAL_OFFSET_TABLE_-(.L900000106-.)),%g1
         xor     %o3,%got10(sum),%o2
         add     %g1,%o1,%o1
         ldx     [%o1+%o2],%g4,%gdop(sum)
         ld      [%g4],%g5
         add     %g5,%o0,%g3
         retl    ! Result =
         st      %g3,[%g4]

Again, the address of sum is formed in two parts. The first part forms the address of the global offset table (GOT). Then a 32-bit offset into the GOT is used to load the address of sum.

The operators act as follows:

%pc22(...)R_SPARC_PC22 relocation
%pc13(...)R_SPARC_PC13
%got22(sum)R_SPARC_GOT22
%got10(sum)R_SPARC_GOT10
%gdop(sum)R_SPARC_GOTDATA_OP

Similarly, the 32-bit code with 32-bit PIC would use just ld instead of ldx to load the address of sum from the GOT.