Fix alignment errors in hashtable fuzzer
[openssl.git] / crypto / sha / asm / sha1-armv8.pl
index 12403eb783340ea5a0642ef83cb95bde92aa1ada..5f23a20c1ab7907e72e66e84433e1e44a660509e 100644 (file)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2014-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
 # (**) Keep in mind that Denver relies on binary translation, which
 #      optimizes compiler output at run-time.
 
-$flavour = shift;
-$output  = shift;
+# $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;
 
 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
 ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
 die "can't locate arm-xlate.pl";
 
-open OUT,"| \"$^X\" $xlate $flavour $output";
+open OUT,"| \"$^X\" $xlate $flavour \"$output\""
+    or die "can't call $xlate: $1";
 *STDOUT=*OUT;
 
 ($ctx,$inp,$num)=("x0","x1","x2");
@@ -172,9 +175,10 @@ ___
 }
 
 $code.=<<___;
+#include "arm_arch.h"
 #ifndef        __KERNEL__
-# include "arm_arch.h"
 .extern OPENSSL_armcap_P
+.hidden OPENSSL_armcap_P
 #endif
 
 .text
@@ -183,11 +187,13 @@ $code.=<<___;
 .type  sha1_block_data_order,%function
 .align 6
 sha1_block_data_order:
+       AARCH64_VALID_CALL_TARGET
        adrp    x16,OPENSSL_armcap_P
        ldr     w16,[x16,#:lo12:OPENSSL_armcap_P]
        tst     w16,#ARMV8_SHA1
        b.ne    .Lv8_entry
 
+       // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
        stp     x29,x30,[sp,#-96]!
        add     x29,sp,#0
        stp     x19,x20,[sp,#16]
@@ -249,6 +255,7 @@ $code.=<<___;
 .align 6
 sha1_block_armv8:
 .Lv8_entry:
+       // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later.
        stp     x29,x30,[sp,#-16]!
        add     x29,sp,#0
 
@@ -320,9 +327,6 @@ $code.=<<___;
 .long  0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6     //K_60_79
 .asciz "SHA1 block transform for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
 .align 2
-#if !defined(__KERNELL__) && !defined(_WIN64)
-.comm  OPENSSL_armcap_P,4,4
-#endif
 ___
 }}}
 
@@ -354,4 +358,4 @@ foreach(split("\n",$code)) {
        print $_,"\n";
 }
 
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";