#! /usr/bin/env perl
-# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
#
# 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
################################################################
my $arch = sub {
if ($flavour =~ /linux/) { ".arch\t".join(',',@_); }
+ elsif ($flavour =~ /win64/) { ".arch\t".join(',',@_); }
else { ""; }
};
my $fpu = sub {
};
my $hidden = sub {
if ($flavour =~ /ios/) { ".private_extern\t".join(',',@_); }
+ elsif ($flavour =~ /win64/) { ""; }
else { ".hidden\t".join(',',@_); }
};
my $comm = sub {
"#endif";
}
}
+ elsif ($flavour =~ /win64/) { if (join(',',@_) =~ /(\w+),%function/) {
+ # See https://sourceware.org/binutils/docs/as/Pseudo-Ops.html
+ # Per https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#coff-symbol-table,
+ # the type for functions is 0x20, or 32.
+ ".def $1\n".
+ " .type 32\n".
+ ".endef";
+ }
+ }
else { ""; }
};
my $size = 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) = @_;
$line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
+ if ($flavour =~ /ios64/) {
+ $line =~ s/#:lo12:(\w+)/$1\@PAGEOFF/;
+ }
+
return $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 skip whitespace in beginning...
$line =~ s|\s+$||; # ... and at the end
{
}
{
- $line =~ s|(^[\.\w]+)\:\s*||;
- my $label = $1;
- if ($label) {
+ if ($line =~ s|(^[\.\w]+)\:\s*||) {
+ my $label = $1;
printf "%s:",($GLOBALS{$label} or $label);
}
}
}
}
+ # ldr REG, #VALUE psuedo-instruction - avoid clang issue with Neon registers
+ #
+ if ($line =~ /^\s*ldr\s+([qd]\d\d?)\s*,\s*=(\w+)/i) {
+ # Immediate load via literal pool into qN or DN - clang max is 2^32-1
+ my ($reg, $value) = ($1, $2);
+ # If $value is hex, 0x + 8 hex chars = 10 chars total will be okay
+ # If $value is decimal, 2^32 - 1 = 4294967295 will be okay (also 10 chars)
+ die("$line: immediate load via literal pool into $reg: value too large for clang - redo manually") if length($value) > 10;
+ }
+
print $line if ($line);
print "\n";
}
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";