ring-native 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGES.md +7 -0
- data/Makefile +5 -0
- data/README.md +12 -5
- data/Rakefile +4 -0
- data/ext/ring/extconf.rb +4 -5
- data/lib/ring/native.rb +3 -1
- data/lib/ring/native/version.rb +5 -1
- data/ring-native.gemspec +6 -6
- data/vendor/ring-ffi/Cargo.lock +26 -0
- data/vendor/ring-ffi/Cargo.toml +45 -0
- data/vendor/ring-ffi/LICENSE +16 -0
- data/vendor/ring-ffi/README.md +59 -0
- data/vendor/ring-ffi/src/lib.rs +79 -0
- metadata +10 -255
- data/vendor/ring/BUILDING.md +0 -40
- data/vendor/ring/Cargo.toml +0 -43
- data/vendor/ring/LICENSE +0 -185
- data/vendor/ring/Makefile +0 -35
- data/vendor/ring/PORTING.md +0 -163
- data/vendor/ring/README.md +0 -113
- data/vendor/ring/STYLE.md +0 -197
- data/vendor/ring/appveyor.yml +0 -27
- data/vendor/ring/build.rs +0 -108
- data/vendor/ring/crypto/aes/aes.c +0 -1142
- data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/aes/aes_test.cc +0 -93
- data/vendor/ring/crypto/aes/asm/aes-586.pl +0 -2368
- data/vendor/ring/crypto/aes/asm/aes-armv4.pl +0 -1249
- data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +0 -2246
- data/vendor/ring/crypto/aes/asm/aesni-x86.pl +0 -1318
- data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +0 -2084
- data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +0 -675
- data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +0 -1364
- data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +0 -1565
- data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +0 -841
- data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +0 -1116
- data/vendor/ring/crypto/aes/internal.h +0 -87
- data/vendor/ring/crypto/aes/mode_wrappers.c +0 -61
- data/vendor/ring/crypto/bn/add.c +0 -394
- data/vendor/ring/crypto/bn/asm/armv4-mont.pl +0 -694
- data/vendor/ring/crypto/bn/asm/armv8-mont.pl +0 -1503
- data/vendor/ring/crypto/bn/asm/bn-586.pl +0 -774
- data/vendor/ring/crypto/bn/asm/co-586.pl +0 -287
- data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +0 -1882
- data/vendor/ring/crypto/bn/asm/x86-mont.pl +0 -592
- data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +0 -599
- data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +0 -1393
- data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +0 -3507
- data/vendor/ring/crypto/bn/bn.c +0 -352
- data/vendor/ring/crypto/bn/bn_asn1.c +0 -74
- data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bn/bn_test.cc +0 -1696
- data/vendor/ring/crypto/bn/cmp.c +0 -200
- data/vendor/ring/crypto/bn/convert.c +0 -433
- data/vendor/ring/crypto/bn/ctx.c +0 -311
- data/vendor/ring/crypto/bn/div.c +0 -594
- data/vendor/ring/crypto/bn/exponentiation.c +0 -1335
- data/vendor/ring/crypto/bn/gcd.c +0 -711
- data/vendor/ring/crypto/bn/generic.c +0 -1019
- data/vendor/ring/crypto/bn/internal.h +0 -316
- data/vendor/ring/crypto/bn/montgomery.c +0 -516
- data/vendor/ring/crypto/bn/mul.c +0 -888
- data/vendor/ring/crypto/bn/prime.c +0 -829
- data/vendor/ring/crypto/bn/random.c +0 -334
- data/vendor/ring/crypto/bn/rsaz_exp.c +0 -262
- data/vendor/ring/crypto/bn/rsaz_exp.h +0 -53
- data/vendor/ring/crypto/bn/shift.c +0 -276
- data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bytestring/bytestring_test.cc +0 -421
- data/vendor/ring/crypto/bytestring/cbb.c +0 -399
- data/vendor/ring/crypto/bytestring/cbs.c +0 -227
- data/vendor/ring/crypto/bytestring/internal.h +0 -46
- data/vendor/ring/crypto/chacha/chacha_generic.c +0 -140
- data/vendor/ring/crypto/chacha/chacha_vec.c +0 -323
- data/vendor/ring/crypto/chacha/chacha_vec_arm.S +0 -1447
- data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +0 -153
- data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/cipher/e_aes.c +0 -390
- data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +0 -208
- data/vendor/ring/crypto/cipher/internal.h +0 -173
- data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +0 -543
- data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +0 -9
- data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +0 -475
- data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +0 -23
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +0 -422
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +0 -484
- data/vendor/ring/crypto/cipher/test/cipher_test.txt +0 -100
- data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/constant_time_test.c +0 -304
- data/vendor/ring/crypto/cpu-arm-asm.S +0 -32
- data/vendor/ring/crypto/cpu-arm.c +0 -199
- data/vendor/ring/crypto/cpu-intel.c +0 -261
- data/vendor/ring/crypto/crypto.c +0 -151
- data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +0 -2118
- data/vendor/ring/crypto/curve25519/curve25519.c +0 -4888
- data/vendor/ring/crypto/curve25519/x25519_test.cc +0 -128
- data/vendor/ring/crypto/digest/md32_common.h +0 -181
- data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +0 -2725
- data/vendor/ring/crypto/ec/ec.c +0 -193
- data/vendor/ring/crypto/ec/ec_curves.c +0 -61
- data/vendor/ring/crypto/ec/ec_key.c +0 -228
- data/vendor/ring/crypto/ec/ec_montgomery.c +0 -114
- data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ec/internal.h +0 -243
- data/vendor/ring/crypto/ec/oct.c +0 -253
- data/vendor/ring/crypto/ec/p256-64.c +0 -1794
- data/vendor/ring/crypto/ec/p256-x86_64-table.h +0 -9548
- data/vendor/ring/crypto/ec/p256-x86_64.c +0 -509
- data/vendor/ring/crypto/ec/simple.c +0 -1007
- data/vendor/ring/crypto/ec/util-64.c +0 -183
- data/vendor/ring/crypto/ec/wnaf.c +0 -508
- data/vendor/ring/crypto/ecdh/ecdh.c +0 -155
- data/vendor/ring/crypto/ecdsa/ecdsa.c +0 -304
- data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +0 -193
- data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +0 -327
- data/vendor/ring/crypto/header_removed.h +0 -17
- data/vendor/ring/crypto/internal.h +0 -495
- data/vendor/ring/crypto/libring.Windows.vcxproj +0 -101
- data/vendor/ring/crypto/mem.c +0 -98
- data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +0 -1045
- data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +0 -517
- data/vendor/ring/crypto/modes/asm/ghash-x86.pl +0 -1393
- data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +0 -1741
- data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +0 -422
- data/vendor/ring/crypto/modes/ctr.c +0 -226
- data/vendor/ring/crypto/modes/gcm.c +0 -1206
- data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/modes/gcm_test.c +0 -348
- data/vendor/ring/crypto/modes/internal.h +0 -299
- data/vendor/ring/crypto/perlasm/arm-xlate.pl +0 -170
- data/vendor/ring/crypto/perlasm/readme +0 -100
- data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +0 -1164
- data/vendor/ring/crypto/perlasm/x86asm.pl +0 -292
- data/vendor/ring/crypto/perlasm/x86gas.pl +0 -263
- data/vendor/ring/crypto/perlasm/x86masm.pl +0 -200
- data/vendor/ring/crypto/perlasm/x86nasm.pl +0 -187
- data/vendor/ring/crypto/poly1305/poly1305.c +0 -331
- data/vendor/ring/crypto/poly1305/poly1305_arm.c +0 -301
- data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +0 -2015
- data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/poly1305/poly1305_test.cc +0 -80
- data/vendor/ring/crypto/poly1305/poly1305_test.txt +0 -52
- data/vendor/ring/crypto/poly1305/poly1305_vec.c +0 -892
- data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +0 -75
- data/vendor/ring/crypto/rand/internal.h +0 -32
- data/vendor/ring/crypto/rand/rand.c +0 -189
- data/vendor/ring/crypto/rand/urandom.c +0 -219
- data/vendor/ring/crypto/rand/windows.c +0 -56
- data/vendor/ring/crypto/refcount_c11.c +0 -66
- data/vendor/ring/crypto/refcount_lock.c +0 -53
- data/vendor/ring/crypto/refcount_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/refcount_test.c +0 -58
- data/vendor/ring/crypto/rsa/blinding.c +0 -462
- data/vendor/ring/crypto/rsa/internal.h +0 -108
- data/vendor/ring/crypto/rsa/padding.c +0 -300
- data/vendor/ring/crypto/rsa/rsa.c +0 -450
- data/vendor/ring/crypto/rsa/rsa_asn1.c +0 -261
- data/vendor/ring/crypto/rsa/rsa_impl.c +0 -944
- data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/rsa/rsa_test.cc +0 -437
- data/vendor/ring/crypto/sha/asm/sha-armv8.pl +0 -436
- data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +0 -2390
- data/vendor/ring/crypto/sha/asm/sha256-586.pl +0 -1275
- data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +0 -735
- data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-586.pl +0 -911
- data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +0 -666
- data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/sha1.c +0 -271
- data/vendor/ring/crypto/sha/sha256.c +0 -204
- data/vendor/ring/crypto/sha/sha512.c +0 -355
- data/vendor/ring/crypto/test/file_test.cc +0 -326
- data/vendor/ring/crypto/test/file_test.h +0 -181
- data/vendor/ring/crypto/test/malloc.cc +0 -150
- data/vendor/ring/crypto/test/scoped_types.h +0 -95
- data/vendor/ring/crypto/test/test.Windows.vcxproj +0 -35
- data/vendor/ring/crypto/test/test_util.cc +0 -46
- data/vendor/ring/crypto/test/test_util.h +0 -41
- data/vendor/ring/crypto/thread_none.c +0 -55
- data/vendor/ring/crypto/thread_pthread.c +0 -165
- data/vendor/ring/crypto/thread_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/thread_test.c +0 -200
- data/vendor/ring/crypto/thread_win.c +0 -282
- data/vendor/ring/examples/checkdigest.rs +0 -103
- data/vendor/ring/include/openssl/aes.h +0 -121
- data/vendor/ring/include/openssl/arm_arch.h +0 -129
- data/vendor/ring/include/openssl/base.h +0 -156
- data/vendor/ring/include/openssl/bn.h +0 -794
- data/vendor/ring/include/openssl/buffer.h +0 -18
- data/vendor/ring/include/openssl/bytestring.h +0 -235
- data/vendor/ring/include/openssl/chacha.h +0 -37
- data/vendor/ring/include/openssl/cmac.h +0 -76
- data/vendor/ring/include/openssl/cpu.h +0 -184
- data/vendor/ring/include/openssl/crypto.h +0 -43
- data/vendor/ring/include/openssl/curve25519.h +0 -88
- data/vendor/ring/include/openssl/ec.h +0 -225
- data/vendor/ring/include/openssl/ec_key.h +0 -129
- data/vendor/ring/include/openssl/ecdh.h +0 -110
- data/vendor/ring/include/openssl/ecdsa.h +0 -156
- data/vendor/ring/include/openssl/err.h +0 -201
- data/vendor/ring/include/openssl/mem.h +0 -101
- data/vendor/ring/include/openssl/obj_mac.h +0 -71
- data/vendor/ring/include/openssl/opensslfeatures.h +0 -68
- data/vendor/ring/include/openssl/opensslv.h +0 -18
- data/vendor/ring/include/openssl/ossl_typ.h +0 -18
- data/vendor/ring/include/openssl/poly1305.h +0 -51
- data/vendor/ring/include/openssl/rand.h +0 -70
- data/vendor/ring/include/openssl/rsa.h +0 -399
- data/vendor/ring/include/openssl/thread.h +0 -133
- data/vendor/ring/include/openssl/type_check.h +0 -71
- data/vendor/ring/mk/Common.props +0 -63
- data/vendor/ring/mk/Windows.props +0 -42
- data/vendor/ring/mk/WindowsTest.props +0 -18
- data/vendor/ring/mk/appveyor.bat +0 -62
- data/vendor/ring/mk/bottom_of_makefile.mk +0 -54
- data/vendor/ring/mk/ring.mk +0 -266
- data/vendor/ring/mk/top_of_makefile.mk +0 -214
- data/vendor/ring/mk/travis.sh +0 -40
- data/vendor/ring/mk/update-travis-yml.py +0 -229
- data/vendor/ring/ring.sln +0 -153
- data/vendor/ring/src/aead.rs +0 -682
- data/vendor/ring/src/agreement.rs +0 -248
- data/vendor/ring/src/c.rs +0 -129
- data/vendor/ring/src/constant_time.rs +0 -37
- data/vendor/ring/src/der.rs +0 -96
- data/vendor/ring/src/digest.rs +0 -690
- data/vendor/ring/src/digest_tests.txt +0 -57
- data/vendor/ring/src/ecc.rs +0 -28
- data/vendor/ring/src/ecc_build.rs +0 -279
- data/vendor/ring/src/ecc_curves.rs +0 -117
- data/vendor/ring/src/ed25519_tests.txt +0 -2579
- data/vendor/ring/src/exe_tests.rs +0 -46
- data/vendor/ring/src/ffi.rs +0 -29
- data/vendor/ring/src/file_test.rs +0 -187
- data/vendor/ring/src/hkdf.rs +0 -153
- data/vendor/ring/src/hkdf_tests.txt +0 -59
- data/vendor/ring/src/hmac.rs +0 -414
- data/vendor/ring/src/hmac_tests.txt +0 -97
- data/vendor/ring/src/input.rs +0 -312
- data/vendor/ring/src/lib.rs +0 -41
- data/vendor/ring/src/pbkdf2.rs +0 -265
- data/vendor/ring/src/pbkdf2_tests.txt +0 -113
- data/vendor/ring/src/polyfill.rs +0 -57
- data/vendor/ring/src/rand.rs +0 -28
- data/vendor/ring/src/signature.rs +0 -314
- data/vendor/ring/third-party/NIST/README.md +0 -9
- data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/sha256sums.txt +0 -1
@@ -1,292 +0,0 @@
|
|
1
|
-
#!/usr/bin/env perl
|
2
|
-
|
3
|
-
# require 'x86asm.pl';
|
4
|
-
# &asm_init(<flavor>,"des-586.pl"[,$i386only]);
|
5
|
-
# &function_begin("foo");
|
6
|
-
# ...
|
7
|
-
# &function_end("foo");
|
8
|
-
# &asm_finish
|
9
|
-
|
10
|
-
$out=();
|
11
|
-
$i386=0;
|
12
|
-
|
13
|
-
# AUTOLOAD is this context has quite unpleasant side effect, namely
|
14
|
-
# that typos in function calls effectively go to assembler output,
|
15
|
-
# but on the pros side we don't have to implement one subroutine per
|
16
|
-
# each opcode...
|
17
|
-
sub ::AUTOLOAD
|
18
|
-
{ my $opcode = $AUTOLOAD;
|
19
|
-
|
20
|
-
die "more than 4 arguments passed to $opcode" if ($#_>3);
|
21
|
-
|
22
|
-
$opcode =~ s/.*:://;
|
23
|
-
if ($opcode =~ /^push/) { $stack+=4; }
|
24
|
-
elsif ($opcode =~ /^pop/) { $stack-=4; }
|
25
|
-
|
26
|
-
&generic($opcode,@_) or die "undefined subroutine \&$AUTOLOAD";
|
27
|
-
}
|
28
|
-
|
29
|
-
sub ::emit
|
30
|
-
{ my $opcode=shift;
|
31
|
-
|
32
|
-
if ($#_==-1) { push(@out,"\t$opcode\n"); }
|
33
|
-
else { push(@out,"\t$opcode\t".join(',',@_)."\n"); }
|
34
|
-
}
|
35
|
-
|
36
|
-
sub ::LB
|
37
|
-
{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'";
|
38
|
-
$1."l";
|
39
|
-
}
|
40
|
-
sub ::HB
|
41
|
-
{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'high byte'";
|
42
|
-
$1."h";
|
43
|
-
}
|
44
|
-
sub ::stack_push{ my $num=$_[0]*4; $stack+=$num; &sub("esp",$num); }
|
45
|
-
sub ::stack_pop { my $num=$_[0]*4; $stack-=$num; &add("esp",$num); }
|
46
|
-
sub ::blindpop { &pop($_[0]); $stack+=4; }
|
47
|
-
sub ::wparam { &DWP($stack+4*$_[0],"esp"); }
|
48
|
-
sub ::swtmp { &DWP(4*$_[0],"esp"); }
|
49
|
-
|
50
|
-
sub ::bswap
|
51
|
-
{ if ($i386) # emulate bswap for i386
|
52
|
-
{ &comment("bswap @_");
|
53
|
-
&xchg(&HB(@_),&LB(@_));
|
54
|
-
&ror (@_,16);
|
55
|
-
&xchg(&HB(@_),&LB(@_));
|
56
|
-
}
|
57
|
-
else
|
58
|
-
{ &generic("bswap",@_); }
|
59
|
-
}
|
60
|
-
# These are made-up opcodes introduced over the years essentially
|
61
|
-
# by ignorance, just alias them to real ones...
|
62
|
-
sub ::movb { &mov(@_); }
|
63
|
-
sub ::xorb { &xor(@_); }
|
64
|
-
sub ::rotl { &rol(@_); }
|
65
|
-
sub ::rotr { &ror(@_); }
|
66
|
-
sub ::exch { &xchg(@_); }
|
67
|
-
sub ::halt { &hlt; }
|
68
|
-
sub ::movz { &movzx(@_); }
|
69
|
-
sub ::pushf { &pushfd; }
|
70
|
-
sub ::popf { &popfd; }
|
71
|
-
|
72
|
-
# 3 argument instructions
|
73
|
-
sub ::movq
|
74
|
-
{ my($p1,$p2,$optimize)=@_;
|
75
|
-
|
76
|
-
if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
|
77
|
-
# movq between mmx registers can sink Intel CPUs
|
78
|
-
{ &::pshufw($p1,$p2,0xe4); }
|
79
|
-
else
|
80
|
-
{ &::generic("movq",@_); }
|
81
|
-
}
|
82
|
-
|
83
|
-
# SSE>2 instructions
|
84
|
-
my %regrm = ( "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3,
|
85
|
-
"esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7 );
|
86
|
-
sub ::pextrd
|
87
|
-
{ my($dst,$src,$imm)=@_;
|
88
|
-
if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/)
|
89
|
-
{ &::data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm); }
|
90
|
-
else
|
91
|
-
{ &::generic("pextrd",@_); }
|
92
|
-
}
|
93
|
-
|
94
|
-
sub ::pinsrd
|
95
|
-
{ my($dst,$src,$imm)=@_;
|
96
|
-
if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/)
|
97
|
-
{ &::data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm); }
|
98
|
-
else
|
99
|
-
{ &::generic("pinsrd",@_); }
|
100
|
-
}
|
101
|
-
|
102
|
-
sub ::pshufb
|
103
|
-
{ my($dst,$src)=@_;
|
104
|
-
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
105
|
-
{ &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2); }
|
106
|
-
else
|
107
|
-
{ &::generic("pshufb",@_); }
|
108
|
-
}
|
109
|
-
|
110
|
-
sub ::palignr
|
111
|
-
{ my($dst,$src,$imm)=@_;
|
112
|
-
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
113
|
-
{ &::data_byte(0x66,0x0f,0x3a,0x0f,0xc0|($1<<3)|$2,$imm); }
|
114
|
-
else
|
115
|
-
{ &::generic("palignr",@_); }
|
116
|
-
}
|
117
|
-
|
118
|
-
sub ::pclmulqdq
|
119
|
-
{ my($dst,$src,$imm)=@_;
|
120
|
-
if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
|
121
|
-
{ &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); }
|
122
|
-
else
|
123
|
-
{ &::generic("pclmulqdq",@_); }
|
124
|
-
}
|
125
|
-
|
126
|
-
sub ::rdrand
|
127
|
-
{ my ($dst)=@_;
|
128
|
-
if ($dst =~ /(e[a-dsd][ixp])/)
|
129
|
-
{ &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
|
130
|
-
else
|
131
|
-
{ &::generic("rdrand",@_); }
|
132
|
-
}
|
133
|
-
|
134
|
-
sub rxb {
|
135
|
-
local *opcode=shift;
|
136
|
-
my ($dst,$src1,$src2,$rxb)=@_;
|
137
|
-
|
138
|
-
$rxb|=0x7<<5;
|
139
|
-
$rxb&=~(0x04<<5) if($dst>=8);
|
140
|
-
$rxb&=~(0x01<<5) if($src1>=8);
|
141
|
-
$rxb&=~(0x02<<5) if($src2>=8);
|
142
|
-
push @opcode,$rxb;
|
143
|
-
}
|
144
|
-
|
145
|
-
sub ::vprotd
|
146
|
-
{ my $args=join(',',@_);
|
147
|
-
if ($args =~ /xmm([0-7]),xmm([0-7]),([x0-9a-f]+)/)
|
148
|
-
{ my @opcode=(0x8f);
|
149
|
-
rxb(\@opcode,$1,$2,-1,0x08);
|
150
|
-
push @opcode,0x78,0xc2;
|
151
|
-
push @opcode,0xc0|($2&7)|(($1&7)<<3); # ModR/M
|
152
|
-
my $c=$3;
|
153
|
-
push @opcode,$c=~/^0/?oct($c):$c;
|
154
|
-
&::data_byte(@opcode);
|
155
|
-
}
|
156
|
-
else
|
157
|
-
{ &::generic("vprotd",@_); }
|
158
|
-
}
|
159
|
-
|
160
|
-
# label management
|
161
|
-
$lbdecor="L"; # local label decoration, set by package
|
162
|
-
$label="000";
|
163
|
-
|
164
|
-
sub ::islabel # see is argument is a known label
|
165
|
-
{ my $i;
|
166
|
-
foreach $i (values %label) { return $i if ($i eq $_[0]); }
|
167
|
-
$label{$_[0]}; # can be undef
|
168
|
-
}
|
169
|
-
|
170
|
-
sub ::label # instantiate a function-scope label
|
171
|
-
{ if (!defined($label{$_[0]}))
|
172
|
-
{ $label{$_[0]}="${lbdecor}${label}${_[0]}"; $label++; }
|
173
|
-
$label{$_[0]};
|
174
|
-
}
|
175
|
-
|
176
|
-
sub ::LABEL # instantiate a file-scope label
|
177
|
-
{ $label{$_[0]}=$_[1] if (!defined($label{$_[0]}));
|
178
|
-
$label{$_[0]};
|
179
|
-
}
|
180
|
-
|
181
|
-
sub ::static_label { &::LABEL($_[0],$lbdecor.$_[0]); }
|
182
|
-
|
183
|
-
sub ::set_label_B { push(@out,"@_:\n"); }
|
184
|
-
sub ::set_label
|
185
|
-
{ my $label=&::label($_[0]);
|
186
|
-
&::align($_[1]) if ($_[1]>1);
|
187
|
-
&::set_label_B($label);
|
188
|
-
$label;
|
189
|
-
}
|
190
|
-
|
191
|
-
sub ::wipe_labels # wipes function-scope labels
|
192
|
-
{ foreach $i (keys %label)
|
193
|
-
{ delete $label{$i} if ($label{$i} =~ /^\Q${lbdecor}\E[0-9]{3}/); }
|
194
|
-
}
|
195
|
-
|
196
|
-
# subroutine management
|
197
|
-
sub ::function_begin
|
198
|
-
{ &function_begin_B(@_);
|
199
|
-
$stack=4;
|
200
|
-
&push("ebp");
|
201
|
-
&push("ebx");
|
202
|
-
&push("esi");
|
203
|
-
&push("edi");
|
204
|
-
}
|
205
|
-
|
206
|
-
sub ::function_end
|
207
|
-
{ &pop("edi");
|
208
|
-
&pop("esi");
|
209
|
-
&pop("ebx");
|
210
|
-
&pop("ebp");
|
211
|
-
&ret();
|
212
|
-
&function_end_B(@_);
|
213
|
-
$stack=0;
|
214
|
-
&wipe_labels();
|
215
|
-
}
|
216
|
-
|
217
|
-
sub ::function_end_A
|
218
|
-
{ &pop("edi");
|
219
|
-
&pop("esi");
|
220
|
-
&pop("ebx");
|
221
|
-
&pop("ebp");
|
222
|
-
&ret();
|
223
|
-
$stack+=16; # readjust esp as if we didn't pop anything
|
224
|
-
}
|
225
|
-
|
226
|
-
sub ::asciz
|
227
|
-
{ my @str=unpack("C*",shift);
|
228
|
-
push @str,0;
|
229
|
-
while ($#str>15) {
|
230
|
-
&data_byte(@str[0..15]);
|
231
|
-
foreach (0..15) { shift @str; }
|
232
|
-
}
|
233
|
-
&data_byte(@str) if (@str);
|
234
|
-
}
|
235
|
-
|
236
|
-
sub ::asm_finish
|
237
|
-
{ &file_end();
|
238
|
-
print "#if defined(__i386__)\n" unless $win32;
|
239
|
-
print @out;
|
240
|
-
print "#endif\n" unless $win32;
|
241
|
-
}
|
242
|
-
|
243
|
-
sub ::asm_init
|
244
|
-
{ my ($type,$fn,$cpu)=@_;
|
245
|
-
|
246
|
-
$filename=$fn;
|
247
|
-
$i386=$cpu;
|
248
|
-
|
249
|
-
$elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$android=0;
|
250
|
-
if (($type eq "elf"))
|
251
|
-
{ $elf=1; require "x86gas.pl"; }
|
252
|
-
elsif (($type eq "elf-1"))
|
253
|
-
{ $elf=-1; require "x86gas.pl"; }
|
254
|
-
elsif (($type eq "a\.out"))
|
255
|
-
{ $aout=1; require "x86gas.pl"; }
|
256
|
-
elsif (($type eq "coff" or $type eq "gaswin"))
|
257
|
-
{ $coff=1; require "x86gas.pl"; }
|
258
|
-
elsif (($type eq "win32n"))
|
259
|
-
{ $win32=1; require "x86nasm.pl"; }
|
260
|
-
elsif (($type eq "nw-nasm"))
|
261
|
-
{ $netware=1; require "x86nasm.pl"; }
|
262
|
-
#elsif (($type eq "nw-mwasm"))
|
263
|
-
#{ $netware=1; $mwerks=1; require "x86nasm.pl"; }
|
264
|
-
elsif (($type eq "win32"))
|
265
|
-
{ $win32=1; require "x86masm.pl"; }
|
266
|
-
elsif (($type eq "macosx"))
|
267
|
-
{ $aout=1; $macosx=1; require "x86gas.pl"; }
|
268
|
-
elsif (($type eq "android"))
|
269
|
-
{ $elf=1; $android=1; require "x86gas.pl"; }
|
270
|
-
else
|
271
|
-
{ print STDERR <<"EOF";
|
272
|
-
Pick one target type from
|
273
|
-
elf - Linux, FreeBSD, Solaris x86, etc.
|
274
|
-
a.out - DJGPP, elder OpenBSD, etc.
|
275
|
-
coff - GAS/COFF such as Win32 targets
|
276
|
-
win32n - Windows 95/Windows NT NASM format
|
277
|
-
nw-nasm - NetWare NASM format
|
278
|
-
macosx - Mac OS X
|
279
|
-
EOF
|
280
|
-
exit(1);
|
281
|
-
}
|
282
|
-
|
283
|
-
$pic=0;
|
284
|
-
for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
|
285
|
-
|
286
|
-
$filename =~ s/\.pl$//;
|
287
|
-
&file($filename);
|
288
|
-
}
|
289
|
-
|
290
|
-
sub ::hidden {}
|
291
|
-
|
292
|
-
1;
|
@@ -1,263 +0,0 @@
|
|
1
|
-
#!/usr/bin/env perl
|
2
|
-
|
3
|
-
package x86gas;
|
4
|
-
|
5
|
-
*out=\@::out;
|
6
|
-
|
7
|
-
$::lbdecor=$::aout?"L":".L"; # local label decoration
|
8
|
-
$nmdecor=($::aout or $::coff)?"_":""; # external name decoration
|
9
|
-
|
10
|
-
$initseg="";
|
11
|
-
|
12
|
-
$align=16;
|
13
|
-
$align=log($align)/log(2) if ($::aout);
|
14
|
-
$com_start="#" if ($::aout or $::coff);
|
15
|
-
|
16
|
-
sub opsize()
|
17
|
-
{ my $reg=shift;
|
18
|
-
if ($reg =~ m/^%e/o) { "l"; }
|
19
|
-
elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; }
|
20
|
-
elsif ($reg =~ m/^%[xm]/o) { undef; }
|
21
|
-
else { "w"; }
|
22
|
-
}
|
23
|
-
|
24
|
-
# swap arguments;
|
25
|
-
# expand opcode with size suffix;
|
26
|
-
# prefix numeric constants with $;
|
27
|
-
sub ::generic
|
28
|
-
{ my($opcode,@arg)=@_;
|
29
|
-
my($suffix,$dst,$src);
|
30
|
-
|
31
|
-
@arg=reverse(@arg);
|
32
|
-
|
33
|
-
for (@arg)
|
34
|
-
{ s/^(\*?)(e?[a-dsixphl]{2})$/$1%$2/o; # gp registers
|
35
|
-
s/^([xy]?mm[0-7])$/%$1/o; # xmm/mmx registers
|
36
|
-
s/^(\-?[0-9]+)$/\$$1/o; # constants
|
37
|
-
s/^(\-?0x[0-9a-f]+)$/\$$1/o; # constants
|
38
|
-
}
|
39
|
-
|
40
|
-
$dst = $arg[$#arg] if ($#arg>=0);
|
41
|
-
$src = $arg[$#arg-1] if ($#arg>=1);
|
42
|
-
if ($dst =~ m/^%/o) { $suffix=&opsize($dst); }
|
43
|
-
elsif ($src =~ m/^%/o) { $suffix=&opsize($src); }
|
44
|
-
else { $suffix="l"; }
|
45
|
-
undef $suffix if ($dst =~ m/^%[xm]/o || $src =~ m/^%[xm]/o);
|
46
|
-
|
47
|
-
if ($#_==0) { &::emit($opcode); }
|
48
|
-
elsif ($#_==1 && $opcode =~ m/^(call|clflush|j|loop|set)/o)
|
49
|
-
{ &::emit($opcode,@arg); }
|
50
|
-
else { &::emit($opcode.$suffix,@arg);}
|
51
|
-
|
52
|
-
1;
|
53
|
-
}
|
54
|
-
#
|
55
|
-
# opcodes not covered by ::generic above, mostly inconsistent namings...
|
56
|
-
#
|
57
|
-
sub ::movzx { &::movzb(@_); }
|
58
|
-
sub ::pushfd { &::pushfl; }
|
59
|
-
sub ::popfd { &::popfl; }
|
60
|
-
sub ::cpuid { &::emit(".byte\t0x0f,0xa2"); }
|
61
|
-
sub ::rdtsc { &::emit(".byte\t0x0f,0x31"); }
|
62
|
-
|
63
|
-
sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
|
64
|
-
sub ::call_ptr { &::generic("call","*$_[0]"); }
|
65
|
-
sub ::jmp_ptr { &::generic("jmp","*$_[0]"); }
|
66
|
-
|
67
|
-
*::bswap = sub { &::emit("bswap","%$_[0]"); } if (!$::i386);
|
68
|
-
|
69
|
-
sub ::DWP
|
70
|
-
{ my($addr,$reg1,$reg2,$idx)=@_;
|
71
|
-
my $ret="";
|
72
|
-
|
73
|
-
if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; }
|
74
|
-
|
75
|
-
$addr =~ s/^\s+//;
|
76
|
-
# prepend global references with optional underscore
|
77
|
-
$addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige;
|
78
|
-
|
79
|
-
$reg1 = "%$reg1" if ($reg1);
|
80
|
-
$reg2 = "%$reg2" if ($reg2);
|
81
|
-
|
82
|
-
$ret .= $addr if (($addr ne "") && ($addr ne 0));
|
83
|
-
|
84
|
-
if ($reg2)
|
85
|
-
{ $idx!= 0 or $idx=1;
|
86
|
-
$ret .= "($reg1,$reg2,$idx)";
|
87
|
-
}
|
88
|
-
elsif ($reg1)
|
89
|
-
{ $ret .= "($reg1)"; }
|
90
|
-
|
91
|
-
$ret;
|
92
|
-
}
|
93
|
-
sub ::QWP { &::DWP(@_); }
|
94
|
-
sub ::BP { &::DWP(@_); }
|
95
|
-
sub ::WP { &::DWP(@_); }
|
96
|
-
sub ::BC { @_; }
|
97
|
-
sub ::DWC { @_; }
|
98
|
-
|
99
|
-
sub ::file
|
100
|
-
{ push(@out,".file\t\"$_[0].S\"\n.text\n"); }
|
101
|
-
|
102
|
-
sub ::function_begin_B
|
103
|
-
{ my $func=shift;
|
104
|
-
my $global=($func !~ /^_/);
|
105
|
-
my $begin="${::lbdecor}_${func}_begin";
|
106
|
-
|
107
|
-
&::LABEL($func,$global?"$begin":"$nmdecor$func");
|
108
|
-
$func=$nmdecor.$func;
|
109
|
-
|
110
|
-
push(@out,".globl\t$func\n") if ($global);
|
111
|
-
if ($::macosx) {
|
112
|
-
push(@out,".private_extern\t$func\n");
|
113
|
-
} else {
|
114
|
-
push(@out,".hidden\t$func\n");
|
115
|
-
}
|
116
|
-
if ($::coff)
|
117
|
-
{ push(@out,".def\t$func;\t.scl\t".(3-$global).";\t.type\t32;\t.endef\n"); }
|
118
|
-
elsif (($::aout and !$::pic) or $::macosx)
|
119
|
-
{ }
|
120
|
-
else
|
121
|
-
{ push(@out,".type $func,\@function\n"); }
|
122
|
-
push(@out,".align\t$align\n");
|
123
|
-
push(@out,"$func:\n");
|
124
|
-
push(@out,"$begin:\n") if ($global);
|
125
|
-
$::stack=4;
|
126
|
-
}
|
127
|
-
|
128
|
-
sub ::function_end_B
|
129
|
-
{ my $func=shift;
|
130
|
-
push(@out,".size\t$nmdecor$func,.-".&::LABEL($func)."\n") if ($::elf);
|
131
|
-
$::stack=0;
|
132
|
-
&::wipe_labels();
|
133
|
-
}
|
134
|
-
|
135
|
-
sub ::comment
|
136
|
-
{
|
137
|
-
if (!defined($com_start) or $::elf)
|
138
|
-
{ # Regarding $::elf above...
|
139
|
-
# GNU and SVR4 as'es use different comment delimiters,
|
140
|
-
push(@out,"\n"); # so we just skip ELF comments...
|
141
|
-
return;
|
142
|
-
}
|
143
|
-
foreach (@_)
|
144
|
-
{
|
145
|
-
if (/^\s*$/)
|
146
|
-
{ push(@out,"\n"); }
|
147
|
-
else
|
148
|
-
{ push(@out,"\t$com_start $_ $com_end\n"); }
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
sub ::external_label
|
153
|
-
{ foreach(@_) { &::LABEL($_,$nmdecor.$_); } }
|
154
|
-
|
155
|
-
sub ::public_label
|
156
|
-
{ push(@out,".globl\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
|
157
|
-
|
158
|
-
sub ::file_end
|
159
|
-
{ if ($::macosx)
|
160
|
-
{ if (%non_lazy_ptr)
|
161
|
-
{ push(@out,".section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
|
162
|
-
foreach $i (keys %non_lazy_ptr)
|
163
|
-
{ push(@out,"$non_lazy_ptr{$i}:\n.indirect_symbol\t$i\n.long\t0\n"); }
|
164
|
-
}
|
165
|
-
}
|
166
|
-
if (0 && grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) {
|
167
|
-
my $tmp=".comm\t${nmdecor}OPENSSL_ia32cap_P,16";
|
168
|
-
if ($::macosx) { push (@out,"$tmp,2\n"); }
|
169
|
-
elsif ($::elf) { push (@out,"$tmp,4\n"); }
|
170
|
-
else { push (@out,"$tmp\n"); }
|
171
|
-
}
|
172
|
-
push(@out,$initseg) if ($initseg);
|
173
|
-
}
|
174
|
-
|
175
|
-
sub ::data_byte { push(@out,".byte\t".join(',',@_)."\n"); }
|
176
|
-
sub ::data_short{ push(@out,".value\t".join(',',@_)."\n"); }
|
177
|
-
sub ::data_word { push(@out,".long\t".join(',',@_)."\n"); }
|
178
|
-
|
179
|
-
sub ::align
|
180
|
-
{ my $val=$_[0];
|
181
|
-
if ($::aout)
|
182
|
-
{ $val=int(log($val)/log(2));
|
183
|
-
$val.=",0x90";
|
184
|
-
}
|
185
|
-
push(@out,".align\t$val\n");
|
186
|
-
}
|
187
|
-
|
188
|
-
sub ::picmeup
|
189
|
-
{ my($dst,$sym,$base,$reflabel)=@_;
|
190
|
-
|
191
|
-
if (($::pic && ($::elf || $::aout)) || $::macosx)
|
192
|
-
{ if (!defined($base))
|
193
|
-
{ &::call(&::label("PIC_me_up"));
|
194
|
-
&::set_label("PIC_me_up");
|
195
|
-
&::blindpop($dst);
|
196
|
-
$base=$dst;
|
197
|
-
$reflabel=&::label("PIC_me_up");
|
198
|
-
}
|
199
|
-
if ($::macosx)
|
200
|
-
{ my $indirect=&::static_label("$nmdecor$sym\$non_lazy_ptr");
|
201
|
-
&::mov($dst,&::DWP("$indirect-$reflabel",$base));
|
202
|
-
$non_lazy_ptr{"$nmdecor$sym"}=$indirect;
|
203
|
-
}
|
204
|
-
elsif ($sym eq "OPENSSL_ia32cap_P" && $::elf>0)
|
205
|
-
{ &::lea($dst,&::DWP("$sym-$reflabel",$base)); }
|
206
|
-
else
|
207
|
-
{ &::lea($dst,&::DWP("_GLOBAL_OFFSET_TABLE_+[.-$reflabel]",
|
208
|
-
$base));
|
209
|
-
&::mov($dst,&::DWP("$sym\@GOT",$dst));
|
210
|
-
}
|
211
|
-
}
|
212
|
-
else
|
213
|
-
{ &::lea($dst,&::DWP($sym)); }
|
214
|
-
}
|
215
|
-
|
216
|
-
sub ::initseg
|
217
|
-
{ my $f=$nmdecor.shift;
|
218
|
-
|
219
|
-
if ($::android)
|
220
|
-
{ $initseg.=<<___;
|
221
|
-
.section .init_array
|
222
|
-
.align 4
|
223
|
-
.long $f
|
224
|
-
___
|
225
|
-
}
|
226
|
-
elsif ($::elf)
|
227
|
-
{ $initseg.=<<___;
|
228
|
-
.section .init
|
229
|
-
call $f
|
230
|
-
___
|
231
|
-
}
|
232
|
-
elsif ($::coff)
|
233
|
-
{ $initseg.=<<___; # applies to both Cygwin and Mingw
|
234
|
-
.section .ctors
|
235
|
-
.long $f
|
236
|
-
___
|
237
|
-
}
|
238
|
-
elsif ($::macosx)
|
239
|
-
{ $initseg.=<<___;
|
240
|
-
.mod_init_func
|
241
|
-
.align 2
|
242
|
-
.long $f
|
243
|
-
___
|
244
|
-
}
|
245
|
-
elsif ($::aout)
|
246
|
-
{ my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
|
247
|
-
$initseg.=".text\n";
|
248
|
-
$initseg.=".type $ctor,\@function\n" if ($::pic);
|
249
|
-
$initseg.=<<___; # OpenBSD way...
|
250
|
-
.globl $ctor
|
251
|
-
.align 2
|
252
|
-
$ctor:
|
253
|
-
jmp $f
|
254
|
-
___
|
255
|
-
}
|
256
|
-
}
|
257
|
-
|
258
|
-
sub ::dataseg
|
259
|
-
{ push(@out,".data\n"); }
|
260
|
-
|
261
|
-
*::hidden = sub { push(@out,".hidden\t$nmdecor$_[0]\n"); } if ($::elf);
|
262
|
-
|
263
|
-
1;
|