sha/asm/sha1-x86_64.pl: fix crash in SHAEXT code on Windows.
[openssl.git] / crypto / sha / asm / sha1-x86_64.pl
index d6b0722f31af0ddc16ab2758cb88f36da412d118..97baae37cd954c7ecddb70669ce981f1a0985beb 100755 (executable)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
 #
 # ====================================================================
 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
@@ -108,14 +115,14 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
        $avx = ($1>=10) + ($1>=11);
 }
 
-if (!$avx && `$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([2-9]\.[0-9]+)/) {
+if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([2-9]\.[0-9]+)/) {
        $avx = ($2>=3.0) + ($2>3.0);
 }
 
 $shaext=1;     ### set to zero if compiling for 1.0.1
 $avx=1         if (!$shaext && $avx);
 
-open OUT,"| \"$^X\" $xlate $flavour $output";
+open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
 *STDOUT=*OUT;
 
 $ctx="%rdi";   # 1st arg
@@ -373,9 +380,9 @@ $code.=<<___;
 .align 16
 .Loop_shaext:
        dec             $num
-       lea             0x40($inp),%rax         # next input block
+       lea             0x40($inp),%r         # next input block
        paddd           @MSG[0],$E
-       cmovne          %rax,$inp
+       cmovne          %r8,$inp
        movdqa          $ABCD,$ABCD_SAVE        # offload $ABCD
 ___
 for($i=0;$i<20-4;$i+=2) {