camellia/asm/cmll-x86_64.pl: add CFI annotations.
[openssl.git] / crypto / camellia / asm / cmll-x86_64.pl
index 4fe87e99f2a263c4b22307c5642e402b8a3a1870..02c52c3efe47ddf35cbf59cac458abcf269cd73a 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2008-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
+
 
 # ====================================================================
 # Copyright (c) 2008 Andy Polyakov <appro@openssl.org>
@@ -40,7 +47,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 STDOUT,"| $^X $xlate $flavour $output";
+open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
+*STDOUT=*OUT;
 
 sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/;    $r; }
 sub lo() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1l/;
@@ -71,7 +79,7 @@ my $i=@_[0];
 my $seed=defined(@_[1])?@_[1]:0;
 my $scale=$seed<0?-8:8;
 my $j=($i&1)*2;
-my $s0=@S[($j)%4],$s1=@S[($j+1)%4],$s2=@S[($j+2)%4],$s3=@S[($j+3)%4];
+my ($s0,$s1,$s2,$s3)=(@S[($j)%4],@S[($j+1)%4],@S[($j+2)%4],@S[($j+3)%4]);
 
 $code.=<<___;
        xor     $s0,$t0                         # t0^=key[0]
@@ -129,11 +137,17 @@ Camellia_EncryptBlock:
 .align 16
 .Lenc_rounds:
 Camellia_EncryptBlock_Rounds:
+.cfi_startproc
        push    %rbx
+.cfi_push      %rbx
        push    %rbp
+.cfi_push      %rbp
        push    %r13
+.cfi_push      %r13
        push    %r14
+.cfi_push      %r14
        push    %r15
+.cfi_push      %r15
 .Lenc_prologue:
 
        #mov    %rsi,$inp               # put away arguments
@@ -165,13 +179,20 @@ Camellia_EncryptBlock_Rounds:
        mov     @S[3],12($out)
 
        mov     0(%rsp),%r15
+.cfi_restore   %r15
        mov     8(%rsp),%r14
+.cfi_restore   %r14
        mov     16(%rsp),%r13
+.cfi_restore   %r13
        mov     24(%rsp),%rbp
+.cfi_restore   %rbp
        mov     32(%rsp),%rbx
+.cfi_restore   %rbx
        lea     40(%rsp),%rsp
+.cfi_adjust_cfa_offset -40
 .Lenc_epilogue:
        ret
+.cfi_endproc
 .size  Camellia_EncryptBlock_Rounds,.-Camellia_EncryptBlock_Rounds
 
 .type  _x86_64_Camellia_encrypt,\@abi-omnipotent
@@ -239,11 +260,17 @@ Camellia_DecryptBlock:
 .align 16
 .Ldec_rounds:
 Camellia_DecryptBlock_Rounds:
+.cfi_startproc
        push    %rbx
+.cfi_push      %rbx
        push    %rbp
+.cfi_push      %rbp
        push    %r13
+.cfi_push      %r13
        push    %r14
+.cfi_push      %r14
        push    %r15
+.cfi_push      %r15
 .Ldec_prologue:
 
        #mov    %rsi,$inp               # put away arguments
@@ -275,13 +302,20 @@ Camellia_DecryptBlock_Rounds:
        mov     @S[3],12($out)
 
        mov     0(%rsp),%r15
+.cfi_restore   %r15
        mov     8(%rsp),%r14
+.cfi_restore   %r14
        mov     16(%rsp),%r13
+.cfi_restore   %r13
        mov     24(%rsp),%rbp
+.cfi_restore   %rbp
        mov     32(%rsp),%rbx
+.cfi_restore   %rbx
        lea     40(%rsp),%rsp
+.cfi_adjust_cfa_offset -40
 .Ldec_epilogue:
        ret
+.cfi_endproc
 .size  Camellia_DecryptBlock_Rounds,.-Camellia_DecryptBlock_Rounds
 
 .type  _x86_64_Camellia_decrypt,\@abi-omnipotent
@@ -401,14 +435,20 @@ $code.=<<___;
 .type  Camellia_Ekeygen,\@function,3
 .align 16
 Camellia_Ekeygen:
+.cfi_startproc
        push    %rbx
+.cfi_push      %rbx
        push    %rbp
