diff options
Diffstat (limited to 'src/lib/libcrypto/sha/asm/sha1-x86_64.pl')
-rwxr-xr-x | src/lib/libcrypto/sha/asm/sha1-x86_64.pl | 125 |
1 files changed, 117 insertions, 8 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha1-x86_64.pl b/src/lib/libcrypto/sha/asm/sha1-x86_64.pl index f7ed67a726..4edc5ea9ad 100755 --- a/src/lib/libcrypto/sha/asm/sha1-x86_64.pl +++ b/src/lib/libcrypto/sha/asm/sha1-x86_64.pl | |||
@@ -29,14 +29,18 @@ | |||
29 | # Xeon P4 +65% +0% 9.9 | 29 | # Xeon P4 +65% +0% 9.9 |
30 | # Core2 +60% +10% 7.0 | 30 | # Core2 +60% +10% 7.0 |
31 | 31 | ||
32 | $output=shift; | 32 | $flavour = shift; |
33 | $output = shift; | ||
34 | if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } | ||
35 | |||
36 | $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); | ||
33 | 37 | ||
34 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; | 38 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; |
35 | ( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or | 39 | ( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or |
36 | ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or | 40 | ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or |
37 | die "can't locate x86_64-xlate.pl"; | 41 | die "can't locate x86_64-xlate.pl"; |
38 | 42 | ||
39 | open STDOUT,"| $^X $xlate $output"; | 43 | open STDOUT,"| $^X $xlate $flavour $output"; |
40 | 44 | ||
41 | $ctx="%rdi"; # 1st arg | 45 | $ctx="%rdi"; # 1st arg |
42 | $inp="%rsi"; # 2nd arg | 46 | $inp="%rsi"; # 2nd arg |
@@ -69,13 +73,14 @@ $func: | |||
69 | push %rbx | 73 | push %rbx |
70 | push %rbp | 74 | push %rbp |
71 | push %r12 | 75 | push %r12 |
72 | mov %rsp,%rax | 76 | mov %rsp,%r11 |
73 | mov %rdi,$ctx # reassigned argument | 77 | mov %rdi,$ctx # reassigned argument |
74 | sub \$`8+16*4`,%rsp | 78 | sub \$`8+16*4`,%rsp |
75 | mov %rsi,$inp # reassigned argument | 79 | mov %rsi,$inp # reassigned argument |
76 | and \$-64,%rsp | 80 | and \$-64,%rsp |
77 | mov %rdx,$num # reassigned argument | 81 | mov %rdx,$num # reassigned argument |
78 | mov %rax,`16*4`(%rsp) | 82 | mov %r11,`16*4`(%rsp) |
83 | .Lprologue: | ||
79 | 84 | ||
80 | mov 0($ctx),$A | 85 | mov 0($ctx),$A |
81 | mov 4($ctx),$B | 86 | mov 4($ctx),$B |
@@ -88,10 +93,12 @@ ___ | |||
88 | sub EPILOGUE { | 93 | sub EPILOGUE { |
89 | my $func=shift; | 94 | my $func=shift; |
90 | $code.=<<___; | 95 | $code.=<<___; |
91 | mov `16*4`(%rsp),%rsp | 96 | mov `16*4`(%rsp),%rsi |
92 | pop %r12 | 97 | mov (%rsi),%r12 |
93 | pop %rbp | 98 | mov 8(%rsi),%rbp |
94 | pop %rbx | 99 | mov 16(%rsi),%rbx |
100 | lea 24(%rsi),%rsp | ||
101 | .Lepilogue: | ||
95 | ret | 102 | ret |
96 | .size $func,.-$func | 103 | .size $func,.-$func |
97 | ___ | 104 | ___ |
@@ -233,7 +240,109 @@ ___ | |||
233 | &EPILOGUE("sha1_block_data_order"); | 240 | &EPILOGUE("sha1_block_data_order"); |
234 | $code.=<<___; | 241 | $code.=<<___; |
235 | .asciz "SHA1 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" | 242 | .asciz "SHA1 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" |
243 | .align 16 | ||
244 | ___ | ||
245 | |||
246 | # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, | ||
247 | # CONTEXT *context,DISPATCHER_CONTEXT *disp) | ||
248 | if ($win64) { | ||
249 | $rec="%rcx"; | ||
250 | $frame="%rdx"; | ||
251 | $context="%r8"; | ||
252 | $disp="%r9"; | ||
253 | |||
254 | $code.=<<___; | ||
255 | .extern __imp_RtlVirtualUnwind | ||
256 | .type se_handler,\@abi-omnipotent | ||
257 | .align 16 | ||
258 | se_handler: | ||
259 | push %rsi | ||
260 | push %rdi | ||
261 | push %rbx | ||
262 | push %rbp | ||
263 | push %r12 | ||
264 | push %r13 | ||
265 | push %r14 | ||
266 | push %r15 | ||
267 | pushfq | ||
268 | sub \$64,%rsp | ||
269 | |||
270 | mov 120($context),%rax # pull context->Rax | ||
271 | mov 248($context),%rbx # pull context->Rip | ||
272 | |||
273 | lea .Lprologue(%rip),%r10 | ||
274 | cmp %r10,%rbx # context->Rip<.Lprologue | ||
275 | jb .Lin_prologue | ||
276 | |||
277 | mov 152($context),%rax # pull context->Rsp | ||
278 | |||
279 | lea .Lepilogue(%rip),%r10 | ||
280 | cmp %r10,%rbx # context->Rip>=.Lepilogue | ||
281 | jae .Lin_prologue | ||
282 | |||
283 | mov `16*4`(%rax),%rax # pull saved stack pointer | ||
284 | lea 24(%rax),%rax | ||
285 | |||
286 | mov -8(%rax),%rbx | ||
287 | mov -16(%rax),%rbp | ||
288 | mov -24(%rax),%r12 | ||
289 | mov %rbx,144($context) # restore context->Rbx | ||
290 | mov %rbp,160($context) # restore context->Rbp | ||
291 | mov %r12,216($context) # restore context->R12 | ||
292 | |||
293 | .Lin_prologue: | ||
294 | mov 8(%rax),%rdi | ||
295 | mov 16(%rax),%rsi | ||
296 | mov %rax,152($context) # restore context->Rsp | ||
297 | mov %rsi,168($context) # restore context->Rsi | ||
298 | mov %rdi,176($context) # restore context->Rdi | ||
299 | |||
300 | mov 40($disp),%rdi # disp->ContextRecord | ||
301 | mov $context,%rsi # context | ||
302 | mov \$154,%ecx # sizeof(CONTEXT) | ||
303 | .long 0xa548f3fc # cld; rep movsq | ||
304 | |||
305 | mov $disp,%rsi | ||
306 | xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER | ||
307 | mov 8(%rsi),%rdx # arg2, disp->ImageBase | ||
308 | mov 0(%rsi),%r8 # arg3, disp->ControlPc | ||
309 | mov 16(%rsi),%r9 # arg4, disp->FunctionEntry | ||
310 | mov 40(%rsi),%r10 # disp->ContextRecord | ||
311 | lea 56(%rsi),%r11 # &disp->HandlerData | ||
312 | lea 24(%rsi),%r12 # &disp->EstablisherFrame | ||
313 | mov %r10,32(%rsp) # arg5 | ||
314 | mov %r11,40(%rsp) # arg6 | ||
315 | mov %r12,48(%rsp) # arg7 | ||
316 | mov %rcx,56(%rsp) # arg8, (NULL) | ||
317 | call *__imp_RtlVirtualUnwind(%rip) | ||
318 | |||
319 | mov \$1,%eax # ExceptionContinueSearch | ||
320 | add \$64,%rsp | ||
321 | popfq | ||
322 | pop %r15 | ||
323 | pop %r14 | ||
324 | pop %r13 | ||
325 | pop %r12 | ||
326 | pop %rbp | ||
327 | pop %rbx | ||
328 | pop %rdi | ||
329 | pop %rsi | ||
330 | ret | ||
331 | .size se_handler,.-se_handler | ||
332 | |||
333 | .section .pdata | ||
334 | .align 4 | ||
335 | .rva .LSEH_begin_sha1_block_data_order | ||
336 | .rva .LSEH_end_sha1_block_data_order | ||
337 | .rva .LSEH_info_sha1_block_data_order | ||
338 | |||
339 | .section .xdata | ||
340 | .align 8 | ||
341 | .LSEH_info_sha1_block_data_order: | ||
342 | .byte 9,0,0,0 | ||
343 | .rva se_handler | ||
236 | ___ | 344 | ___ |
345 | } | ||
237 | 346 | ||
238 | #################################################################### | 347 | #################################################################### |
239 | 348 | ||