[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Thu Apr 2 07:37:59 UTC 2015


The branch master has been updated
       via  7b644df899d0c818488686affc0bfe2dfdd0d0c2 (commit)
       via  449e3f2601246e533a05ccf227375c1e15db2b55 (commit)
      from  11305038e904cdebd1c8882f6f508fe0dd14e349 (commit)


- Log -----------------------------------------------------------------
commit 7b644df899d0c818488686affc0bfe2dfdd0d0c2
Author: Andy Polyakov <appro at openssl.org>
Date:   Mon Mar 30 16:48:38 2015 +0200

    perlasm/arm-xlate.pl update (fix end-less loop and prepare for 32-bit iOS).
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

commit 449e3f2601246e533a05ccf227375c1e15db2b55
Author: Andy Polyakov <appro at openssl.org>
Date:   Mon Mar 30 16:47:57 2015 +0200

    Configure: android-arm facelift.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 Configurations/10-main.conf | 53 ++++++++++++++++++++++++++++++--
 crypto/perlasm/arm-xlate.pl | 73 ++++++++++++++++++++++++++++++---------------
 include/openssl/rand.h      |  3 ++
 3 files changed, 103 insertions(+), 26 deletions(-)

diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index 7cd109c..ab269ba 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -740,10 +740,35 @@
     },
 
 #### Android: linux-* but without pointers to headers and libs.
+    #
+    # It takes pair of prior-set environment variables to make it work:
+    #
+    # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<
+    # CROSS_COMPILE=<prefix>
+    #
+    # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
+    # For example to compile for ICS and ARM with NDK 10d, you'd:
+    #
+    # ANDROID_NDK=/some/where/android-ndk-10d
+    # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
+    # CROSS_COMPILE=arm-linux-adroideabi-
+    # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/
+    #
     "android" => {
         inherit_from     => [ "linux-generic32" ],
-        cflags           => "-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -Wall",
+        # Special note about unconditional -fPIC and -pie. The underlying
+        # reason is that Lollipop refuses to run non-PIE. But what about
+        # older systems and NDKs? -fPIC was never problem, so the only
+        # concern if -pie. Older toolchains, e.g. r4, appear to handle it
+        # and binaries turn mostly functional. "Mostly" means that oldest
+        # Androids, such as Froyo, fail to handle executable, but newer
+        # systems are perfectly capable of executing binaries targeting
+        # Froyo. Keep in mind that in the nutshell Android builds are
+        # about JNI, i.e. shared libraries, not applications.
+        cflags           => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack -Wall",
         debug_cflags     => "-O0 -g",
+        lflags           => "-pie%-ldl",
+        shared_cflag     => "",
     },
     "android-x86" => {
         inherit_from     => [ "android", asm("x86_asm") ],
@@ -751,8 +776,32 @@
         bn_ops           => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
         perlasm_scheme   => "android",
     },