+.cfi_push      %rbp
        push    %r13
+.cfi_push      %r13
        push    %r14
+.cfi_push      %r14
        push    %r15
+.cfi_push      %r15
 .Lkey_prologue:
 
-       mov     %rdi,$keyend            # put away arguments, keyBitLength
+       mov     %edi,${keyend}d         # put away arguments, keyBitLength
        mov     %rdx,$out               # keyTable
 
        mov     0(%rsi),@S[0]           # load 0-127 bits
@@ -565,13 +605,20 @@ $code.=<<___;
        mov     \$4,%eax
 .Ldone:
        mov     0(%rsp),%r15
+.cfi_restore   %r15
        mov     8(%rsp),%r14
+.cfi_restore   %r14
        mov     16(%rsp),%r13
+.cfi_restore   %r13
        mov     24(%rsp),%rbp
+.cfi_restore   %rbp
        mov     32(%rsp),%rbx
+.cfi_restore   %rbx
        lea     40(%rsp),%rsp
+.cfi_adjust_cfa_offset -40
 .Lkey_epilogue:
        ret
+.cfi_endproc
 .size  Camellia_Ekeygen,.-Camellia_Ekeygen
 ___
 }
@@ -629,17 +676,25 @@ $code.=<<___;
 .type  Camellia_cbc_encrypt,\@function,6
 .align 16
 Camellia_cbc_encrypt:
+.cfi_startproc
        cmp     \$0,%rdx
        je      .Lcbc_abort
        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
 .Lcbc_prologue:
 
        mov     %rsp,%rbp
+.cfi_def_cfa_register  %rbp
        sub     \$64,%rsp
        and     \$-64,%rsp
 
@@ -650,16 +705,17 @@ Camellia_cbc_encrypt:
        neg     %r10
        and     \$0x3C0,%r10
        sub     %r10,%rsp
-       add     \$8,%rsp                # 8 is reserved for callee's ra
+       #add    \$8,%rsp                # 8 is reserved for callee's ra
 
        mov     %rdi,$inp               # inp argument
        mov     %rsi,$out               # out argument
        mov     %r8,%rbx                # ivp argument
        mov     %rcx,$key               # key argument
-       mov     272(%rcx),$keyend       # grandRounds
+       mov     272(%rcx),${keyend}d    # grandRounds
 
        mov     %r8,$_ivp
        mov     %rbp,$_rsp
+.cfi_cfa_expression    $_rsp,deref,+56
 
 .Lcbc_body:
        lea     .LCamellia_SBOX(%rip),$Tbl
@@ -746,7 +802,7 @@ Camellia_cbc_encrypt:
        pushfq
        cld
        mov     $inp,%rsi
-       lea     $ivec,%rdi
+       lea     8+$ivec,%rdi
        .long   0x9066A4F3              # rep movsb
        popfq
 .Lcbc_enc_popf:
@@ -835,7 +891,7 @@ Camellia_cbc_encrypt:
 .Lcbc_dec_pushf:
        pushfq
        cld
-       lea     $ivec,%rsi
+       lea     8+$ivec,%rsi
        lea     ($out),%rdi
        .long   0x9066A4F3              # rep movsb
        popfq
@@ -848,18 +904,27 @@ Camellia_cbc_encrypt:
 .align 16
 .Lcbc_done:
        mov     $_rsp,%rcx
+.cfi_def_cfa   %rcx,56
        mov     0(%rcx),%r15
+.cfi_restore   %r15
        mov     8(%rcx),%r14
+.cfi_restore   %r14
        mov     16(%rcx),%r13
+.cfi_restore   %r13
        mov     24(%rcx),%r12
+.cfi_restore   %r12
        mov     32(%rcx),%rbp
+.cfi_restore   %rbp
        mov     40(%rcx),%rbx
+.cfi_restore   %rbx
        lea     48(%rcx),%rsp
+.cfi_def_cfa   %rsp,8
 .Lcbc_abort:
        ret
+.cfi_endproc
 .size  Camellia_cbc_encrypt,.-Camellia_cbc_encrypt
 
-.asciz "Camellia for x86_64 by <appro@openssl.org>"
+.asciz "Camellia for x86_64 by <appro\@openssl.org>"
 ___
 }