Addressing memory
-There are many ways to reference data, in the sake of writing
-position-independent code the current implementation uses GOT-indirect
+There are many ways to reference data, to maintain support of
+position-independent code the current implementations use GOT-indirect
addressing (Accessing data through the global offset table):
1. Define data in .data section
2. Load the address of data into register from the global offset table
- e.g. ld 7, my_var@got(2)
+ Use 32-bit offset (medium or large code model) to get maximum addressing
+ reach of 4 GB e.g. addis r7, r2, my_var@got@ha
+ ld r7, my_var@got@l(r7)
3. Use the address to load the value of data into register
- e.g. ld 3, 0(7)
+ e.g. ld r3, 0(r7)
Refer to [2] for more information about referencing data
VSX instructions "lxvd2x/stxvd2x" are used to load and store data to
C DATA_SRC storage.
C DATA_LOAD_VEC(VEC_DST, DATA_SRC, GPR)
define(`DATA_LOAD_VEC',
-`ld $3,$2@got(r2)
+`addis $3,r2,$2@got@ha
+ld $3,$2@got@l($3)
lvx $1,0,$3')
dnl Usage: r0 ... r31, cr0 ... cr7
vspltw v15, v12, 3
vspltw v12, v12, 0
- ld r9, .Lcnts@got(r2)
+ addis r9, r2, .Lcnts@got@ha
+ ld r9, .Lcnts@got@l(r9)
lxvw4x VSR(T0), 0, r9 C increments
vaddcuw T1, v12, T0 C compute carry-out
vadduwm v12, v12, T0 C low adds