Unify all assembler file generators
[openssl.git] / crypto / rc4 / asm / rc4-md5-x86_64.pl
index a92fe92269fd57d53cd87d10ddec220068b81ab7..c9381ca9b2bce31bf5c36a684962dc24926c6a8d 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2011-2016 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
+# 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
@@ -44,11 +51,12 @@ my ($rc4,$md5)=(1,1);       # what to generate?
 my $D="#" if (!$md5);  # if set to "#", MD5 is stitched into RC4(),
                        # but its result is discarded. Idea here is
                        # to be able to use 'openssl speed rc4' for
-                       # benchmarking the stitched subroutine... 
+                       # benchmarking the stitched subroutine...
 
-my $flavour = shift;
-my $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
+my $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+my $flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
 
 my $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
 
@@ -57,7 +65,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
 ( $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;
 
 my ($dat,$in0,$out,$ctx,$inp,$len, $func,$nargs);
@@ -117,15 +126,23 @@ $code.=<<___;
 .globl $func
 .type  $func,\@function,$nargs
 $func:
+.cfi_startproc
        cmp     \$0,$len
        je      .Labort
        push    %rbx
+.cfi_push      %rbx
        push    %rbp
+.cfi_push      %rbp
        push    %r12
+.cfi_push      %r12
        push    %r13
+.cfi_push      %r13
        push    %r14
+.cfi_push      %r14
        push    %r15
+.cfi_push      %r15
        sub     \$40,%rsp
+.cfi_adjust_cfa_offset 40
 .Lbody:
 ___
 if ($rc4) {
@@ -412,7 +429,7 @@ $code.=<<___ if ($rc4 && (!$md5 || $D));
        and     \$63,$len               # remaining bytes
        jnz     .Loop1
        jmp     .Ldone
-       
+
 .align 16
 .Loop1:
        add     $TX[0]#b,$YY#b
@@ -437,15 +454,23 @@ $code.=<<___;
 #rc4#  movl    $YY#d,-4($dat)
 
        mov     40(%rsp),%r15
+.cfi_restore   %r15
        mov     48(%rsp),%r14
+.cfi_restore   %r14
        mov     56(%rsp),%r13
+.cfi_restore   %r13
        mov     64(%rsp),%r12
+.cfi_restore   %r12
        mov     72(%rsp),%rbp
+.cfi_restore   %rbp
        mov     80(%rsp),%rbx
+.cfi_restore   %rbx
        lea     88(%rsp),%rsp
+.cfi_adjust_cfa_offset -88
 .Lepilogue:
 .Labort:
        ret
+.cfi_endproc
 .size $func,.-$func
 ___