From ad8bd4ece8b4d03b21d9334ae4565283561e109d Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Thu, 22 Nov 2007 20:51:48 +0000 Subject: [PATCH] Combat [bogus] relocations in some assember modules. --- crypto/aes/asm/aes-586.pl | 31 +++++++++++++------------------ crypto/perlasm/x86unix.pl | 17 ++++++++++------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/crypto/aes/asm/aes-586.pl b/crypto/aes/asm/aes-586.pl index b09bf0231..5eaced508 100755 --- a/crypto/aes/asm/aes-586.pl +++ b/crypto/aes/asm/aes-586.pl @@ -2657,12 +2657,10 @@ sub enckey() &xor ("eax",&DWP(1024-128,$tbl,"ecx",4)); # rcon } -# int AES_set_encrypt_key(const unsigned char *userKey, const int bits, -# AES_KEY *key) &public_label("AES_Te"); -&function_begin("AES_set_encrypt_key"); - &mov ("esi",&wparam(0)); # user supplied key - &mov ("edi",&wparam(2)); # private key schedule +&function_begin("_x86_AES_set_encrypt_key"); + &mov ("esi",&wparam(1)); # user supplied key + &mov ("edi",&wparam(3)); # private key schedule &test ("esi",-1); &jz (&label("badpointer")); @@ -2685,7 +2683,7 @@ sub enckey() &mov ("ecx",&DWP(192-128,$tbl)); &mov ("edx",&DWP(224-128,$tbl)); - &mov ("ecx",&wparam(1)); # number of bits in key + &mov ("ecx",&wparam(2)); # number of bits in key &cmp ("ecx",128); &je (&label("10rounds")); &cmp ("ecx",192); @@ -2862,7 +2860,14 @@ sub enckey() &set_label("badpointer"); &mov ("eax",-1); &set_label("exit"); -&function_end("AES_set_encrypt_key"); +&function_end("_x86_AES_set_encrypt_key"); + +# int AES_set_encrypt_key(const unsigned char *userKey, const int bits, +# AES_KEY *key) +&function_begin_B("AES_set_encrypt_key"); + &call ("_x86_AES_set_encrypt_key"); + &ret (); +&function_end_B("AES_set_encrypt_key"); sub deckey() { my ($i,$key,$tp1,$tp2,$tp4,$tp8) = @_; @@ -2921,18 +2926,8 @@ sub deckey() # int AES_set_decrypt_key(const unsigned char *userKey, const int bits, # AES_KEY *key) -&public_label("AES_Td"); -&public_label("AES_Te"); &function_begin_B("AES_set_decrypt_key"); - &mov ("eax",&wparam(0)); - &mov ("ecx",&wparam(1)); - &mov ("edx",&wparam(2)); - &sub ("esp",12); - &mov (&DWP(0,"esp"),"eax"); - &mov (&DWP(4,"esp"),"ecx"); - &mov (&DWP(8,"esp"),"edx"); - &call ("AES_set_encrypt_key"); - &add ("esp",12); + &call ("_x86_AES_set_encrypt_key"); &cmp ("eax",0); &je (&label("proceed")); &ret (); diff --git a/crypto/perlasm/x86unix.pl b/crypto/perlasm/x86unix.pl index 8e3e4bd38..eb8d76203 100644 --- a/crypto/perlasm/x86unix.pl +++ b/crypto/perlasm/x86unix.pl @@ -115,12 +115,14 @@ sub ::file sub ::function_begin_B { my($func,$extra)=@_; - my $tmp; + my $begin; &::external_label($func); + $label{$func} = $begin = "${dot}L_${func}_begin"; $func=$under.$func; - push(@out,".text\n.globl\t$func\n"); + push(@out,".text\n"); + push(@out,".globl\t$func\n") if ($func !~ /^${under}_/); if ($::coff) { push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } elsif ($::aout and !$::pic) @@ -129,18 +131,19 @@ sub ::function_begin_B { push(@out,".type $func,\@function\n"); } push(@out,".align\t$align\n"); push(@out,"$func:\n"); + push(@out,"$begin:\n"); $::stack=4; } sub ::function_end_B { my($func)=@_; + my $i; - $func=$under.$func; push(@out,"${dot}L_${func}_end:\n"); if ($::elf) - { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); } + { push(@out,".size\t$under$func,${dot}L_${func}_end-${dot}L_${func}_begin\n"); } $::stack=0; - %label=(); + foreach $i (keys %label) { delete $label{$i} if ($label{$i} =~ /^${dot}L[0-9]{3}/); } } sub ::comment @@ -162,8 +165,8 @@ sub ::comment sub islabel # see is argument is a known label { my $i; - foreach $i (%label) { return $label{$i} if ($label{$i} eq $_[0]); } - undef; + foreach $i (values %label) { return $i if ($i eq $_[0]); } + $label{$_[0]}; # can be undef } sub ::external_label { push(@labels,@_); }