~mmach/netext73/isl

« back to all changes in this revision

Viewing changes to debian/patches/pic.patch

  • Committer: mmach
  • Date: 2019-05-14 07:37:06 UTC
  • Revision ID: netbit73@gmail.com-20190514073706-nt6iq2m3597se19c
0.21

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Debian OpenSSL Team <pkg-openssl-devel@lists.alioth.debian.org>
 
2
Date: Tue, 12 Dec 2017 23:35:24 +0100
 
3
Subject: pic
 
4
 
 
5
===================================================================
 
6
---
 
7
 crypto/des/asm/desboth.pl | 17 ++++++++++++++---
 
8
 crypto/perlasm/cbc.pl     | 24 ++++++++++++++++++++----
 
9
 crypto/perlasm/x86gas.pl  | 16 ++++++++++++++++
 
10
 crypto/x86cpuid.pl        | 10 +++++-----
 
11
 4 files changed, 55 insertions(+), 12 deletions(-)
 
12
 
 
13
diff --git a/crypto/des/asm/desboth.pl b/crypto/des/asm/desboth.pl
 
14
index eec00886e4c6..ab6f52452bf3 100644
 
15
--- a/crypto/des/asm/desboth.pl
 
16
+++ b/crypto/des/asm/desboth.pl
 
17
@@ -16,6 +16,11 @@ sub DES_encrypt3
 
18
 
 
19
        &push("edi");
 
20
 
 
21
+       &call   (&label("pic_point0"));
 
22
+       &set_label("pic_point0");
 
23
+       &blindpop("ebp");
 
24
+       &add    ("ebp", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
 
25
+
 
26
        &comment("");
 
27
        &comment("Load the data words");
 
28
        &mov($L,&DWP(0,"ebx","",0));
 
29
@@ -47,15 +52,21 @@ sub DES_encrypt3
 
30
        &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
 
31
        &mov(&swtmp(1), "eax");
 
32
        &mov(&swtmp(0), "ebx");
 
33
-       &call("DES_encrypt2");
 
34
+       &exch("ebx", "ebp");
 
35
+       &call("DES_encrypt2\@PLT");
 
36
+       &exch("ebx", "ebp");
 
37
        &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
 
38
        &mov(&swtmp(1), "edi");
 
39
        &mov(&swtmp(0), "ebx");
 
40
-       &call("DES_encrypt2");
 
41
+       &exch("ebx", "ebp");
 
42
+       &call("DES_encrypt2\@PLT");
 
43
+       &exch("ebx", "ebp");
 
44
        &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
 
45
        &mov(&swtmp(1), "esi");
 
46
        &mov(&swtmp(0), "ebx");
 
47
-       &call("DES_encrypt2");
 
48
+       &exch("ebx", "ebp");
 
49
+       &call("DES_encrypt2\@PLT");
 
50
+       &exch("ebx", "ebp");
 
51
 
 
52
        &stack_pop(3);
 
53
        &mov($L,&DWP(0,"ebx","",0));
 
54
diff --git a/crypto/perlasm/cbc.pl b/crypto/perlasm/cbc.pl
 
55
index 24561e759aba..269fb0b0c69f 100644
 
56
--- a/crypto/perlasm/cbc.pl
 
57
+++ b/crypto/perlasm/cbc.pl
 
58
@@ -122,7 +122,11 @@ sub cbc
 
59
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
 
60
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
 
61
 
 
62
-       &call($enc_func);
 
63
+       &call   (&label("pic_point0"));
 
64
+       &set_label("pic_point0");
 
65
+       &blindpop("ebx");
 
66
+       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
 
67
+       &call("$enc_func\@PLT");
 
68
 
 
69
        &mov("eax",     &DWP($data_off,"esp","",0));
 
70
        &mov("ebx",     &DWP($data_off+4,"esp","",0));
 
71
@@ -185,7 +189,11 @@ sub cbc
 
72
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
 
73
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
 
74
 
 
75
-       &call($enc_func);
 
76
+       &call   (&label("pic_point1"));
 
77
+       &set_label("pic_point1");
 
78
+       &blindpop("ebx");
 
79
+       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point1") . "]");
 
80
+       &call("$enc_func\@PLT");
 
81
 
 
82
        &mov("eax",     &DWP($data_off,"esp","",0));
 
83
        &mov("ebx",     &DWP($data_off+4,"esp","",0));
 
84
@@ -218,7 +226,11 @@ sub cbc
 
85
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
 
86
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
 
87
 
 
88
-       &call($dec_func);
 
89
+       &call   (&label("pic_point2"));
 
90
+       &set_label("pic_point2");
 
91
+       &blindpop("ebx");
 
