summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/openssl/openssl/openssl_fix_for_x32.patch
blob: 59a4b7ce9a807bb3155f85c69fd61f2bb177df68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Upstream-Status: Pending

Received from H J Liu @ Intel
Make the assembly syntax compatible with x32 gcc. Othewise x32 gcc throws errors.
Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com> 2011/07/13

ported the patch to the 1.0.0e version
Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com> 2011/12/01

ported the patch to the 1.0.0m version
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> 2015/03/24

Ported the patch to 1.0.1t version.
Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com> 2016/05/09
---
diff -ruN a/Configure b/Configure
--- a/Configure	2016-05-04 08:24:51.630028856 +0200
+++ b/Configure	2016-05-04 09:09:14.987332751 +0200
@@ -417,6 +417,7 @@
 "linux-ia64-ecc","ecc:-DL_ENDIAN -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-ia64-icc","icc:-DL_ENDIAN -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-x86_64",	"gcc:-m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
+"linux-x32", "gcc:-mx32 -DL_ENDIAN -O3 -Wall -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32",
 "linux-x86_64-clang","clang: -m64 -DL_ENDIAN -O3 -Wall -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
 "linux64-s390x",	"gcc:-m64 -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
 #### So called "highgprs" target for z/Architecture CPUs
diff -ruN a/crypto/bn/asm/x86_64-gcc.c b/crypto/bn/asm/x86_64-gcc.c
--- a/crypto/bn/asm/x86_64-gcc.c	2016-05-03 15:49:00.000000000 +0200
+++ b/crypto/bn/asm/x86_64-gcc.c	2016-05-04 09:07:52.974863300 +0200
@@ -55,7 +55,7 @@
  *    machine.
  */
 
-# ifdef _WIN64
+# if defined _WIN64 || !defined __LP64__
 #  define BN_ULONG unsigned long long
 # else
 #  define BN_ULONG unsigned long
@@ -211,9 +211,9 @@
 
     asm volatile ("       subq    %2,%2           \n"
                   ".p2align 4                     \n"
-                  "1:     movq    (%4,%2,8),%0    \n"
-                  "       adcq    (%5,%2,8),%0    \n"
-                  "       movq    %0,(%3,%2,8)    \n"
+                  "1:     movq    (%q4,%2,8),%0   \n"
+                  "       adcq    (%q5,%2,8),%0   \n"
+                  "       movq    %0,(%q3,%2,8)   \n"
                   "       leaq    1(%2),%2        \n"
                   "       loop    1b              \n"
                   "       sbbq    %0,%0           \n":"=&a" (ret), "+c"(n),
@@ -235,9 +235,9 @@
 
     asm volatile ("       subq    %2,%2           \n"
                   ".p2align 4                     \n"
-                  "1:     movq    (%4,%2,8),%0    \n"
-                  "       sbbq    (%5,%2,8),%0    \n"
-                  "       movq    %0,(%3,%2,8)    \n"
+                  "1:     movq    (%q4,%2,8),%0   \n"
+                  "       sbbq    (%q5,%2,8),%0   \n"
+                  "       movq    %0,(%q3,%2,8)   \n"
                   "       leaq    1(%2),%2        \n"
                   "       loop    1b              \n"
                   "       sbbq    %0,%0           \n":"=&a" (ret), "+c"(n),
diff -ruN a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
--- a/crypto/bn/bn_exp.c	2016-05-03 15:49:00.000000000 +0200
+++ b/crypto/bn/bn_exp.c	2016-05-04 09:07:52.974863300 +0200
@@ -622,7 +622,7 @@
  * multiple.
  */
 #define MOD_EXP_CTIME_ALIGN(x_) \
-        ((unsigned char*)(x_) + (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - (((size_t)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK))))
+        ((unsigned char*)(x_) + (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - (((BN_ADDR)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK))))
 
 /*
  * This variant of BN_mod_exp_mont() uses fixed windows and the special
diff -ruN a/crypto/bn/bn.h b/crypto/bn/bn.h
--- a/crypto/bn/bn.h	2016-05-03 15:49:00.000000000 +0200
+++ b/crypto/bn/bn.h	2016-05-04 09:07:52.974863300 +0200
@@ -174,6 +174,13 @@
 #  endif
 # endif
 
+/* Address type.  */
+# ifdef _WIN64
+#   define BN_ADDR unsigned long long
+# else
+#   define BN_ADDR unsigned long
+# endif
+
 /*
  * assuming long is 64bit - this is the DEC Alpha unsigned long long is only
  * 64 bits :-(, don't define BN_LLONG for the DEC Alpha