diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-09-11 14:57:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-09-11 14:57:30 +0000 |
commit | f46607add371e119a9103a8f11bc0765f940b169 (patch) | |
tree | eb602af5e1bd1b77180dee3c9caa2c8a5544e2a1 /lib/libcrypto/perlasm | |
parent | c48faa143ee9ede7b68b0d6df98d25ced0a64256 (diff) |
Bring back the expansion-into-.byte-sequences routines removed in r1.9, but
only define them if not building for the "openbsd" flavour.
This way, non-obfuscated output can still be generated for analysis, by using
the "openbsd" flavour (which OpenBSD HEAD will do), and obfuscated output,
compatible with older as(1), will be generated for other platforms.
The portable version of LibreSSL can then use "openbsd-portable" as the
flavour for OpenBSD/amd64 so that generated files can be compiled with
OpenBSD 5.7 and other older versions stuck with as(1) 2.15.
Diffstat (limited to 'lib/libcrypto/perlasm')
-rwxr-xr-x | lib/libcrypto/perlasm/x86_64-xlate.pl | 79 |
1 files changed, 67 insertions, 12 deletions
diff --git a/lib/libcrypto/perlasm/x86_64-xlate.pl b/lib/libcrypto/perlasm/x86_64-xlate.pl index 82992f41e5e..4bd53da33dd 100755 --- a/lib/libcrypto/perlasm/x86_64-xlate.pl +++ b/lib/libcrypto/perlasm/x86_64-xlate.pl @@ -662,6 +662,32 @@ sub rex { my %regrm = ( "%eax"=>0, "%ecx"=>1, "%edx"=>2, "%ebx"=>3, "%esp"=>4, "%ebp"=>5, "%esi"=>6, "%edi"=>7 ); +if ($flavour ne "openbsd") { + +$movq = sub { # elderly gas can't handle inter-register movq + my $arg = shift; + my @opcode=(0x66); + if ($arg =~ /%xmm([0-9]+),\s*%r(\w+)/) { + my ($src,$dst)=($1,$2); + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,$src,$dst,0x8); + push @opcode,0x0f,0x7e; + push @opcode,0xc0|(($src&7)<<3)|($dst&7); # ModR/M + @opcode; + } elsif ($arg =~ /%r(\w+),\s*%xmm([0-9]+)/) { + my ($src,$dst)=($2,$1); + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,$src,$dst,0x8); + push @opcode,0x0f,0x6e; + push @opcode,0xc0|(($src&7)<<3)|($dst&7); # ModR/M + @opcode; + } else { + (); + } +}; + +} + my $pextrd = sub { if (shift =~ /\$([0-9]+),\s*%xmm([0-9]+),\s*(%\w+)/) { my @opcode=(0x66); @@ -698,20 +724,49 @@ my $pinsrd = sub { } }; -my $pclmulqdq = sub { - if (shift =~ /\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { - my @opcode=(0x66); - rex(\@opcode,$3,$2); - push @opcode,0x0f,0x3a,0x44; - push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M - my $c=$1; - push @opcode,$c=~/^0/?oct($c):$c; - @opcode; - } else { - (); - } +if ($flavour ne "openbsd") { + +$pshufb = sub { + if (shift =~ /%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$2,$1); + push @opcode,0x0f,0x38,0x00; + push @opcode,0xc0|($1&7)|(($2&7)<<3); # ModR/M + @opcode; + } else { + (); + } +}; + +$palignr = sub { + if (shift =~ /\$([0-9]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$3,$2); + push @opcode,0x0f,0x3a,0x0f; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + push @opcode,$1; + @opcode; + } else { + (); + } }; +$pclmulqdq = sub { + if (shift =~ /\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$3,$2); + push @opcode,0x0f,0x3a,0x44; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + my $c=$1; + push @opcode,$c=~/^0/?oct($c):$c; + @opcode; + } else { + (); + } +}; + +} + if ($nasm) { print <<___; default rel |