Update copyright year
[openssl.git] / crypto / ec / asm / x25519-x86_64.pl
index b32a0415d94ff99e9a272410ea57199bd4918e16..a8b145e6a0f6da3b32c68b6583e7fa2a4cc39909 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env perl
-# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 #      C implementation, so that comparison is always against
 #      2^51 radix;
 
-$flavour = shift;
-$output  = shift;
-if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
+# $output is the last argument if it looks like a file (it has an extension)
+# $flavour is the first argument if it doesn't look like a file
+$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
 
 $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
 
@@ -72,7 +73,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
 die "can't locate x86_64-xlate.pl";
 
-open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
+open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
+    or die "can't call $xlate: $!";
 *STDOUT=*OUT;
 
 if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
@@ -90,7 +92,7 @@ if (!$addx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
        $addx = ($1>=12);
 }
 
-if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9])\.([0-9]+)/) {
+if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([0-9]+)\.([0-9]+)/) {
        my $ver = $2 + $3/100.0;        # 3.1->3.01, 3.10->3.10
        $addx = ($ver>=3.03);
 }
@@ -488,12 +490,14 @@ $code.=<<___;
 .type  x25519_fe64_eligible,\@abi-omnipotent
 .align 32
 x25519_fe64_eligible:
+.cfi_startproc
        mov     OPENSSL_ia32cap_P+8(%rip),%ecx
        xor     %eax,%eax
        and     \$0x80100,%ecx
        cmp     \$0x80100,%ecx
        cmove   %ecx,%eax
        ret
+.cfi_endproc
 .size  x25519_fe64_eligible,.-x25519_fe64_eligible
 
 .globl x25519_fe64_mul
@@ -722,6 +726,7 @@ x25519_fe64_sqr:
 .align 32
 x25519_fe64_mul121666:
 .Lfe64_mul121666_body:
+.cfi_startproc
        mov     \$121666,%edx
        mulx    8*0(%rsi),$acc0,%rcx
        mulx    8*1(%rsi),$acc1,%rax
@@ -750,6 +755,7 @@ x25519_fe64_mul121666:
 
 .Lfe64_mul121666_epilogue:
        ret
+.cfi_endproc
 .size  x25519_fe64_mul121666,.-x25519_fe64_mul121666
 
 .globl x25519_fe64_add
@@ -757,6 +763,7 @@ x25519_fe64_mul121666:
 .align 32
 x25519_fe64_add:
 .Lfe64_add_body:
+.cfi_startproc
        mov     8*0(%rsi),$acc0
        mov     8*1(%rsi),$acc1
        mov     8*2(%rsi),$acc2
@@ -785,6 +792,7 @@ x25519_fe64_add:
 
 .Lfe64_add_epilogue:
        ret
+.cfi_endproc
 .size  x25519_fe64_add,.-x25519_fe64_add
 
 .globl x25519_fe64_sub
@@ -792,6 +800,7 @@ x25519_fe64_add:
 .align 32
 x25519_fe64_sub:
 .Lfe64_sub_body:
+.cfi_startproc
        mov     8*0(%rsi),$acc0
        mov     8*1(%rsi),$acc1
        mov     8*2(%rsi),$acc2
@@ -820,6 +829,7 @@ x25519_fe64_sub:
 
 .Lfe64_sub_epilogue:
        ret
+.cfi_endproc
 .size  x25519_fe64_sub,.-x25519_fe64_sub
 
 .globl x25519_fe64_tobytes
@@ -827,6 +837,7 @@ x25519_fe64_sub:
 .align 32
 x25519_fe64_tobytes:
 .Lfe64_to_body:
+.cfi_startproc
        mov     8*0(%rsi),$acc0
        mov     8*1(%rsi),$acc1
        mov     8*2(%rsi),$acc2
@@ -862,6 +873,7 @@ x25519_fe64_tobytes:
 
 .Lfe64_to_epilogue:
        ret
+.cfi_endproc
 .size  x25519_fe64_tobytes,.-x25519_fe64_tobytes
 ___
 } else {
@@ -870,8 +882,10 @@ $code.=<<___;
 .type  x25519_fe64_eligible,\@abi-omnipotent
 .align 32
 x25519_fe64_eligible:
+.cfi_startproc
        xor     %eax,%eax
        ret
+.cfi_endproc
 .size  x25519_fe64_eligible,.-x25519_fe64_eligible
 
 .globl x25519_fe64_mul
@@ -887,8 +901,10 @@ x25519_fe64_mul121666:
 x25519_fe64_add:
 x25519_fe64_sub:
 x25519_fe64_tobytes:
+.cfi_startproc
        .byte   0x0f,0x0b       # ud2
        ret
+.cfi_endproc
 .size  x25519_fe64_mul,.-x25519_fe64_mul
 ___
 }
@@ -1114,4 +1130,4 @@ ___
 
 $code =~ s/\`([^\`]*)\`/eval $1/gem;
 print $code;
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";