]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Finishing touch to perlasm update to make it work on OpenBSD
authorsashan <anedvedicky@gmail.com>
Mon, 29 Apr 2024 12:04:56 +0000 (14:04 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 14 Jan 2025 11:15:13 +0000 (12:15 +0100)
This changeset brings a finishing touch to stuff we got from botovoq@
Changes to `crypto/perlasm/arm-xlate.pl` deal with verious assembler
flavours to keep various assembler compilers happy.

We also need to keep original code for 32-bit flavour in
`crypto/aes/asm/aesv8-armx.pl`.

Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24137)

crypto/aes/asm/aesv8-armx.pl
crypto/perlasm/arm-xlate.pl

index 289210b2c6290d26f579552810d44c177e5fe9d5..b2abcd1869f1a6060ac1f8d7951998eb01b7b554 100755 (executable)
@@ -106,14 +106,21 @@ my ($zero,$rcon,$mask,$in0,$in1,$tmp,$key)=
        $flavour=~/64/? map("q$_",(0..6)) : map("q$_",(0..3,8..10));
 
 
+#
+# This file generates .s file for 64-bit and 32-bit CPUs.
+# We don't implement .rodata on 32-bit CPUs yet.
+#
+$code.=".rodata\n"     if ($flavour =~ /64/);
 $code.=<<___;
-.rodata
 .align 5
 .Lrcon:
 .long  0x01,0x01,0x01,0x01
 .long  0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d     // rotate-n-splat
 .long  0x1b,0x1b,0x1b,0x1b
-.previous
+___
+$code.=".previous\n"   if ($flavour =~ /64/);
+
+$code.=<<___;
 .globl ${prefix}_set_encrypt_key
 .type  ${prefix}_set_encrypt_key,%function
 .align 5
@@ -140,8 +147,15 @@ $code.=<<___;
        tst     $bits,#0x3f
        b.ne    .Lenc_key_abort
 
+___
+$code.=<<___   if ($flavour =~ /64/);
        adrp    $ptr,.Lrcon
        add     $ptr,$ptr,:lo12:.Lrcon
+___
+$code.=<<___   if ($flavour =~ /32/);
+       adr     $ptr,.Lrcon
+___
+$code.=<<___;
        cmp     $bits,#192
 
        veor    $zero,$zero,$zero
index 3b0dcad4139f90ddb091dfa4868f741341619e31..aef9595a5e0b7de7cc0eb4dd023e1ca957283eb7 100755 (executable)
@@ -116,9 +116,26 @@ my $asciz = sub {
 
 my $adrp = sub {
     my ($args,$comment) = split(m|\s*//|,shift);
-    "\tadrp\t$args\@PAGE";
-} if ($flavour =~ /ios64/);
-
+    if ($flavour =~ /ios64/) {
+        "\tadrp\t$args\@PAGE";
+    } elsif ($flavour =~ /linux/) {
+        #
+        # there seem to be two forms of 'addrp' instruction
+        # to calculate offset:
+       #    addrp      x3,x3,:lo12:Lrcon
+        # and alternate form:
+       #    addrp      x3,x3,:#lo12:Lrcon
+        # the '#' is mandatory for some compilers
+        # so make sure our asm always uses '#' here.
+        #
+        $args =~ s/(\w+)#?:lo2:(\.?\w+)/$1#:lo2:$2/;
+        if ($flavour =~ /linux32/) {
+            "\tadr\t$args";
+        } else {
+            "\tadrp\t$args";
+        }
+    }
+} if (($flavour =~ /ios64/) || ($flavour =~ /linux/));
 
 sub range {
   my ($r,$sfx,$start,$end) = @_;
@@ -150,7 +167,12 @@ sub expand_line {
     $line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
 
     if ($flavour =~ /ios64/) {
-       $line =~ s/#:lo12:(\w+)/$1\@PAGEOFF/;
+       $line =~ s/#?:lo12:(\w+)/$1\@PAGEOFF/;
+    } elsif($flavour =~ /linux/) {
+        #
+        # make '#' mandatory for :lo12: (similar to adrp above)
+        #
+       $line =~ s/#?:lo12:(\.?\w+)/\#:lo12:$1/;
     }
 
     return $line;