RPM build fix (reverted CI changes which will need to be un-reverted or made conditional) and vendor Rust dependencies to make builds much faster in any CI system.
This commit is contained in:
233
zeroidc/vendor/ring/crypto/perlasm/arm-xlate.pl
vendored
Normal file
233
zeroidc/vendor/ring/crypto/perlasm/arm-xlate.pl
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
#! /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
|
||||
# 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: $!";
|
||||
|
||||
$flavour = "linux32" if (!$flavour or $flavour eq "void");
|
||||
|
||||
my %GLOBALS;
|
||||
my $dotinlocallabels=($flavour=~/linux/)?1:0;
|
||||
|
||||
################################################################
|
||||
# directives which need special treatment on different platforms
|
||||
################################################################
|
||||
my $arch = sub {
|
||||
if ($flavour =~ /linux/) { ".arch\t".join(',',@_); }
|
||||
else { ""; }
|
||||
};
|
||||
my $fpu = sub {
|
||||
if ($flavour =~ /linux/) { ".fpu\t".join(',',@_); }
|
||||
else { ""; }
|
||||
};
|
||||
my $hidden = sub {
|
||||
if ($flavour =~ /ios/) { ".private_extern\t".join(',',@_); }
|
||||
else { ".hidden\t".join(',',@_); }
|
||||
};
|
||||
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,@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(',',@args); }
|
||||
|
||||
$$global = $name;
|
||||
$ret;
|
||||
};
|
||||
my $globl = sub {
|
||||
my $name = shift;
|
||||
my $global = \$GLOBALS{$name};
|
||||
my $ret;
|
||||
|
||||
SWITCH: for ($flavour) {
|
||||
/ios/ && do { $name = "_$name";
|
||||
last;
|
||||
};
|
||||
}
|
||||
|
||||
$ret = ".globl $name\n";
|
||||
# All symbols in assembly files are hidden.
|
||||
$ret .= &$hidden($name);
|
||||
$$global = $name;
|
||||
$ret;
|
||||
};
|
||||
my $global = $globl;
|
||||
my $extern = sub {
|
||||
&$globl(@_);
|
||||
return; # return nothing
|
||||
};
|
||||
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 {
|
||||
if ($flavour =~ /linux/) { ".size\t".join(',',@_); }
|
||||
else { ""; }
|
||||
};
|
||||
my $inst = sub {
|
||||
if ($flavour =~ /linux/) { ".inst\t".join(',',@_); }
|
||||
else { ".long\t".join(',',@_); }
|
||||
};
|
||||
my $asciz = sub {
|
||||
my $line = join(",",@_);
|
||||
if ($line =~ /^"(.*)"$/)
|
||||
{ ".byte " . join(",",unpack("C*",$1),0) . "\n.align 2"; }
|
||||
else
|
||||
{ ""; }
|
||||
};
|
||||
my $section = sub {
|
||||
if ($flavour =~ /ios/) {
|
||||
if ($_[0] eq ".rodata") {
|
||||
return ".section\t__TEXT,__const";
|
||||
}
|
||||
die "Unknown section name $_[0]";
|
||||
} else {
|
||||
return ".section\t" . join(",", @_);
|
||||
}
|
||||
};
|
||||
|
||||
sub range {
|
||||
my ($r,$sfx,$start,$end) = @_;
|
||||
|
||||
join(",",map("$r$_$sfx",($start..$end)));
|
||||
}
|
||||
|
||||
sub expand_line {
|
||||
my $line = shift;
|
||||
my @ret = ();
|
||||
|
||||
pos($line)=0;
|
||||
|
||||
while ($line =~ m/\G[^@\/\{\"]*/g) {
|
||||
if ($line =~ m/\G(@|\/\/|$)/gc) {
|
||||
last;
|
||||
}
|
||||
elsif ($line =~ m/\G\{/gc) {
|
||||
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\"/gc) {
|
||||
$line =~ m/\G[^\"]*\"/g;
|
||||
}
|
||||
}
|
||||
|
||||
$line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
print <<___;
|
||||
// This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
// source tree. Do not edit by hand.
|
||||
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM)
|
||||
___
|
||||
|
||||
print "#if defined(__arm__)\n" if ($flavour eq "linux32");
|
||||
print "#if defined(__aarch64__)\n" if ($flavour eq "linux64");
|
||||
|
||||
while(my $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
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
my $copy = $line;
|
||||
# Also remove line comments.
|
||||
$copy =~ s|//.*||;
|
||||
if ($copy =~ /\b[wx]18\b/) {
|
||||
die "r18 is reserved by the platform and may not be used.";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
$line =~ s|[\b\.]L(\w{2,})|L$1|g; # common denominator for Locallabel
|
||||
$line =~ s|\bL(\w{2,})|\.L$1|g if ($dotinlocallabels);
|
||||
}
|
||||
|
||||
{
|
||||
$line =~ s|(^[\.\w]+)\:\s*||;
|
||||
my $label = $1;
|
||||
if ($label) {
|
||||
printf "%s:",($GLOBALS{$label} or $label);
|
||||
}
|
||||
}
|
||||
|
||||
if ($line !~ m/^[#@]/) {
|
||||
$line =~ s|^\s*(\.?)(\S+)\s*||;
|
||||
my $c = $1; $c = "\t" if ($c eq "");
|
||||
my $mnemonic = $2;
|
||||
my $opcode;
|
||||
if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/) {
|
||||
$opcode = eval("\$$1_$2");
|
||||
} else {
|
||||
$opcode = eval("\$$mnemonic");
|
||||
}
|
||||
|
||||
if ($flavour =~ /ios/) {
|
||||
# Mach-O and ELF use different syntax for these relocations. Note
|
||||
# that we require :pg_hi21: to be explicitly listed. It is normally
|
||||
# optional with adrp instructions.
|
||||
$line =~ s|:pg_hi21:(\w+)|\1\@PAGE|;
|
||||
$line =~ s|:lo12:(\w+)|\1\@PAGEOFF|;
|
||||
} else {
|
||||
# Clang's integrated assembly does not support the optional
|
||||
# :pg_hi21: markers, so erase them.
|
||||
$line =~ s|:pg_hi21:||;
|
||||
}
|
||||
|
||||
my $arg=expand_line($line);
|
||||
|
||||
if (ref($opcode) eq 'CODE') {
|
||||
$line = &$opcode($arg);
|
||||
} elsif ($mnemonic) {
|
||||
$line = $c.$mnemonic;
|
||||
$line.= "\t$arg" if ($arg ne "");
|
||||
}
|
||||
}
|
||||
|
||||
print $line if ($line);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print "#endif\n" if ($flavour eq "linux32" || $flavour eq "linux64");
|
||||
print "#endif // !OPENSSL_NO_ASM\n";
|
||||
|
||||
# See https://www.airs.com/blog/archives/518.
|
||||
print ".section\t.note.GNU-stack,\"\",\%progbits\n" if ($flavour =~ /linux/);
|
||||
|
||||
close STDOUT;
|
||||
1488
zeroidc/vendor/ring/crypto/perlasm/x86_64-xlate.pl
vendored
Normal file
1488
zeroidc/vendor/ring/crypto/perlasm/x86_64-xlate.pl
vendored
Normal file
File diff suppressed because it is too large
Load Diff
327
zeroidc/vendor/ring/crypto/perlasm/x86asm.pl
vendored
Normal file
327
zeroidc/vendor/ring/crypto/perlasm/x86asm.pl
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
|
||||
# require 'x86asm.pl';
|
||||
# &asm_init(<flavor>[,$i386only]);
|
||||
# &function_begin("foo");
|
||||
# ...
|
||||
# &function_end("foo");
|
||||
# &asm_finish
|
||||
|
||||
$out=();
|
||||
$i386=0;
|
||||
|
||||
# AUTOLOAD is this context has quite unpleasant side effect, namely
|
||||
# that typos in function calls effectively go to assembler output,
|
||||
# but on the pros side we don't have to implement one subroutine per
|
||||
# each opcode...
|
||||
sub ::AUTOLOAD
|
||||
{ my $opcode = $AUTOLOAD;
|
||||
|
||||
die "more than 4 arguments passed to $opcode" if ($#_>3);
|
||||
|
||||
$opcode =~ s/.*:://;
|
||||
if ($opcode =~ /^push/) { $stack+=4; }
|
||||
elsif ($opcode =~ /^pop/) { $stack-=4; }
|
||||
|
||||
&generic($opcode,@_) or die "undefined subroutine \&$AUTOLOAD";
|
||||
}
|
||||
|
||||
sub ::emit
|
||||
{ my $opcode=shift;
|
||||
|
||||
if ($#_==-1) { push(@out,"\t$opcode\n"); }
|
||||
else { push(@out,"\t$opcode\t".join(',',@_)."\n"); }
|
||||
}
|
||||
|
||||
sub ::LB
|
||||
{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'";
|
||||
$1."l";
|
||||
}
|
||||
sub ::HB
|
||||
{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'high byte'";
|
||||
$1."h";
|
||||
}
|
||||
sub ::stack_push{ my $num=$_[0]*4; $stack+=$num; &sub("esp",$num); }
|
||||
sub ::stack_pop { my $num=$_[0]*4; $stack-=$num; &add("esp",$num); }
|
||||
sub ::blindpop { &pop($_[0]); $stack+=4; }
|
||||
sub ::wparam { &DWP($stack+4*$_[0],"esp"); }
|
||||
sub ::swtmp { &DWP(4*$_[0],"esp"); }
|
||||
|
||||
sub ::bswap
|
||||
{ if ($i386) # emulate bswap for i386
|
||||
{ &comment("bswap @_");
|
||||
&xchg(&HB(@_),&LB(@_));
|
||||
&ror (@_,16);
|
||||
&xchg(&HB(@_),&LB(@_));
|
||||
}
|
||||
else
|
||||
{ &generic("bswap",@_); }
|
||||
}
|
||||
# These are made-up opcodes introduced over the years essentially
|
||||
# by ignorance, just alias them to real ones...
|
||||
sub ::movb { &mov(@_); }
|
||||
sub ::xorb { &xor(@_); }
|
||||
sub ::rotl { &rol(@_); }
|
||||
sub ::rotr { &ror(@_); }
|
||||
sub ::exch { &xchg(@_); }
|
||||
sub ::halt { &hlt; }
|
||||
sub ::movz { &movzx(@_); }
|
||||
sub ::pushf { &pushfd; }
|
||||
sub ::popf { &popfd; }
|
||||
|
||||
# 3 argument instructions
|
||||
sub ::movq
|
||||
{ my($p1,$p2,$optimize)=@_;
|
||||
|
||||
if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
|
||||
# movq between mmx registers can sink Intel CPUs
|
||||
{ &::pshufw($p1,$p2,0xe4); }
|
||||
else
|
||||
{ &::generic("movq",@_); }
|
||||
}
|
||||
|
||||
# SSE>2 instructions
|
||||
my %regrm = ( "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3,
|
||||
"esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7 );
|
||||
sub ::pextrd
|
||||
{ my($dst,$src,$imm)=@_;
|
||||
if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/)
|
||||
{ &::data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm); }
|
||||
else
|
||||
{ &::generic("pextrd",@_); }
|
||||
}
|
||||
|
||||
sub ::pinsrd
|
||||
{ my($dst,$src,$imm)=@_;
|
||||
if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/)
|
||||
{ &::data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm); }
|
||||
else
|
||||
{ &::generic("pinsrd",@_); }
|
||||
}
|
||||
|
||||
sub ::pshufb
|
||||
{ my($dst,$src)=@_;
|
||||
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
||||
{ &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2); }
|
||||
else
|
||||
{ &::generic("pshufb",@_); }
|
||||
}
|
||||
|
||||
sub ::palignr
|
||||
{ my($dst,$src,$imm)=@_;
|
||||
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
||||
{ &::data_byte(0x66,0x0f,0x3a,0x0f,0xc0|($1<<3)|$2,$imm); }
|
||||
else
|
||||
{ &::generic("palignr",@_); }
|
||||
}
|
||||
|
||||
sub ::pclmulqdq
|
||||
{ my($dst,$src,$imm)=@_;
|
||||
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
||||
{ &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); }
|
||||
else
|
||||
{ &::generic("pclmulqdq",@_); }
|
||||
}
|
||||
|
||||
sub ::rdrand
|
||||
{ my ($dst)=@_;
|
||||
if ($dst =~ /(e[a-dsd][ixp])/)
|
||||
{ &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
|
||||
else
|
||||
{ &::generic("rdrand",@_); }
|
||||
}
|
||||
|
||||
sub ::rdseed
|
||||
{ my ($dst)=@_;
|
||||
if ($dst =~ /(e[a-dsd][ixp])/)
|
||||
{ &::data_byte(0x0f,0xc7,0xf8|$regrm{$dst}); }
|
||||
else
|
||||
{ &::generic("rdrand",@_); }
|
||||
}
|
||||
|
||||
sub rxb {
|
||||
local *opcode=shift;
|
||||
my ($dst,$src1,$src2,$rxb)=@_;
|
||||
|
||||
$rxb|=0x7<<5;
|
||||
$rxb&=~(0x04<<5) if($dst>=8);
|
||||
$rxb&=~(0x01<<5) if($src1>=8);
|
||||
$rxb&=~(0x02<<5) if($src2>=8);
|
||||
push @opcode,$rxb;
|
||||
}
|
||||
|
||||
sub ::vprotd
|
||||
{ my $args=join(',',@_);
|
||||
if ($args =~ /xmm([0-7]),xmm([0-7]),([x0-9a-f]+)/)
|
||||
{ my @opcode=(0x8f);
|
||||
rxb(\@opcode,$1,$2,-1,0x08);
|
||||
push @opcode,0x78,0xc2;
|
||||
push @opcode,0xc0|($2&7)|(($1&7)<<3); # ModR/M
|
||||
my $c=$3;
|
||||
push @opcode,$c=~/^0/?oct($c):$c;
|
||||
&::data_byte(@opcode);
|
||||
}
|
||||
else
|
||||
{ &::generic("vprotd",@_); }
|
||||
}
|
||||
|
||||
sub ::endbranch
|
||||
{
|
||||
&::data_byte(0xf3,0x0f,0x1e,0xfb);
|
||||
}
|
||||
|
||||
# label management
|
||||
$lbdecor="L"; # local label decoration, set by package
|
||||
$label="000";
|
||||
|
||||
sub ::islabel # see is argument is a known label
|
||||
{ my $i;
|
||||
foreach $i (values %label) { return $i if ($i eq $_[0]); }
|
||||
$label{$_[0]}; # can be undef
|
||||
}
|
||||
|
||||
sub ::label # instantiate a function-scope label
|
||||
{ if (!defined($label{$_[0]}))
|
||||
{ $label{$_[0]}="${lbdecor}${label}${_[0]}"; $label++; }
|
||||
$label{$_[0]};
|
||||
}
|
||||
|
||||
sub ::LABEL # instantiate a file-scope label
|
||||
{ $label{$_[0]}=$_[1] if (!defined($label{$_[0]}));
|
||||
$label{$_[0]};
|
||||
}
|
||||
|
||||
sub ::static_label { &::LABEL($_[0],$lbdecor.$_[0]); }
|
||||
|
||||
sub ::set_label_B { push(@out,"@_:\n"); }
|
||||
sub ::set_label
|
||||
{ my $label=&::label($_[0]);
|
||||
&::align($_[1]) if ($_[1]>1);
|
||||
&::set_label_B($label);
|
||||
$label;
|
||||
}
|
||||
|
||||
sub ::wipe_labels # wipes function-scope labels
|
||||
{ foreach $i (keys %label)
|
||||
{ delete $label{$i} if ($label{$i} =~ /^\Q${lbdecor}\E[0-9]{3}/); }
|
||||
}
|
||||
|
||||
# subroutine management
|
||||
sub ::function_begin
|
||||
{ &function_begin_B(@_);
|
||||
$stack=4;
|
||||
&push("ebp");
|
||||
&push("ebx");
|
||||
&push("esi");
|
||||
&push("edi");
|
||||
}
|
||||
|
||||
sub ::function_end
|
||||
{ &pop("edi");
|
||||
&pop("esi");
|
||||
&pop("ebx");
|
||||
&pop("ebp");
|
||||
&ret();
|
||||
&function_end_B(@_);
|
||||
$stack=0;
|
||||
&wipe_labels();
|
||||
}
|
||||
|
||||
sub ::function_end_A
|
||||
{ &pop("edi");
|
||||
&pop("esi");
|
||||
&pop("ebx");
|
||||
&pop("ebp");
|
||||
&ret();
|
||||
$stack+=16; # readjust esp as if we didn't pop anything
|
||||
}
|
||||
|
||||
sub ::asciz
|
||||
{ my @str=unpack("C*",shift);
|
||||
push @str,0;
|
||||
while ($#str>15) {
|
||||
&data_byte(@str[0..15]);
|
||||
foreach (0..15) { shift @str; }
|
||||
}
|
||||
&data_byte(@str) if (@str);
|
||||
}
|
||||
|
||||
sub ::asm_finish
|
||||
{ &file_end();
|
||||
my $comment = "#";
|
||||
$comment = ";" if ($win32);
|
||||
print <<___;
|
||||
$comment This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
$comment source tree. Do not edit by hand.
|
||||
|
||||
___
|
||||
if ($win32) {
|
||||
print <<___ unless $masm;
|
||||
%ifdef BORINGSSL_PREFIX
|
||||
%include "boringssl_prefix_symbols_nasm.inc"
|
||||
%endif
|
||||
___
|
||||
} else {
|
||||
print <<___;
|
||||
#if defined(__i386__)
|
||||
#if defined(BORINGSSL_PREFIX)
|
||||
#include <boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
___
|
||||
}
|
||||
print @out;
|
||||
print "#endif\n" unless ($win32);
|
||||
# See https://www.airs.com/blog/archives/518.
|
||||
print ".section\t.note.GNU-stack,\"\",\@progbits\n" if ($elf);
|
||||
}
|
||||
|
||||
sub ::asm_init
|
||||
{ my ($type,$cpu)=@_;
|
||||
|
||||
$i386=$cpu;
|
||||
|
||||
$elf=$cpp=$coff=$aout=$macosx=$win32=$mwerks=$android=0;
|
||||
if (($type eq "elf"))
|
||||
{ $elf=1; require "x86gas.pl"; }
|
||||
elsif (($type eq "elf-1"))
|
||||
{ $elf=-1; require "x86gas.pl"; }
|
||||
elsif (($type eq "a\.out"))
|
||||
{ $aout=1; require "x86gas.pl"; }
|
||||
elsif (($type eq "coff" or $type eq "gaswin"))
|
||||
{ $coff=1; require "x86gas.pl"; }
|
||||
elsif (($type eq "win32n"))
|
||||
{ $win32=1; require "x86nasm.pl"; }
|
||||
elsif (($type eq "win32"))
|
||||
{ $win32=1; $masm=1; require "x86masm.pl"; }
|
||||
elsif (($type eq "macosx"))
|
||||
{ $aout=1; $macosx=1; require "x86gas.pl"; }
|
||||
elsif (($type eq "android"))
|
||||
{ $elf=1; $android=1; require "x86gas.pl"; }
|
||||
else
|
||||
{ print STDERR <<"EOF";
|
||||
Pick one target type from
|
||||
elf - Linux, FreeBSD, Solaris x86, etc.
|
||||
a.out - DJGPP, elder OpenBSD, etc.
|
||||
coff - GAS/COFF such as Win32 targets
|
||||
win32n - Windows 95/Windows NT NASM format
|
||||
macosx - Mac OS X
|
||||
EOF
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$pic=0;
|
||||
for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
|
||||
|
||||
&file();
|
||||
}
|
||||
|
||||
sub ::hidden {}
|
||||
|
||||
1;
|
||||
270
zeroidc/vendor/ring/crypto/perlasm/x86gas.pl
vendored
Normal file
270
zeroidc/vendor/ring/crypto/perlasm/x86gas.pl
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
|
||||
package x86gas;
|
||||
|
||||
*out=\@::out;
|
||||
|
||||
$::lbdecor=$::aout?"L":".L"; # local label decoration
|
||||
$nmdecor=($::aout or $::coff)?"_":""; # external name decoration
|
||||
|
||||
$initseg="";
|
||||
|
||||
$align=16;
|
||||
$align=log($align)/log(2) if ($::aout);
|
||||
$com_start="#" if ($::aout or $::coff);
|
||||
|
||||
sub opsize()
|
||||
{ my $reg=shift;
|
||||
if ($reg =~ m/^%e/o) { "l"; }
|
||||
elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; }
|
||||
elsif ($reg =~ m/^%[yxm]/o) { undef; }
|
||||
else { "w"; }
|
||||
}
|
||||
|
||||
# swap arguments;
|
||||
# expand opcode with size suffix;
|
||||
# prefix numeric constants with $;
|
||||
sub ::generic
|
||||
{ my($opcode,@arg)=@_;
|
||||
my($suffix,$dst,$src);
|
||||
|
||||
@arg=reverse(@arg);
|
||||
|
||||
for (@arg)
|
||||
{ s/^(\*?)(e?[a-dsixphl]{2})$/$1%$2/o; # gp registers
|
||||
s/^([xy]?mm[0-7])$/%$1/o; # xmm/mmx registers
|
||||
s/^(\-?[0-9]+)$/\$$1/o; # constants
|
||||
s/^(\-?0x[0-9a-f]+)$/\$$1/o; # constants
|
||||
}
|
||||
|
||||
$dst = $arg[$#arg] if ($#arg>=0);
|
||||
$src = $arg[$#arg-1] if ($#arg>=1);
|
||||
if ($dst =~ m/^%/o) { $suffix=&opsize($dst); }
|
||||
elsif ($src =~ m/^%/o) { $suffix=&opsize($src); }
|
||||
else { $suffix="l"; }
|
||||
undef $suffix if ($dst =~ m/^%[xm]/o || $src =~ m/^%[xm]/o);
|
||||
|
||||
if ($#_==0) { &::emit($opcode); }
|
||||
elsif ($#_==1 && $opcode =~ m/^(call|clflush|j|loop|set)/o)
|
||||
{ &::emit($opcode,@arg); }
|
||||
else { &::emit($opcode.$suffix,@arg);}
|
||||
|
||||
1;
|
||||
}
|
||||
#
|
||||
# opcodes not covered by ::generic above, mostly inconsistent namings...
|
||||
#
|
||||
sub ::movzx { &::movzb(@_); }
|
||||
sub ::pushfd { &::pushfl; }
|
||||
sub ::popfd { &::popfl; }
|
||||
sub ::cpuid { &::emit(".byte\t0x0f,0xa2"); }
|
||||
sub ::rdtsc { &::emit(".byte\t0x0f,0x31"); }
|
||||
|
||||
sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
|
||||
sub ::call_ptr { &::generic("call","*$_[0]"); }
|
||||
sub ::jmp_ptr { &::generic("jmp","*$_[0]"); }
|
||||
|
||||
*::bswap = sub { &::emit("bswap","%$_[0]"); } if (!$::i386);
|
||||
|
||||
sub ::DWP
|
||||
{ my($addr,$reg1,$reg2,$idx)=@_;
|
||||
my $ret="";
|
||||
|
||||
if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; }
|
||||
|
||||
$addr =~ s/^\s+//;
|
||||
# prepend global references with optional underscore
|
||||
$addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige;
|
||||
|
||||
$reg1 = "%$reg1" if ($reg1);
|
||||
$reg2 = "%$reg2" if ($reg2);
|
||||
|
||||
$ret .= $addr if (($addr ne "") && ($addr ne 0));
|
||||
|
||||
if ($reg2)
|
||||
{ $idx!= 0 or $idx=1;
|
||||
$ret .= "($reg1,$reg2,$idx)";
|
||||
}
|
||||
elsif ($reg1)
|
||||
{ $ret .= "($reg1)"; }
|
||||
|
||||
$ret;
|
||||
}
|
||||
sub ::QWP { &::DWP(@_); }
|
||||
sub ::BP { &::DWP(@_); }
|
||||
sub ::WP { &::DWP(@_); }
|
||||
sub ::BC { @_; }
|
||||
sub ::DWC { @_; }
|
||||
|
||||
sub ::file
|
||||
{ push(@out,".text\n"); }
|
||||
|
||||
sub ::function_begin_B
|
||||
{ my $func=shift;
|
||||
my $global=($func !~ /^_/);
|
||||
my $begin="${::lbdecor}_${func}_begin";
|
||||
|
||||
&::LABEL($func,$global?"$begin":"$nmdecor$func");
|
||||
$func=$nmdecor.$func;
|
||||
|
||||
push(@out,".globl\t$func\n") if ($global);
|
||||
if ($::macosx) {
|
||||
push(@out,".private_extern\t$func\n");
|
||||
} else {
|
||||
push(@out,".hidden\t$func\n");
|
||||
}
|
||||
if ($::coff)
|
||||
{ push(@out,".def\t$func;\t.scl\t".(3-$global).";\t.type\t32;\t.endef\n"); }
|
||||
elsif (($::aout and !$::pic) or $::macosx)
|
||||
{ }
|
||||
else
|
||||
{ push(@out,".type $func,\@function\n"); }
|
||||
push(@out,".align\t$align\n");
|
||||
push(@out,"$func:\n");
|
||||
push(@out,"$begin:\n") if ($global);
|
||||
$::stack=4;
|
||||
}
|
||||
|
||||
sub ::function_end_B
|
||||
{ my $func=shift;
|
||||
push(@out,".size\t$nmdecor$func,.-".&::LABEL($func)."\n") if ($::elf);
|
||||
$::stack=0;
|
||||
&::wipe_labels();
|
||||
}
|
||||
|
||||
sub ::comment
|
||||
{
|
||||
if (!defined($com_start) or $::elf)
|
||||
{ # Regarding $::elf above...
|
||||
# GNU and SVR4 as'es use different comment delimiters,
|
||||
push(@out,"\n"); # so we just skip ELF comments...
|
||||
return;
|
||||
}
|
||||
foreach (@_)
|
||||
{
|
||||
if (/^\s*$/)
|
||||
{ push(@out,"\n"); }
|
||||
else
|
||||
{ push(@out,"\t$com_start $_ $com_end\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
sub ::external_label
|
||||
{ foreach(@_) { &::LABEL($_,$nmdecor.$_); } }
|
||||
|
||||
sub ::public_label
|
||||
{ push(@out,".globl\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
|
||||
|
||||
sub ::file_end
|
||||
{ if ($::macosx)
|
||||
{ if (%non_lazy_ptr)
|
||||
{ push(@out,".section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
|
||||
foreach $i (keys %non_lazy_ptr)
|
||||
{ push(@out,"$non_lazy_ptr{$i}:\n.indirect_symbol\t$i\n.long\t0\n"); }
|
||||
}
|
||||
}
|
||||
if (0 && grep {/\b${nmdecor}GFp_ia32cap_P\b/i} @out) {
|
||||
my $tmp=".comm\t${nmdecor}GFp_ia32cap_P,16";
|
||||
if ($::macosx) { push (@out,"$tmp,2\n"); }
|
||||
elsif ($::elf) { push (@out,"$tmp,4\n"); }
|
||||
else { push (@out,"$tmp\n"); }
|
||||
}
|
||||
push(@out,$initseg) if ($initseg);
|
||||
}
|
||||
|
||||
sub ::data_byte { push(@out,".byte\t".join(',',@_)."\n"); }
|
||||
sub ::data_short{ push(@out,".value\t".join(',',@_)."\n"); }
|
||||
sub ::data_word { push(@out,".long\t".join(',',@_)."\n"); }
|
||||
|
||||
sub ::align
|
||||
{ my $val=$_[0];
|
||||
if ($::aout)
|
||||
{ $val=int(log($val)/log(2));
|
||||
$val.=",0x90";
|
||||
}
|
||||
push(@out,".align\t$val\n");
|
||||
}
|
||||
|
||||
sub ::picmeup
|
||||
{ my($dst,$sym,$base,$reflabel)=@_;
|
||||
|
||||
if (($::pic && ($::elf || $::aout)) || $::macosx)
|
||||
{ if (!defined($base))
|
||||
{ &::call(&::label("PIC_me_up"));
|
||||
&::set_label("PIC_me_up");
|
||||
&::blindpop($dst);
|
||||
$base=$dst;
|
||||
$reflabel=&::label("PIC_me_up");
|
||||
}
|
||||
if ($::macosx)
|
||||
{ my $indirect=&::static_label("$nmdecor$sym\$non_lazy_ptr");
|
||||
&::mov($dst,&::DWP("$indirect-$reflabel",$base));
|
||||
$non_lazy_ptr{"$nmdecor$sym"}=$indirect;
|
||||
}
|
||||
elsif ($sym eq "GFp_ia32cap_P" && $::elf>0)
|
||||
{ &::lea($dst,&::DWP("$sym-$reflabel",$base)); }
|
||||
else
|
||||
{ &::lea($dst,&::DWP("_GLOBAL_OFFSET_TABLE_+[.-$reflabel]",
|
||||
$base));
|
||||
&::mov($dst,&::DWP("$sym\@GOT",$dst));
|
||||
}
|
||||
}
|
||||
else
|
||||
{ &::lea($dst,&::DWP($sym)); }
|
||||
}
|
||||
|
||||
sub ::initseg
|
||||
{ my $f=$nmdecor.shift;
|
||||
|
||||
if ($::android)
|
||||
{ $initseg.=<<___;
|
||||
.section .init_array
|
||||
.align 4
|
||||
.long $f
|
||||
___
|
||||
}
|
||||
elsif ($::elf)
|
||||
{ $initseg.=<<___;
|
||||
.section .init
|
||||
call $f
|
||||
___
|
||||
}
|
||||
elsif ($::coff)
|
||||
{ $initseg.=<<___; # applies to both Cygwin and Mingw
|
||||
.section .ctors
|
||||
.long $f
|
||||
___
|
||||
}
|
||||
elsif ($::macosx)
|
||||
{ $initseg.=<<___;
|
||||
.mod_init_func
|
||||
.align 2
|
||||
.long $f
|
||||
___
|
||||
}
|
||||
elsif ($::aout)
|
||||
{ my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
|
||||
$initseg.=".text\n";
|
||||
$initseg.=".type $ctor,\@function\n" if ($::pic);
|
||||
$initseg.=<<___; # OpenBSD way...
|
||||
.globl $ctor
|
||||
.align 2
|
||||
$ctor:
|
||||
jmp $f
|
||||
___
|
||||
}
|
||||
}
|
||||
|
||||
sub ::dataseg
|
||||
{ push(@out,".data\n"); }
|
||||
|
||||
*::hidden = sub { push(@out,".hidden\t$nmdecor$_[0]\n"); } if ($::elf);
|
||||
|
||||
1;
|
||||
186
zeroidc/vendor/ring/crypto/perlasm/x86nasm.pl
vendored
Normal file
186
zeroidc/vendor/ring/crypto/perlasm/x86nasm.pl
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (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
|
||||
|
||||
|
||||
package x86nasm;
|
||||
|
||||
*out=\@::out;
|
||||
|
||||
$::lbdecor="L\$"; # local label decoration
|
||||
$nmdecor="_"; # external name decoration
|
||||
$drdecor=$::mwerks?".":""; # directive decoration
|
||||
|
||||
$initseg="";
|
||||
|
||||
sub ::generic
|
||||
{ my $opcode=shift;
|
||||
my $tmp;
|
||||
|
||||
if (!$::mwerks)
|
||||
{ if ($opcode =~ m/^j/o && $#_==0) # optimize jumps
|
||||
{ $_[0] = "NEAR $_[0]"; }
|
||||
elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea
|
||||
{ $_[1] =~ s/^[^\[]*\[/\[/o; }
|
||||
elsif ($opcode eq "clflush" && $#_==0)
|
||||
{ $_[0] =~ s/^[^\[]*\[/\[/o; }
|
||||
}
|
||||
&::emit($opcode,@_);
|
||||
1;
|
||||
}
|
||||
#
|
||||
# opcodes not covered by ::generic above, mostly inconsistent namings...
|
||||
#
|
||||
sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
|
||||
sub ::call_ptr { &::emit("call",@_); }
|
||||
sub ::jmp_ptr { &::emit("jmp",@_); }
|
||||
|
||||
sub get_mem
|
||||
{ my($size,$addr,$reg1,$reg2,$idx)=@_;
|
||||
my($post,$ret);
|
||||
|
||||
if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; }
|
||||
|
||||
if ($size ne "")
|
||||
{ $ret .= "$size";
|
||||
$ret .= " PTR" if ($::mwerks);
|
||||
$ret .= " ";
|
||||
}
|
||||
$ret .= "[";
|
||||
|
||||
$addr =~ s/^\s+//;
|
||||
# prepend global references with optional underscore
|
||||
$addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige;
|
||||
# put address arithmetic expression in parenthesis
|
||||
$addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
|
||||
|
||||
if (($addr ne "") && ($addr ne 0))
|
||||
{ if ($addr !~ /^-/) { $ret .= "$addr+"; }
|
||||
else { $post=$addr; }
|
||||
}
|
||||
|
||||
if ($reg2 ne "")
|
||||
{ $idx!=0 or $idx=1;
|
||||
$ret .= "$reg2*$idx";
|
||||
$ret .= "+$reg1" if ($reg1 ne "");
|
||||
}
|
||||
else
|
||||
{ $ret .= "$reg1"; }
|
||||
|
||||
$ret .= "$post]";
|
||||
$ret =~ s/\+\]/]/; # in case $addr was the only argument
|
||||
|
||||
$ret;
|
||||
}
|
||||
sub ::BP { &get_mem("BYTE",@_); }
|
||||
sub ::DWP { &get_mem("DWORD",@_); }
|
||||
sub ::WP { &get_mem("WORD",@_); }
|
||||
sub ::QWP { &get_mem("",@_); }
|
||||
sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; }
|
||||
sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; }
|
||||
|
||||
sub ::file
|
||||
{ if ($::mwerks) { push(@out,".section\t.text,64\n"); }
|
||||
else
|
||||
{ my $tmp=<<___;
|
||||
%ifidn __OUTPUT_FORMAT__,obj
|
||||
section code use32 class=code align=64
|
||||
%elifidn __OUTPUT_FORMAT__,win32
|
||||
\$\@feat.00 equ 1
|
||||
section .text code align=64
|
||||
%else
|
||||
section .text code
|
||||
%endif
|
||||
___
|
||||
push(@out,$tmp);
|
||||
}
|
||||
}
|
||||
|
||||
sub ::function_begin_B
|
||||
{ my $func=shift;
|
||||
my $global=($func !~ /^_/);
|
||||
my $begin="${::lbdecor}_${func}_begin";
|
||||
|
||||
$begin =~ s/^\@/./ if ($::mwerks); # the torture never stops
|
||||
|
||||
&::LABEL($func,$global?"$begin":"$nmdecor$func");
|
||||
$func=$nmdecor.$func;
|
||||
|
||||
push(@out,"${drdecor}global $func\n") if ($global);
|
||||
push(@out,"${drdecor}align 16\n");
|
||||
push(@out,"$func:\n");
|
||||
push(@out,"$begin:\n") if ($global);
|
||||
$::stack=4;
|
||||
}
|
||||
|
||||
sub ::function_end_B
|
||||
{ $::stack=0;
|
||||
&::wipe_labels();
|
||||
}
|
||||
|
||||
sub ::file_end
|
||||
{ if (grep {/\b${nmdecor}GFp_ia32cap_P\b/i} @out)
|
||||
{ my $comm=<<___;
|
||||
${drdecor}segment .bss
|
||||
${drdecor}common ${nmdecor}GFp_ia32cap_P 16
|
||||
___
|
||||
# comment out GFp_ia32cap_P declarations
|
||||
grep {s/(^extern\s+${nmdecor}GFp_ia32cap_P)/\;$1/} @out;
|
||||
push (@out,$comm)
|
||||
}
|
||||
push (@out,$initseg) if ($initseg);
|
||||
}
|
||||
|
||||
sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
|
||||
|
||||
sub ::external_label
|
||||
{ foreach(@_)
|
||||
{ push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); }
|
||||
}
|
||||
|
||||
sub ::public_label
|
||||
{ push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
|
||||
|
||||
sub ::data_byte
|
||||
{ push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); }
|
||||
sub ::data_short
|
||||
{ push(@out,(($::mwerks)?".word\t":"dw\t").join(',',@_)."\n"); }
|
||||
sub ::data_word
|
||||
{ push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); }
|
||||
|
||||
sub ::align
|
||||
{ push(@out,"${drdecor}align\t$_[0]\n"); }
|
||||
|
||||
sub ::picmeup
|
||||
{ my($dst,$sym)=@_;
|
||||
&::lea($dst,&::DWP($sym));
|
||||
}
|
||||
|
||||
sub ::initseg
|
||||
{ my $f=$nmdecor.shift;
|
||||
if ($::win32)
|
||||
{ $initseg=<<___;
|
||||
segment .CRT\$XCU data align=4
|
||||
extern $f
|
||||
dd $f
|
||||
___
|
||||
}
|
||||
}
|
||||
|
||||
sub ::dataseg
|
||||
{ if ($mwerks) { push(@out,".section\t.data,4\n"); }
|
||||
else { push(@out,"section\t.data align=4\n"); }
|
||||
}
|
||||
|
||||
sub ::safeseh
|
||||
{ my $nm=shift;
|
||||
push(@out,"%if __NASM_VERSION_ID__ >= 0x02030000\n");
|
||||
push(@out,"safeseh ".&::LABEL($nm,$nmdecor.$nm)."\n");
|
||||
push(@out,"%endif\n");
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user