92
+       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point2") . "]");
 
93
+       &call("$dec_func\@PLT");
 
94
 
 
95
        &mov("eax",     &DWP($data_off,"esp","",0));    # get return
 
96
        &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
 
97
@@ -261,7 +273,11 @@ sub cbc
 
98
        &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
 
99
        &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
 
100
 
 
101
-       &call($dec_func);
 
102
+       &call   (&label("pic_point3"));
 
103
+       &set_label("pic_point3");
 
104
+       &blindpop("ebx");
 
105
+       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point3") . "]");
 
106
+       &call("$dec_func\@PLT");
 
107
 
 
108
        &mov("eax",     &DWP($data_off,"esp","",0));    # get return
 
109
        &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
 
110
diff --git a/crypto/perlasm/x86gas.pl b/crypto/perlasm/x86gas.pl
 
111
index 63b2301fd1f0..176b04d24521 100644
 
112
--- a/crypto/perlasm/x86gas.pl
 
113
+++ b/crypto/perlasm/x86gas.pl
 
114
@@ -163,6 +163,7 @@ sub ::file_end
 
115
        if ($::macosx)  { push (@out,"$tmp,2\n"); }
 
116
        elsif ($::elf)  { push (@out,"$tmp,4\n"); }
 
117
        else            { push (@out,"$tmp\n"); }
 
118
+       if ($::elf)     { push (@out,".hidden\tOPENSSL_ia32cap_P\n"); }
 
119
     }
 
120
     push(@out,$initseg) if ($initseg);
 
121
 }
 
122
@@ -221,8 +222,23 @@ ___
 
123
     elsif ($::elf)
 
124
     {  $initseg.=<<___;
 
125
 .section       .init
 
126
+___
 
127
+        if ($::pic)
 
128
+       {   $initseg.=<<___;
 
129
+       pushl   %ebx
 
130
+       call    .pic_point0
 
131
+.pic_point0:
 
132
+       popl    %ebx
 
133
+       addl    \$_GLOBAL_OFFSET_TABLE_+[.-.pic_point0],%ebx
 
134
+       call    $f\@PLT
 
135
+       popl    %ebx
 
136
+___
 
137
+       }
 
138
+       else
 
139
+       {   $initseg.=<<___;
 
140
        call    $f
 
141
 ___
 
142
+       }
 
143
     }
 
144
     elsif ($::coff)
 
145
     {   $initseg.=<<___;       # applies to both Cygwin and Mingw
 
146
diff --git a/crypto/x86cpuid.pl b/crypto/x86cpuid.pl
 
147
index 90ed196c09cd..b49d1be8c38c 100644
 
148
--- a/crypto/x86cpuid.pl
 
149
+++ b/crypto/x86cpuid.pl
 
150
@@ -8,6 +8,8 @@ require "x86asm.pl";
 
151
 
 
152
 for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
 
153
 
 
154
+push(@out, ".hidden OPENSSL_ia32cap_P\n");
 
155
+
 
156
 &function_begin("OPENSSL_ia32_cpuid");
 
157
        &xor    ("edx","edx");
 
158
        &pushf  ();
 
159
@@ -153,9 +155,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
 
160
 &set_label("nocpuid");
 
161
 &function_end("OPENSSL_ia32_cpuid");
 
162
 
 
163
-&external_label("OPENSSL_ia32cap_P");
 
164
-
 
165
-&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
 
166
+&function_begin_B("OPENSSL_rdtsc");
 
167
        &xor    ("eax","eax");
 
168
        &xor    ("edx","edx");
 
169
        &picmeup("ecx","OPENSSL_ia32cap_P");
 
170
@@ -169,7 +169,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
 
171
 # This works in Ring 0 only [read DJGPP+MS-DOS+privileged DPMI host],
 
172
 # but it's safe to call it on any [supported] 32-bit platform...
 
173
 # Just check for [non-]zero return value...
 
174
-&function_begin_B("OPENSSL_instrument_halt","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
 
175
+&function_begin_B("OPENSSL_instrument_halt");
 
176
        &picmeup("ecx","OPENSSL_ia32cap_P");
 
177
        &bt     (&DWP(0,"ecx"),4);
 
178
        &jnc    (&label("nohalt"));     # no TSC
 
179
@@ -236,7 +236,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
 
180
        &ret    ();
 
181
 &function_end_B("OPENSSL_far_spin");
 
182
 
 
183
-&function_begin_B("OPENSSL_wipe_cpu","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
 
184
+&function_begin_B("OPENSSL_wipe_cpu");
 
185
        &xor    ("eax","eax");
 
186
        &xor    ("edx","edx");
 
187
        &picmeup("ecx","OPENSSL_ia32cap_P");