-    "android-armv7" => {
+    ################################################################
+    # Contemporary Android applications can provide multiple JNI
+    # providers in .apk, targeting multiple architectures. Among
+    # them there is "place" for two ARM flavours: generic eabi and
+    # armv7-a/hard-float. However, it should be noted that OpenSSL's
+    # ability to engage NEON is not constrained by ABI choice, nor
+    # is your ability to call OpenSSL from your application code
+    # compiled with floating-point ABI other than default 'soft'.
+    # [Latter thanks to __attribute__((pcs("aapcs"))) declaration.]
+    # This means that choice of ARM libraries you provide in .apk
+    # is driven by application needs. For example if application
+    # itself benefits from NEON or is floating-point intensive, then
+    # it might be appropriate to provide both libraries. Otherwise
+    # just generic eabi would do. But in latter case it would be
+    # appropriate to
+    #
+    #   ./Configure android-armeabi -D__ARM_MAX_ARCH__=8
+    #
+    # in order to build "universal" binary and allow OpenSSL take
+    # advantage of NEON when it's available.
+    #
+    "android-armeabi" => {
         inherit_from     => [ "android", asm("armv4_asm") ],
+    },
+    "android-armv7" => {
+        inherit_from     => [ "android-armeabi" ],
         cflags           => sub { join (" ","-march=armv7-a", at _); },
     },
     "android-mips" => {
diff --git a/crypto/perlasm/arm-xlate.pl b/crypto/perlasm/arm-xlate.pl
index fd185e9..22dc7e4 100755
--- a/crypto/perlasm/arm-xlate.pl
+++ b/crypto/perlasm/arm-xlate.pl
@@ -18,6 +18,32 @@ my $arch = sub {
     if ($flavour =~ /linux/)	{ ".arch\t".join(',', at _); }
     else			{ ""; }
 };
+my $fpu = sub {
+    if ($flavour =~ /linux/)	{ ".fpu\t".join(',', at _); }
+    else			{ ""; }
+};
+my $hidden = sub {
+    if ($flavour =~ /ios/)	{ ".private_extern\t".join(',', at _); }
+    else			{ ".hidden\t".join(',', at _); }
+};
+my $comm = sub {
+    my @args = split(/,\s*/,shift);
+    my $name = @args[0];
+    my $global = \$GLOBALS{$name};
+    my $ret;
+
+    if ($flavour =~ /ios32/)	{
+	$ret = ".comm\t_$name, at args[1]\n";
+	$ret .= ".non_lazy_symbol_pointer\n";
+	$ret .= "$name:\n";
+	$ret .= ".indirect_symbol\t_$name\n";
+	$ret .= ".long\t0";
+	$name = "_$name";
+    } else			{ $ret = ".comm\t".join(',', at args); }
+
+    $$global = $name;
+    $ret;
+};
 my $globl = sub {
     my $name = shift;
     my $global = \$GLOBALS{$name};
@@ -64,44 +90,43 @@ sub range {
     join(",",map("$r$_$sfx",($start..$end)));
 }
 
-sub parse_args {
+sub expand_line {
   my $line = shift;
   my @ret = ();
 
     pos($line)=0;
 
-    while (1) {
-	if ($line =~ m/\G\[/gc) {
-	    $line =~ m/\G([^\]]+\][^,]*)\s*/g;
-	    push @ret,"[$1";
+    while ($line =~ m/\G[^@\/\{\"]*/g) {
+	if ($line =~ m/\G(@|\/\/|$)/gc) {
+	    last;
 	}
 	elsif ($line =~ m/\G\{/gc) {
-	    $line =~ m/\G([^\}]+\}[^,]*)\s*/g;
-	    my $arg = $1;
-	    $arg =~ s/([rdqv])([0-9]+)([^\-]*)\-\1([0-9]+)\3/range($1,$3,$2,$4)/ge;
-	    push @ret,"{$arg";
+	    my $saved_pos = pos($line);
+	    $line =~ s/\G([rdqv])([0-9]+)([^\-]*)\-\1([0-9]+)\3/range($1,$3,$2,$4)/e;
+	    pos($line) = $saved_pos;
+	    $line =~ m/\G[^\}]*\}/g;
 	}
-	elsif ($line =~ m/\G([^,]+)\s*/g) {
-	    push @ret,$1;
+	elsif ($line =~ m/\G\"/gc) {
+	    $line =~ m/\G[^\"]*\"/g;
 	}
-
-	last if ($line =~ m/\G$/gc);
-
-	$line =~ m/\G,\s*/g;
     }
 
-    map {my $s=$_;$s=~s/\b(\w+)/$GLOBALS{$1} or $1/ge;$s} @ret;
+    $line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
+
+    return $line;
 }
 
 while($line=<>) {
 
+    if ($line =~ m/^\s*(#|@|\/\/)/)	{ print $line; next; }
+
     $line =~ s|/\*.*\*/||;	# get rid of C-style comments...
     $line =~ s|^\s+||;		# ... and skip white spaces in beginning...
     $line =~ s|\s+$||;		# ... and at the end
 
     {
-	$line =~ s|[\b\.]L(\w+)|L$1|g;	# common denominator for Locallabel
-	$line =~ s|\bL(\w+)|\.L$1|g	if ($dotinlocallabels);
+	$line =~ s|[\b\.]L(\w{2,})|L$1|g;	# common denominator for Locallabel
+	$line =~ s|\bL(\w{2,})|\.L$1|g	if ($dotinlocallabels);
     }
 
     {
@@ -112,24 +137,24 @@ while($line=<>) {
 	}
     }
 
-    if ($line !~ m/^#/o) {
-	$line =~ s|^\s*(\.?)(\S+)\s*||o;
+    if ($line !~ m/^[#@]/) {
+	$line =~ s|^\s*(\.?)(\S+)\s*||;
 	my $c = $1; $c = "\t" if ($c eq "");
 	my $mnemonic = $2;
 	my $opcode;
-	if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/o) {
+	if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/) {
 	    $opcode = eval("\$$1_$2");
 	} else {
 	    $opcode = eval("\$$mnemonic");
 	}
 
-	my @args=parse_args($line);
+	my $arg=expand_line($line);
 
 	if (ref($opcode) eq 'CODE') {
-		$line = &$opcode(@args);
+		$line = &$opcode($arg);
 	} elsif ($mnemonic)         {
 		$line = $c.$mnemonic;
-		$line.= "\t".join(',', at args) if ($#args>=0);
+		$line.= "\t$arg" if ($arg);
 	}
     }
 
diff --git a/include/openssl/rand.h b/include/openssl/rand.h
index 14b4793..0086c07 100644
--- a/include/openssl/rand.h
+++ b/include/openssl/rand.h
@@ -99,6 +99,9 @@ int RAND_bytes(unsigned char *buf, int num);
 DECLARE_DEPRECATED(int RAND_pseudo_bytes(unsigned char *buf, int num));
 #endif
 void RAND_seed(const void *buf, int num);
+#if defined(__ANDROID__) && defined(__NDK_FPABI__)
+__NDK_FPABI__	/* __attribute__((pcs("aapcs"))) on ARM */
+#endif
 void RAND_add(const void *buf, int num, double entropy);
 int RAND_load_file(const char *file, long max_bytes);
 int RAND_write_file(const char *file);


More information about the openssl-commits mailing list