From a285992763f3961f69a8d86bf7dfff020a08cef9 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 6 Dec 2015 22:02:39 +0100 Subject: [PATCH] ARMv4 assembly pack: allow Thumb2 even in iOS build, and engage it in most modules. Reviewed-by: Tim Hudson --- crypto/aes/asm/aes-armv4.pl | 1 + crypto/aes/asm/bsaes-armv7.pl | 1 + crypto/bn/asm/armv4-gf2m.pl | 2 +- crypto/bn/asm/armv4-mont.pl | 2 +- crypto/ec/asm/ecp_nistz256-armv4.pl | 2 +- crypto/modes/asm/ghash-armv4.pl | 2 +- crypto/perlasm/arm-xlate.pl | 6 ++++++ crypto/sha/asm/sha1-armv4-large.pl | 10 +++++----- crypto/sha/asm/sha256-armv4.pl | 4 ++-- crypto/sha/asm/sha512-armv4.pl | 2 +- 10 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crypto/aes/asm/aes-armv4.pl b/crypto/aes/asm/aes-armv4.pl index c3d166ff5f..fbe45975a5 100644 --- a/crypto/aes/asm/aes-armv4.pl +++ b/crypto/aes/asm/aes-armv4.pl @@ -75,6 +75,7 @@ $code=<<___; .thumb #else .code 32 +#undef __thumb2__ #endif .type AES_Te,%object diff --git a/crypto/aes/asm/bsaes-armv7.pl b/crypto/aes/asm/bsaes-armv7.pl index f9293d599b..03b8d825cd 100644 --- a/crypto/aes/asm/bsaes-armv7.pl +++ b/crypto/aes/asm/bsaes-armv7.pl @@ -731,6 +731,7 @@ $code.=<<___; .thumb #else .code 32 +# undef __thumb2__ #endif .type _bsaes_decrypt8,%function diff --git a/crypto/bn/asm/armv4-gf2m.pl b/crypto/bn/asm/armv4-gf2m.pl index 227581e10c..22aa4830f8 100644 --- a/crypto/bn/asm/armv4-gf2m.pl +++ b/crypto/bn/asm/armv4-gf2m.pl @@ -51,7 +51,7 @@ $code=<<___; #include "arm_arch.h" .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb #else diff --git a/crypto/bn/asm/armv4-mont.pl b/crypto/bn/asm/armv4-mont.pl index 48e523013f..7017ad5f20 100644 --- a/crypto/bn/asm/armv4-mont.pl +++ b/crypto/bn/asm/armv4-mont.pl @@ -91,7 +91,7 @@ $code=<<___; #include "arm_arch.h" .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb #else diff --git a/crypto/ec/asm/ecp_nistz256-armv4.pl b/crypto/ec/asm/ecp_nistz256-armv4.pl index aeeb190335..3a636eae6c 100755 --- a/crypto/ec/asm/ecp_nistz256-armv4.pl +++ b/crypto/ec/asm/ecp_nistz256-armv4.pl @@ -45,7 +45,7 @@ $code.=<<___; #include "arm_arch.h" .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb #else diff --git a/crypto/modes/asm/ghash-armv4.pl b/crypto/modes/asm/ghash-armv4.pl index 245ac921d2..0d5b8ef3a7 100644 --- a/crypto/modes/asm/ghash-armv4.pl +++ b/crypto/modes/asm/ghash-armv4.pl @@ -136,7 +136,7 @@ $code=<<___; #include "arm_arch.h" .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb #else diff --git a/crypto/perlasm/arm-xlate.pl b/crypto/perlasm/arm-xlate.pl index 81ceb3142c..ecd3198c44 100755 --- a/crypto/perlasm/arm-xlate.pl +++ b/crypto/perlasm/arm-xlate.pl @@ -66,6 +66,12 @@ my $extern = sub { }; my $type = sub { if ($flavour =~ /linux/) { ".type\t".join(',',@_); } + elsif ($flavour =~ /ios32/) { if (join(',',@_) =~ /(\w+),%function/) { + "#ifdef __thumb2__\n". + ".thumb_func $1\n". + "#endif"; + } + } else { ""; } }; my $size = sub { diff --git a/crypto/sha/asm/sha1-armv4-large.pl b/crypto/sha/asm/sha1-armv4-large.pl index 9d34e04f7b..e1bb92bad7 100644 --- a/crypto/sha/asm/sha1-armv4-large.pl +++ b/crypto/sha/asm/sha1-armv4-large.pl @@ -181,7 +181,7 @@ $code=<<___; #include "arm_arch.h" .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb #else @@ -222,7 +222,7 @@ for($i=0;$i<5;$i++) { &BODY_00_15(@V); unshift(@V,pop(@V)); } $code.=<<___; -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) mov $t3,sp teq $Xi,$t3 #else @@ -246,7 +246,7 @@ for($i=0;$i<5;$i++) { &BODY_20_39(@V); unshift(@V,pop(@V)); } $code.=<<___; -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) mov $t3,sp teq $Xi,$t3 #else @@ -263,7 +263,7 @@ for($i=0;$i<5;$i++) { &BODY_40_59(@V); unshift(@V,pop(@V)); } $code.=<<___; -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) mov $t3,sp teq $Xi,$t3 #else @@ -610,7 +610,7 @@ my ($W0,$W1,$ABCD_SAVE)=map("q$_",(12..14)); $code.=<<___; #if __ARM_MAX_ARCH__>=7 -# if defined(__thumb2__) && !defined(__APPLE__) +# if defined(__thumb2__) # define INST(a,b,c,d) .byte c,d|0xf,a,b # else # define INST(a,b,c,d) .byte a,b,c,d|0x10 diff --git a/crypto/sha/asm/sha256-armv4.pl b/crypto/sha/asm/sha256-armv4.pl index c65073b7f9..b6b39dcbbb 100644 --- a/crypto/sha/asm/sha256-armv4.pl +++ b/crypto/sha/asm/sha256-armv4.pl @@ -175,7 +175,7 @@ $code=<<___; #endif .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb # define adrl adr @@ -595,7 +595,7 @@ my $Ktbl="r3"; $code.=<<___; #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) -# if defined(__thumb2__) && !defined(__APPLE__) +# if defined(__thumb2__) # define INST(a,b,c,d) .byte c,d|0xc,a,b # else # define INST(a,b,c,d) .byte a,b,c,d diff --git a/crypto/sha/asm/sha512-armv4.pl b/crypto/sha/asm/sha512-armv4.pl index a83d6772c8..56bb9fddff 100644 --- a/crypto/sha/asm/sha512-armv4.pl +++ b/crypto/sha/asm/sha512-armv4.pl @@ -212,7 +212,7 @@ $code=<<___; #endif .text -#if defined(__thumb2__) && !defined(__APPLE__) +#if defined(__thumb2__) .syntax unified .thumb # define adrl adr