summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormamonet <maamoun@DESKTOP-KU5PF0V.localdomain>2020-12-18 17:38:39 +0200
committermamonet <maamoun@DESKTOP-KU5PF0V.localdomain>2020-12-18 17:42:14 +0200
commit94a57e070a6160000a7d5f07ea632db5c8cdba21 (patch)
tree2f902737f73c3a1c7c3ce63d388a5b70f8b384dc
parent539efc9b997dfba757cacbbc512bc0a216ffe743 (diff)
downloadnettle-94a57e070a6160000a7d5f07ea632db5c8cdba21.tar.gz
[PowerPC64] Use 32-bit offset to load data
-rw-r--r--powerpc64/README10
-rw-r--r--powerpc64/machine.m43
-rw-r--r--powerpc64/p7/chacha-4core.asm3
3 files changed, 10 insertions, 6 deletions
diff --git a/powerpc64/README b/powerpc64/README
index 7301953b..9083d898 100644
--- a/powerpc64/README
+++ b/powerpc64/README
@@ -34,14 +34,16 @@ VR20:VR31 Nonvolatile (extended ABI mode) their values are preserved
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
diff --git a/powerpc64/machine.m4 b/powerpc64/machine.m4
index e2383201..187a49b8 100644
--- a/powerpc64/machine.m4
+++ b/powerpc64/machine.m4
@@ -34,7 +34,8 @@ C used to obtain the effective address of
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
diff --git a/powerpc64/p7/chacha-4core.asm b/powerpc64/p7/chacha-4core.asm
index ed1445dd..e3870063 100644
--- a/powerpc64/p7/chacha-4core.asm
+++ b/powerpc64/p7/chacha-4core.asm
@@ -168,7 +168,8 @@ C Load state and splat
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