ARM64 assembly pack: make it Windows-friendly.
[openssl.git] / crypto / perlasm / arm-xlate.pl
index c00f54af1bdd6978a955673c25dc218f53903266..af6f7d31885abe16573f16c87a47e18054f8893b 100755 (executable)
@@ -1,11 +1,13 @@
 #! /usr/bin/env perl
 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
 #
-# Licensed under the OpenSSL license (the "License").  You may not use
+# Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
 
+use strict;
+
 my $flavour = shift;
 my $output = shift;
 open STDOUT,">$output" || die "can't open $output: $!";
@@ -26,6 +28,13 @@ my $fpu = sub {
     if ($flavour =~ /linux/)   { ".fpu\t".join(',',@_); }
     else                       { ""; }
 };
+my $rodata = sub {
+    SWITCH: for ($flavour) {
+       /linux/         && return ".section\t.rodata";
+       /ios/           && return ".section\t__TEXT,__const";
+       last;
+    }
+};
 my $hidden = sub {
     if ($flavour =~ /ios/)     { ".private_extern\t".join(',',@_); }
     else                       { ".hidden\t".join(',',@_); }
@@ -94,6 +103,12 @@ my $asciz = sub {
     {  "";     }
 };
 
+my $adrp = sub {
+    my ($args,$comment) = split(m|\s*//|,shift);
+    "\tadrp\t$args\@PAGE";
+} if ($flavour =~ /ios64/);
+
+
 sub range {
   my ($r,$sfx,$start,$end) = @_;
 
@@ -123,10 +138,14 @@ sub expand_line {
 
     $line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
 
+    if ($flavour =~ /ios64/) {
+       $line =~ s/#:lo12:(\w+)/$1\@PAGEOFF/;
+    }
+
     return $line;
 }
 
-while($line=<>) {
+while(my $line=<>) {
 
     if ($line =~ m/^\s*(#|@|\/\/)/)    { print $line; next; }