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:
|
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.