diff options
| author | jsing <> | 2014-04-30 13:40:02 +0000 |
|---|---|---|
| committer | jsing <> | 2014-04-30 13:40:02 +0000 |
| commit | b8e088b53dabff9eeb33721c6fa4e60831bf9797 (patch) | |
| tree | 75932b21b0fece851ece3d9ad0c80de6a9ff65e2 /src/lib/libcrypto/camellia | |
| parent | 11a8133c7b915dcd4af9f7cf1c70b1179eeddf14 (diff) | |
| download | openbsd-b8e088b53dabff9eeb33721c6fa4e60831bf9797.tar.gz openbsd-b8e088b53dabff9eeb33721c6fa4e60831bf9797.tar.bz2 openbsd-b8e088b53dabff9eeb33721c6fa4e60831bf9797.zip | |
First pass at removing win64 support from the assembly generating Perl
scripts. We certainly do not need an identical copy of the win64
exception handler in each script (surely one copy would be sufficient).
ok miod@
Diffstat (limited to 'src/lib/libcrypto/camellia')
| -rw-r--r-- | src/lib/libcrypto/camellia/asm/cmll-x86_64.pl | 216 |
1 files changed, 1 insertions, 215 deletions
diff --git a/src/lib/libcrypto/camellia/asm/cmll-x86_64.pl b/src/lib/libcrypto/camellia/asm/cmll-x86_64.pl index 9f4b82fa48..a171c654b2 100644 --- a/src/lib/libcrypto/camellia/asm/cmll-x86_64.pl +++ b/src/lib/libcrypto/camellia/asm/cmll-x86_64.pl | |||
| @@ -33,8 +33,6 @@ $flavour = shift; | |||
| 33 | $output = shift; | 33 | $output = shift; |
| 34 | if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } | 34 | if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } |
| 35 | 35 | ||
| 36 | $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); | ||
| 37 | |||
| 38 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; | 36 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; |
| 39 | ( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or | 37 | ( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or |
| 40 | ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or | 38 | ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or |
| @@ -57,7 +55,7 @@ $inp="%r12"; | |||
| 57 | $out="%r13"; | 55 | $out="%r13"; |
| 58 | $key="%r14"; | 56 | $key="%r14"; |
| 59 | $keyend="%r15"; | 57 | $keyend="%r15"; |
| 60 | $arg0d=$win64?"%ecx":"%edi"; | 58 | $arg0d="%edi"; |
| 61 | 59 | ||
| 62 | # const unsigned int Camellia_SBOX[4][256]; | 60 | # const unsigned int Camellia_SBOX[4][256]; |
| 63 | # Well, sort of... Camellia_SBOX[0][] is interleaved with [1][], | 61 | # Well, sort of... Camellia_SBOX[0][] is interleaved with [1][], |
| @@ -864,218 +862,6 @@ Camellia_cbc_encrypt: | |||
| 864 | ___ | 862 | ___ |
| 865 | } | 863 | } |
| 866 | 864 | ||
| 867 | # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, | ||
| 868 | # CONTEXT *context,DISPATCHER_CONTEXT *disp) | ||
| 869 | if ($win64) { | ||
| 870 | $rec="%rcx"; | ||
| 871 | $frame="%rdx"; | ||
| 872 | $context="%r8"; | ||
| 873 | $disp="%r9"; | ||
| 874 | |||
| 875 | $code.=<<___; | ||
| 876 | .extern __imp_RtlVirtualUnwind | ||
| 877 | .type common_se_handler,\@abi-omnipotent | ||
| 878 | .align 16 | ||
| 879 | common_se_handler: | ||
| 880 | push %rsi | ||
| 881 | push %rdi | ||
| 882 | push %rbx | ||
| 883 | push %rbp | ||
| 884 | push %r12 | ||
| 885 | push %r13 | ||
| 886 | push %r14 | ||
| 887 | push %r15 | ||
| 888 | pushfq | ||
| 889 | lea -64(%rsp),%rsp | ||
| 890 | |||
| 891 | mov 120($context),%rax # pull context->Rax | ||
| 892 | mov 248($context),%rbx # pull context->Rip | ||
| 893 | |||
| 894 | mov 8($disp),%rsi # disp->ImageBase | ||
| 895 | mov 56($disp),%r11 # disp->HandlerData | ||
| 896 | |||
| 897 | mov 0(%r11),%r10d # HandlerData[0] | ||
| 898 | lea (%rsi,%r10),%r10 # prologue label | ||
| 899 | cmp %r10,%rbx # context->Rip<prologue label | ||
| 900 | jb .Lin_prologue | ||
| 901 | |||
| 902 | mov 152($context),%rax # pull context->Rsp | ||
| 903 | |||
| 904 | mov 4(%r11),%r10d # HandlerData[1] | ||
| 905 | lea (%rsi,%r10),%r10 # epilogue label | ||
| 906 | cmp %r10,%rbx # context->Rip>=epilogue label | ||
| 907 | jae .Lin_prologue | ||
| 908 | |||
| 909 | lea 40(%rax),%rax | ||
| 910 | mov -8(%rax),%rbx | ||
| 911 | mov -16(%rax),%rbp | ||
| 912 | mov -24(%rax),%r13 | ||
| 913 | mov -32(%rax),%r14 | ||
| 914 | mov -40(%rax),%r15 | ||
| 915 | mov %rbx,144($context) # restore context->Rbx | ||
| 916 | mov %rbp,160($context) # restore context->Rbp | ||
| 917 | mov %r13,224($context) # restore context->R13 | ||
| 918 | mov %r14,232($context) # restore context->R14 | ||
| 919 | mov %r15,240($context) # restore context->R15 | ||
| 920 | |||
| 921 | .Lin_prologue: | ||
| 922 | mov 8(%rax),%rdi | ||
| 923 | mov 16(%rax),%rsi | ||
| 924 | mov %rax,152($context) # restore context->Rsp | ||
| 925 | mov %rsi,168($context) # restore context->Rsi | ||
| 926 | mov %rdi,176($context) # restore context->Rdi | ||
| 927 | |||
| 928 | jmp .Lcommon_seh_exit | ||
| 929 | .size common_se_handler,.-common_se_handler | ||
| 930 | |||
| 931 | .type cbc_se_handler,\@abi-omnipotent | ||
| 932 | .align 16 | ||
| 933 | cbc_se_handler: | ||
| 934 | push %rsi | ||
| 935 | push %rdi | ||
| 936 | push %rbx | ||
| 937 | push %rbp | ||
| 938 | push %r12 | ||
| 939 | push %r13 | ||
| 940 | push %r14 | ||
| 941 | push %r15 | ||
| 942 | pushfq | ||
| 943 | lea -64(%rsp),%rsp | ||
| 944 | |||
| 945 | mov 120($context),%rax # pull context->Rax | ||
| 946 | mov 248($context),%rbx # pull context->Rip | ||
| 947 | |||
| 948 | lea .Lcbc_prologue(%rip),%r10 | ||
| 949 | cmp %r10,%rbx # context->Rip<.Lcbc_prologue | ||
| 950 | jb .Lin_cbc_prologue | ||
| 951 | |||
| 952 | lea .Lcbc_body(%rip),%r10 | ||
| 953 | cmp %r10,%rbx # context->Rip<.Lcbc_body | ||
| 954 | jb .Lin_cbc_frame_setup | ||
| 955 | |||
| 956 | mov 152($context),%rax # pull context->Rsp | ||
| 957 | |||
| 958 | lea .Lcbc_abort(%rip),%r10 | ||
| 959 | cmp %r10,%rbx # context->Rip>=.Lcbc_abort | ||
| 960 | jae .Lin_cbc_prologue | ||
| 961 | |||
| 962 | # handle pushf/popf in Camellia_cbc_encrypt | ||
| 963 | lea .Lcbc_enc_pushf(%rip),%r10 | ||
| 964 | cmp %r10,%rbx # context->Rip<=.Lcbc_enc_pushf | ||
| 965 | jbe .Lin_cbc_no_flag | ||
| 966 | lea 8(%rax),%rax | ||
| 967 | lea .Lcbc_enc_popf(%rip),%r10 | ||
| 968 | cmp %r10,%rbx # context->Rip<.Lcbc_enc_popf | ||
| 969 | jb .Lin_cbc_no_flag | ||
| 970 | lea -8(%rax),%rax | ||
| 971 | lea .Lcbc_dec_pushf(%rip),%r10 | ||
| 972 | cmp %r10,%rbx # context->Rip<=.Lcbc_dec_pushf | ||
| 973 | jbe .Lin_cbc_no_flag | ||
| 974 | lea 8(%rax),%rax | ||
| 975 | lea .Lcbc_dec_popf(%rip),%r10 | ||
| 976 | cmp %r10,%rbx # context->Rip<.Lcbc_dec_popf | ||
| 977 | jb .Lin_cbc_no_flag | ||
| 978 | lea -8(%rax),%rax | ||
| 979 | |||
| 980 | .Lin_cbc_no_flag: | ||
| 981 | mov 48(%rax),%rax # $_rsp | ||
| 982 | lea 48(%rax),%rax | ||
| 983 | |||
| 984 | .Lin_cbc_frame_setup: | ||
| 985 | mov -8(%rax),%rbx | ||
| 986 | mov -16(%rax),%rbp | ||
| 987 | mov -24(%rax),%r12 | ||
| 988 | mov -32(%rax),%r13 | ||
| 989 | mov -40(%rax),%r14 | ||
| 990 | mov -48(%rax),%r15 | ||
| 991 | mov %rbx,144($context) # restore context->Rbx | ||
| 992 | mov %rbp,160($context) # restore context->Rbp | ||
| 993 | mov %r12,216($context) # restore context->R12 | ||
| 994 | mov %r13,224($context) # restore context->R13 | ||
| 995 | mov %r14,232($context) # restore context->R14 | ||
| 996 | mov %r15,240($context) # restore context->R15 | ||
| 997 | |||
| 998 | .Lin_cbc_prologue: | ||
| 999 | mov 8(%rax),%rdi | ||
| 1000 | mov 16(%rax),%rsi | ||
| 1001 | mov %rax,152($context) # restore context->Rsp | ||
| 1002 | mov %rsi,168($context) # restore context->Rsi | ||
| 1003 | mov %rdi,176($context) # restore context->Rdi | ||
| 1004 | |||
| 1005 | .align 4 | ||
| 1006 | .Lcommon_seh_exit: | ||
| 1007 | |||
| 1008 | mov 40($disp),%rdi # disp->ContextRecord | ||
| 1009 | mov $context,%rsi # context | ||
| 1010 | mov \$`1232/8`,%ecx # sizeof(CONTEXT) | ||
| 1011 | .long 0xa548f3fc # cld; rep movsq | ||
| 1012 | |||
| 1013 | mov $disp,%rsi | ||
| 1014 | xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER | ||
| 1015 | mov 8(%rsi),%rdx # arg2, disp->ImageBase | ||
| 1016 | mov 0(%rsi),%r8 # arg3, disp->ControlPc | ||
| 1017 | mov 16(%rsi),%r9 # arg4, disp->FunctionEntry | ||
| 1018 | mov 40(%rsi),%r10 # disp->ContextRecord | ||
| 1019 | lea 56(%rsi),%r11 # &disp->HandlerData | ||
| 1020 | lea 24(%rsi),%r12 # &disp->EstablisherFrame | ||
| 1021 | mov %r10,32(%rsp) # arg5 | ||
| 1022 | mov %r11,40(%rsp) # arg6 | ||
| 1023 | mov %r12,48(%rsp) # arg7 | ||
| 1024 | mov %rcx,56(%rsp) # arg8, (NULL) | ||
| 1025 | call *__imp_RtlVirtualUnwind(%rip) | ||
| 1026 | |||
| 1027 | mov \$1,%eax # ExceptionContinueSearch | ||
| 1028 | lea 64(%rsp),%rsp | ||
| 1029 | popfq | ||
| 1030 | pop %r15 | ||
| 1031 | pop %r14 | ||
| 1032 | pop %r13 | ||
| 1033 | pop %r12 | ||
| 1034 | pop %rbp | ||
| 1035 | pop %rbx | ||
| 1036 | pop %rdi | ||
| 1037 | pop %rsi | ||
| 1038 | ret | ||
| 1039 | .size cbc_se_handler,.-cbc_se_handler | ||
| 1040 | |||
| 1041 | .section .pdata | ||
| 1042 | .align 4 | ||
| 1043 | .rva .LSEH_begin_Camellia_EncryptBlock_Rounds | ||
| 1044 | .rva .LSEH_end_Camellia_EncryptBlock_Rounds | ||
| 1045 | .rva .LSEH_info_Camellia_EncryptBlock_Rounds | ||
| 1046 | |||
| 1047 | .rva .LSEH_begin_Camellia_DecryptBlock_Rounds | ||
| 1048 | .rva .LSEH_end_Camellia_DecryptBlock_Rounds | ||
| 1049 | .rva .LSEH_info_Camellia_DecryptBlock_Rounds | ||
| 1050 | |||
| 1051 | .rva .LSEH_begin_Camellia_Ekeygen | ||
| 1052 | .rva .LSEH_end_Camellia_Ekeygen | ||
| 1053 | .rva .LSEH_info_Camellia_Ekeygen | ||
| 1054 | |||
| 1055 | .rva .LSEH_begin_Camellia_cbc_encrypt | ||
| 1056 | .rva .LSEH_end_Camellia_cbc_encrypt | ||
| 1057 | .rva .LSEH_info_Camellia_cbc_encrypt | ||
| 1058 | |||
| 1059 | .section .xdata | ||
| 1060 | .align 8 | ||
| 1061 | .LSEH_info_Camellia_EncryptBlock_Rounds: | ||
| 1062 | .byte 9,0,0,0 | ||
| 1063 | .rva common_se_handler | ||
| 1064 | .rva .Lenc_prologue,.Lenc_epilogue # HandlerData[] | ||
| 1065 | .LSEH_info_Camellia_DecryptBlock_Rounds: | ||
| 1066 | .byte 9,0,0,0 | ||
| 1067 | .rva common_se_handler | ||
| 1068 | .rva .Ldec_prologue,.Ldec_epilogue # HandlerData[] | ||
| 1069 | .LSEH_info_Camellia_Ekeygen: | ||
| 1070 | .byte 9,0,0,0 | ||
| 1071 | .rva common_se_handler | ||
| 1072 | .rva .Lkey_prologue,.Lkey_epilogue # HandlerData[] | ||
| 1073 | .LSEH_info_Camellia_cbc_encrypt: | ||
| 1074 | .byte 9,0,0,0 | ||
| 1075 | .rva cbc_se_handler | ||
| 1076 | ___ | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | $code =~ s/\`([^\`]*)\`/eval $1/gem; | 865 | $code =~ s/\`([^\`]*)\`/eval $1/gem; |
| 1080 | print $code; | 866 | print $code; |
| 1081 | close STDOUT; | 867 | close STDOUT; |
