diff options
author | miod <> | 2014-04-17 20:17:45 +0000 |
---|---|---|
committer | miod <> | 2014-04-17 20:17:45 +0000 |
commit | e3fc9c40a3ddca5774c9d4f26e3cd8d2d76dfc34 (patch) | |
tree | fc3da8c8b6c8f15792563161ab289bca4f145d79 | |
parent | 585c7d218a6a897c19af7772e5b441680146eafa (diff) | |
download | openbsd-e3fc9c40a3ddca5774c9d4f26e3cd8d2d76dfc34.tar.gz openbsd-e3fc9c40a3ddca5774c9d4f26e3cd8d2d76dfc34.tar.bz2 openbsd-e3fc9c40a3ddca5774c9d4f26e3cd8d2d76dfc34.zip |
Stop paying lip service to non-AT&T syntax assemblers in the x86 world.
-rw-r--r-- | src/lib/libcrypto/perlasm/x86asm.pl | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/perlasm/x86masm.pl | 198 | ||||
-rw-r--r-- | src/lib/libcrypto/perlasm/x86nasm.pl | 177 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/perlasm/x86asm.pl | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/perlasm/x86masm.pl | 198 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/perlasm/x86nasm.pl | 177 |
6 files changed, 2 insertions, 772 deletions
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl index bf783cff26..d74d1992f8 100644 --- a/src/lib/libcrypto/perlasm/x86asm.pl +++ b/src/lib/libcrypto/perlasm/x86asm.pl | |||
@@ -225,21 +225,13 @@ sub ::asm_init | |||
225 | $filename=$fn; | 225 | $filename=$fn; |
226 | $i386=$cpu; | 226 | $i386=$cpu; |
227 | 227 | ||
228 | $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$openbsd=$android=0; | 228 | $elf=$cpp=$coff=$aout=$macosx=$win32=$openbsd=$android=0; |
229 | if (($type eq "elf")) | 229 | if (($type eq "elf")) |
230 | { $elf=1; require "x86gas.pl"; } | 230 | { $elf=1; require "x86gas.pl"; } |
231 | elsif (($type eq "a\.out")) | 231 | elsif (($type eq "a\.out")) |
232 | { $aout=1; require "x86gas.pl"; } | 232 | { $aout=1; require "x86gas.pl"; } |
233 | elsif (($type eq "coff" or $type eq "gaswin")) | 233 | elsif (($type eq "coff" or $type eq "gaswin")) |
234 | { $coff=1; require "x86gas.pl"; } | 234 | { $coff=1; require "x86gas.pl"; } |
235 | elsif (($type eq "win32n")) | ||
236 | { $win32=1; require "x86nasm.pl"; } | ||
237 | elsif (($type eq "nw-nasm")) | ||
238 | { $netware=1; require "x86nasm.pl"; } | ||
239 | #elsif (($type eq "nw-mwasm")) | ||
240 | #{ $netware=1; $mwerks=1; require "x86nasm.pl"; } | ||
241 | elsif (($type eq "win32")) | ||
242 | { $win32=1; require "x86masm.pl"; } | ||
243 | elsif (($type eq "macosx")) | 235 | elsif (($type eq "macosx")) |
244 | { $aout=1; $macosx=1; require "x86gas.pl"; } | 236 | { $aout=1; $macosx=1; require "x86gas.pl"; } |
245 | elsif (($type eq "openbsd-elf")) | 237 | elsif (($type eq "openbsd-elf")) |
@@ -254,10 +246,8 @@ Pick one target type from | |||
254 | elf - Linux, FreeBSD, Solaris x86, etc. | 246 | elf - Linux, FreeBSD, Solaris x86, etc. |
255 | a.out - DJGPP, elder OpenBSD, etc. | 247 | a.out - DJGPP, elder OpenBSD, etc. |
256 | coff - GAS/COFF such as Win32 targets | 248 | coff - GAS/COFF such as Win32 targets |
257 | win32n - Windows 95/Windows NT NASM format | ||
258 | openbsd-elf - OpenBSD elf | 249 | openbsd-elf - OpenBSD elf |
259 | openbsd-a.out - OpenBSD a.out | 250 | openbsd-a.out - OpenBSD a.out |
260 | nw-nasm - NetWare NASM format | ||
261 | macosx - Mac OS X | 251 | macosx - Mac OS X |
262 | EOF | 252 | EOF |
263 | exit(1); | 253 | exit(1); |
diff --git a/src/lib/libcrypto/perlasm/x86masm.pl b/src/lib/libcrypto/perlasm/x86masm.pl deleted file mode 100644 index f937d07c87..0000000000 --- a/src/lib/libcrypto/perlasm/x86masm.pl +++ /dev/null | |||
@@ -1,198 +0,0 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | |||
3 | package x86masm; | ||
4 | |||
5 | *out=\@::out; | ||
6 | |||
7 | $::lbdecor="\$L"; # local label decoration | ||
8 | $nmdecor="_"; # external name decoration | ||
9 | |||
10 | $initseg=""; | ||
11 | $segment=""; | ||
12 | |||
13 | sub ::generic | ||
14 | { my ($opcode,@arg)=@_; | ||
15 | |||
16 | # fix hexadecimal constants | ||
17 | for (@arg) { s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/oi; } | ||
18 | |||
19 | if ($opcode =~ /lea/ && @arg[1] =~ s/.*PTR\s+(\(.*\))$/OFFSET $1/) # no [] | ||
20 | { $opcode="mov"; } | ||
21 | elsif ($opcode !~ /movq/) | ||
22 | { # fix xmm references | ||
23 | $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i); | ||
24 | $arg[1] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[0]=~/\bxmm[0-7]\b/i); | ||
25 | } | ||
26 | |||
27 | &::emit($opcode,@arg); | ||
28 | 1; | ||
29 | } | ||
30 | # | ||
31 | # opcodes not covered by ::generic above, mostly inconsistent namings... | ||
32 | # | ||
33 | sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } | ||
34 | sub ::call_ptr { &::emit("call",@_); } | ||
35 | sub ::jmp_ptr { &::emit("jmp",@_); } | ||
36 | sub ::lock { &::data_byte(0xf0); } | ||
37 | |||
38 | sub get_mem | ||
39 | { my($size,$addr,$reg1,$reg2,$idx)=@_; | ||
40 | my($post,$ret); | ||
41 | |||
42 | $ret .= "$size PTR " if ($size ne ""); | ||
43 | |||
44 | $addr =~ s/^\s+//; | ||
45 | # prepend global references with optional underscore | ||
46 | $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige; | ||
47 | # put address arithmetic expression in parenthesis | ||
48 | $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/); | ||
49 | |||
50 | if (($addr ne "") && ($addr ne 0)) | ||
51 | { if ($addr !~ /^-/) { $ret .= "$addr"; } | ||
52 | else { $post=$addr; } | ||
53 | } | ||
54 | $ret .= "["; | ||
55 | |||
56 | if ($reg2 ne "") | ||
57 | { $idx!=0 or $idx=1; | ||
58 | $ret .= "$reg2*$idx"; | ||
59 | $ret .= "+$reg1" if ($reg1 ne ""); | ||
60 | } | ||
61 | else | ||
62 | { $ret .= "$reg1"; } | ||
63 | |||
64 | $ret .= "$post]"; | ||
65 | $ret =~ s/\+\]/]/; # in case $addr was the only argument | ||
66 | $ret =~ s/\[\s*\]//; | ||
67 | |||
68 | $ret; | ||
69 | } | ||
70 | sub ::BP { &get_mem("BYTE",@_); } | ||
71 | sub ::WP { &get_mem("WORD",@_); } | ||
72 | sub ::DWP { &get_mem("DWORD",@_); } | ||
73 | sub ::QWP { &get_mem("QWORD",@_); } | ||
74 | sub ::BC { "@_"; } | ||
75 | sub ::DWC { "@_"; } | ||
76 | |||
77 | sub ::file | ||
78 | { my $tmp=<<___; | ||
79 | TITLE $_[0].asm | ||
80 | IF \@Version LT 800 | ||
81 | ECHO MASM version 8.00 or later is strongly recommended. | ||
82 | ENDIF | ||
83 | .486 | ||
84 | .MODEL FLAT | ||
85 | OPTION DOTNAME | ||
86 | IF \@Version LT 800 | ||
87 | .text\$ SEGMENT PAGE 'CODE' | ||
88 | ELSE | ||
89 | .text\$ SEGMENT ALIGN(64) 'CODE' | ||
90 | ENDIF | ||
91 | ___ | ||
92 | push(@out,$tmp); | ||
93 | $segment = ".text\$"; | ||
94 | } | ||
95 | |||
96 | sub ::function_begin_B | ||
97 | { my $func=shift; | ||
98 | my $global=($func !~ /^_/); | ||
99 | my $begin="${::lbdecor}_${func}_begin"; | ||
100 | |||
101 | &::LABEL($func,$global?"$begin":"$nmdecor$func"); | ||
102 | $func="ALIGN\t16\n".$nmdecor.$func."\tPROC"; | ||
103 | |||
104 | if ($global) { $func.=" PUBLIC\n${begin}::\n"; } | ||
105 | else { $func.=" PRIVATE\n"; } | ||
106 | push(@out,$func); | ||
107 | $::stack=4; | ||
108 | } | ||
109 | sub ::function_end_B | ||
110 | { my $func=shift; | ||
111 | |||
112 | push(@out,"$nmdecor$func ENDP\n"); | ||
113 | $::stack=0; | ||
114 | &::wipe_labels(); | ||
115 | } | ||
116 | |||
117 | sub ::file_end | ||
118 | { my $xmmheader=<<___; | ||
119 | .686 | ||
120 | .XMM | ||
121 | IF \@Version LT 800 | ||
122 | XMMWORD STRUCT 16 | ||
123 | DQ 2 dup (?) | ||
124 | XMMWORD ENDS | ||
125 | ENDIF | ||
126 | ___ | ||
127 | if (grep {/\b[x]?mm[0-7]\b/i} @out) { | ||
128 | grep {s/\.[3-7]86/$xmmheader/} @out; | ||
129 | } | ||
130 | |||
131 | push(@out,"$segment ENDS\n"); | ||
132 | |||
133 | if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) | ||
134 | { my $comm=<<___; | ||
135 | .bss SEGMENT 'BSS' | ||
136 | COMM ${nmdecor}OPENSSL_ia32cap_P:QWORD | ||
137 | .bss ENDS | ||
138 | ___ | ||
139 | # comment out OPENSSL_ia32cap_P declarations | ||
140 | grep {s/(^EXTERN\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out; | ||
141 | push (@out,$comm); | ||
142 | } | ||
143 | push (@out,$initseg) if ($initseg); | ||
144 | push (@out,"END\n"); | ||
145 | } | ||
146 | |||
147 | sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } } | ||
148 | |||
149 | *::set_label_B = sub | ||
150 | { my $l=shift; push(@out,$l.($l=~/^\Q${::lbdecor}\E[0-9]{3}/?":\n":"::\n")); }; | ||
151 | |||
152 | sub ::external_label | ||
153 | { foreach(@_) | ||
154 | { push(@out, "EXTERN\t".&::LABEL($_,$nmdecor.$_).":NEAR\n"); } | ||
155 | } | ||
156 | |||
157 | sub ::public_label | ||
158 | { push(@out,"PUBLIC\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } | ||
159 | |||
160 | sub ::data_byte | ||
161 | { push(@out,("DB\t").join(',',@_)."\n"); } | ||
162 | |||
163 | sub ::data_short | ||
164 | { push(@out,("DW\t").join(',',@_)."\n"); } | ||
165 | |||
166 | sub ::data_word | ||
167 | { push(@out,("DD\t").join(',',@_)."\n"); } | ||
168 | |||
169 | sub ::align | ||
170 | { push(@out,"ALIGN\t$_[0]\n"); } | ||
171 | |||
172 | sub ::picmeup | ||
173 | { my($dst,$sym)=@_; | ||
174 | &::lea($dst,&::DWP($sym)); | ||
175 | } | ||
176 | |||
177 | sub ::initseg | ||
178 | { my $f=$nmdecor.shift; | ||
179 | |||
180 | $initseg.=<<___; | ||
181 | .CRT\$XCU SEGMENT DWORD PUBLIC 'DATA' | ||
182 | EXTERN $f:NEAR | ||
183 | DD $f | ||
184 | .CRT\$XCU ENDS | ||
185 | ___ | ||
186 | } | ||
187 | |||
188 | sub ::dataseg | ||
189 | { push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA"; } | ||
190 | |||
191 | sub ::safeseh | ||
192 | { my $nm=shift; | ||
193 | push(@out,"IF \@Version GE 710\n"); | ||
194 | push(@out,".SAFESEH ".&::LABEL($nm,$nmdecor.$nm)."\n"); | ||
195 | push(@out,"ENDIF\n"); | ||
196 | } | ||
197 | |||
198 | 1; | ||
diff --git a/src/lib/libcrypto/perlasm/x86nasm.pl b/src/lib/libcrypto/perlasm/x86nasm.pl deleted file mode 100644 index ca2511c9eb..0000000000 --- a/src/lib/libcrypto/perlasm/x86nasm.pl +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | |||
3 | package x86nasm; | ||
4 | |||
5 | *out=\@::out; | ||
6 | |||
7 | $::lbdecor="L\$"; # local label decoration | ||
8 | $nmdecor=$::netware?"":"_"; # external name decoration | ||
9 | $drdecor=$::mwerks?".":""; # directive decoration | ||
10 | |||
11 | $initseg=""; | ||
12 | |||
13 | sub ::generic | ||
14 | { my $opcode=shift; | ||
15 | my $tmp; | ||
16 | |||
17 | if (!$::mwerks) | ||
18 | { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps | ||
19 | { $_[0] = "NEAR $_[0]"; } | ||
20 | elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea | ||
21 | { $_[1] =~ s/^[^\[]*\[/\[/o; } | ||
22 | elsif ($opcode eq "clflush" && $#_==0) | ||
23 | { $_[0] =~ s/^[^\[]*\[/\[/o; } | ||
24 | } | ||
25 | &::emit($opcode,@_); | ||
26 | 1; | ||
27 | } | ||
28 | # | ||
29 | # opcodes not covered by ::generic above, mostly inconsistent namings... | ||
30 | # | ||
31 | sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } | ||
32 | sub ::call_ptr { &::emit("call",@_); } | ||
33 | sub ::jmp_ptr { &::emit("jmp",@_); } | ||
34 | |||
35 | sub get_mem | ||
36 | { my($size,$addr,$reg1,$reg2,$idx)=@_; | ||
37 | my($post,$ret); | ||
38 | |||
39 | if ($size ne "") | ||
40 | { $ret .= "$size"; | ||
41 | $ret .= " PTR" if ($::mwerks); | ||
42 | $ret .= " "; | ||
43 | } | ||
44 | $ret .= "["; | ||
45 | |||
46 | $addr =~ s/^\s+//; | ||
47 | # prepend global references with optional underscore | ||
48 | $addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige; | ||
49 | # put address arithmetic expression in parenthesis | ||
50 | $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/); | ||
51 | |||
52 | if (($addr ne "") && ($addr ne 0)) | ||
53 | { if ($addr !~ /^-/) { $ret .= "$addr+"; } | ||
54 | else { $post=$addr; } | ||
55 | } | ||
56 | |||
57 | if ($reg2 ne "") | ||
58 | { $idx!=0 or $idx=1; | ||
59 | $ret .= "$reg2*$idx"; | ||
60 | $ret .= "+$reg1" if ($reg1 ne ""); | ||
61 | } | ||
62 | else | ||
63 | { $ret .= "$reg1"; } | ||
64 | |||
65 | $ret .= "$post]"; | ||
66 | $ret =~ s/\+\]/]/; # in case $addr was the only argument | ||
67 | |||
68 | $ret; | ||
69 | } | ||
70 | sub ::BP { &get_mem("BYTE",@_); } | ||
71 | sub ::DWP { &get_mem("DWORD",@_); } | ||
72 | sub ::WP { &get_mem("WORD",@_); } | ||
73 | sub ::QWP { &get_mem("",@_); } | ||
74 | sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; } | ||
75 | sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; } | ||
76 | |||
77 | sub ::file | ||
78 | { if ($::mwerks) { push(@out,".section\t.text,64\n"); } | ||
79 | else | ||
80 | { my $tmp=<<___; | ||
81 | %ifidn __OUTPUT_FORMAT__,obj | ||
82 | section code use32 class=code align=64 | ||
83 | %elifidn __OUTPUT_FORMAT__,win32 | ||
84 | \$\@feat.00 equ 1 | ||
85 | section .text code align=64 | ||
86 | %else | ||
87 | section .text code | ||
88 | %endif | ||
89 | ___ | ||
90 | push(@out,$tmp); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | sub ::function_begin_B | ||
95 | { my $func=shift; | ||
96 | my $global=($func !~ /^_/); | ||
97 | my $begin="${::lbdecor}_${func}_begin"; | ||
98 | |||
99 | $begin =~ s/^\@/./ if ($::mwerks); # the torture never stops | ||
100 | |||
101 | &::LABEL($func,$global?"$begin":"$nmdecor$func"); | ||
102 | $func=$nmdecor.$func; | ||
103 | |||
104 | push(@out,"${drdecor}global $func\n") if ($global); | ||
105 | push(@out,"${drdecor}align 16\n"); | ||
106 | push(@out,"$func:\n"); | ||
107 | push(@out,"$begin:\n") if ($global); | ||
108 | $::stack=4; | ||
109 | } | ||
110 | |||
111 | sub ::function_end_B | ||
112 | { $::stack=0; | ||
113 | &::wipe_labels(); | ||
114 | } | ||
115 | |||
116 | sub ::file_end | ||
117 | { if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) | ||
118 | { my $comm=<<___; | ||
119 | ${drdecor}segment .bss | ||
120 | ${drdecor}common ${nmdecor}OPENSSL_ia32cap_P 8 | ||
121 | ___ | ||
122 | # comment out OPENSSL_ia32cap_P declarations | ||
123 | grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out; | ||
124 | push (@out,$comm) | ||
125 | } | ||
126 | push (@out,$initseg) if ($initseg); | ||
127 | } | ||
128 | |||
129 | sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } } | ||
130 | |||
131 | sub ::external_label | ||
132 | { foreach(@_) | ||
133 | { push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); } | ||
134 | } | ||
135 | |||
136 | sub ::public_label | ||
137 | { push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } | ||
138 | |||
139 | sub ::data_byte | ||
140 | { push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); } | ||
141 | sub ::data_short | ||
142 | { push(@out,(($::mwerks)?".word\t":"dw\t").join(',',@_)."\n"); } | ||
143 | sub ::data_word | ||
144 | { push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); } | ||
145 | |||
146 | sub ::align | ||
147 | { push(@out,"${drdecor}align\t$_[0]\n"); } | ||
148 | |||
149 | sub ::picmeup | ||
150 | { my($dst,$sym)=@_; | ||
151 | &::lea($dst,&::DWP($sym)); | ||
152 | } | ||
153 | |||
154 | sub ::initseg | ||
155 | { my $f=$nmdecor.shift; | ||
156 | if ($::win32) | ||
157 | { $initseg=<<___; | ||
158 | segment .CRT\$XCU data align=4 | ||
159 | extern $f | ||
160 | dd $f | ||
161 | ___ | ||
162 | } | ||
163 | } | ||
164 | |||
165 | sub ::dataseg | ||
166 | { if ($mwerks) { push(@out,".section\t.data,4\n"); } | ||
167 | else { push(@out,"section\t.data align=4\n"); } | ||
168 | } | ||
169 | |||
170 | sub ::safeseh | ||
171 | { my $nm=shift; | ||
172 | push(@out,"%if __NASM_VERSION_ID__ >= 0x02030000\n"); | ||
173 | push(@out,"safeseh ".&::LABEL($nm,$nmdecor.$nm)."\n"); | ||
174 | push(@out,"%endif\n"); | ||
175 | } | ||
176 | |||
177 | 1; | ||
diff --git a/src/lib/libssl/src/crypto/perlasm/x86asm.pl b/src/lib/libssl/src/crypto/perlasm/x86asm.pl index bf783cff26..d74d1992f8 100644 --- a/src/lib/libssl/src/crypto/perlasm/x86asm.pl +++ b/src/lib/libssl/src/crypto/perlasm/x86asm.pl | |||
@@ -225,21 +225,13 @@ sub ::asm_init | |||
225 | $filename=$fn; | 225 | $filename=$fn; |
226 | $i386=$cpu; | 226 | $i386=$cpu; |
227 | 227 | ||
228 | $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$openbsd=$android=0; | 228 | $elf=$cpp=$coff=$aout=$macosx=$win32=$openbsd=$android=0; |
229 | if (($type eq "elf")) | 229 | if (($type eq "elf")) |
230 | { $elf=1; require "x86gas.pl"; } | 230 | { $elf=1; require "x86gas.pl"; } |
231 | elsif (($type eq "a\.out")) | 231 | elsif (($type eq "a\.out")) |
232 | { $aout=1; require "x86gas.pl"; } | 232 | { $aout=1; require "x86gas.pl"; } |
233 | elsif (($type eq "coff" or $type eq "gaswin")) | 233 | elsif (($type eq "coff" or $type eq "gaswin")) |
234 | { $coff=1; require "x86gas.pl"; } | 234 | { $coff=1; require "x86gas.pl"; } |
235 | elsif (($type eq "win32n")) | ||
236 | { $win32=1; require "x86nasm.pl"; } | ||
237 | elsif (($type eq "nw-nasm")) | ||
238 | { $netware=1; require "x86nasm.pl"; } | ||
239 | #elsif (($type eq "nw-mwasm")) | ||
240 | #{ $netware=1; $mwerks=1; require "x86nasm.pl"; } | ||
241 | elsif (($type eq "win32")) | ||
242 | { $win32=1; require "x86masm.pl"; } | ||
243 | elsif (($type eq "macosx")) | 235 | elsif (($type eq "macosx")) |
244 | { $aout=1; $macosx=1; require "x86gas.pl"; } | 236 | { $aout=1; $macosx=1; require "x86gas.pl"; } |
245 | elsif (($type eq "openbsd-elf")) | 237 | elsif (($type eq "openbsd-elf")) |
@@ -254,10 +246,8 @@ Pick one target type from | |||
254 | elf - Linux, FreeBSD, Solaris x86, etc. | 246 | elf - Linux, FreeBSD, Solaris x86, etc. |
255 | a.out - DJGPP, elder OpenBSD, etc. | 247 | a.out - DJGPP, elder OpenBSD, etc. |
256 | coff - GAS/COFF such as Win32 targets | 248 | coff - GAS/COFF such as Win32 targets |
257 | win32n - Windows 95/Windows NT NASM format | ||
258 | openbsd-elf - OpenBSD elf | 249 | openbsd-elf - OpenBSD elf |
259 | openbsd-a.out - OpenBSD a.out | 250 | openbsd-a.out - OpenBSD a.out |
260 | nw-nasm - NetWare NASM format | ||
261 | macosx - Mac OS X | 251 | macosx - Mac OS X |
262 | EOF | 252 | EOF |
263 | exit(1); | 253 | exit(1); |
diff --git a/src/lib/libssl/src/crypto/perlasm/x86masm.pl b/src/lib/libssl/src/crypto/perlasm/x86masm.pl deleted file mode 100644 index f937d07c87..0000000000 --- a/src/lib/libssl/src/crypto/perlasm/x86masm.pl +++ /dev/null | |||
@@ -1,198 +0,0 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | |||
3 | package x86masm; | ||
4 | |||
5 | *out=\@::out; | ||
6 | |||
7 | $::lbdecor="\$L"; # local label decoration | ||
8 | $nmdecor="_"; # external name decoration | ||
9 | |||
10 | $initseg=""; | ||
11 | $segment=""; | ||
12 | |||
13 | sub ::generic | ||
14 | { my ($opcode,@arg)=@_; | ||
15 | |||
16 | # fix hexadecimal constants | ||
17 | for (@arg) { s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/oi; } | ||
18 | |||
19 | if ($opcode =~ /lea/ && @arg[1] =~ s/.*PTR\s+(\(.*\))$/OFFSET $1/) # no [] | ||
20 | { $opcode="mov"; } | ||
21 | elsif ($opcode !~ /movq/) | ||
22 | { # fix xmm references | ||
23 | $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i); | ||
24 | $arg[1] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[0]=~/\bxmm[0-7]\b/i); | ||
25 | } | ||
26 | |||
27 | &::emit($opcode,@arg); | ||
28 | 1; | ||
29 | } | ||
30 | # | ||
31 | # opcodes not covered by ::generic above, mostly inconsistent namings... | ||
32 | # | ||
33 | sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } | ||
34 | sub ::call_ptr { &::emit("call",@_); } | ||
35 | sub ::jmp_ptr { &::emit("jmp",@_); } | ||
36 | sub ::lock { &::data_byte(0xf0); } | ||
37 | |||
38 | sub get_mem | ||
39 | { my($size,$addr,$reg1,$reg2,$idx)=@_; | ||
40 | my($post,$ret); | ||
41 | |||
42 | $ret .= "$size PTR " if ($size ne ""); | ||
43 | |||
44 | $addr =~ s/^\s+//; | ||
45 | # prepend global references with optional underscore | ||
46 | $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige; | ||
47 | # put address arithmetic expression in parenthesis | ||
48 | $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/); | ||
49 | |||
50 | if (($addr ne "") && ($addr ne 0)) | ||
51 | { if ($addr !~ /^-/) { $ret .= "$addr"; } | ||
52 | else { $post=$addr; } | ||
53 | } | ||
54 | $ret .= "["; | ||
55 | |||
56 | if ($reg2 ne "") | ||
57 | { $idx!=0 or $idx=1; | ||
58 | $ret .= "$reg2*$idx"; | ||
59 | $ret .= "+$reg1" if ($reg1 ne ""); | ||
60 | } | ||
61 | else | ||
62 | { $ret .= "$reg1"; } | ||
63 | |||
64 | $ret .= "$post]"; | ||
65 | $ret =~ s/\+\]/]/; # in case $addr was the only argument | ||
66 | $ret =~ s/\[\s*\]//; | ||
67 | |||
68 | $ret; | ||
69 | } | ||
70 | sub ::BP { &get_mem("BYTE",@_); } | ||
71 | sub ::WP { &get_mem("WORD",@_); } | ||
72 | sub ::DWP { &get_mem("DWORD",@_); } | ||
73 | sub ::QWP { &get_mem("QWORD",@_); } | ||
74 | sub ::BC { "@_"; } | ||
75 | sub ::DWC { "@_"; } | ||
76 | |||
77 | sub ::file | ||
78 | { my $tmp=<<___; | ||
79 | TITLE $_[0].asm | ||
80 | IF \@Version LT 800 | ||
81 | ECHO MASM version 8.00 or later is strongly recommended. | ||
82 | ENDIF | ||
83 | .486 | ||
84 | .MODEL FLAT | ||
85 | OPTION DOTNAME | ||
86 | IF \@Version LT 800 | ||
87 | .text\$ SEGMENT PAGE 'CODE' | ||
88 | ELSE | ||
89 | .text\$ SEGMENT ALIGN(64) 'CODE' | ||
90 | ENDIF | ||
91 | ___ | ||
92 | push(@out,$tmp); | ||
93 | $segment = ".text\$"; | ||
94 | } | ||
95 | |||
96 | sub ::function_begin_B | ||
97 | { my $func=shift; | ||
98 | my $global=($func !~ /^_/); | ||
99 | my $begin="${::lbdecor}_${func}_begin"; | ||
100 | |||
101 | &::LABEL($func,$global?"$begin":"$nmdecor$func"); | ||
102 | $func="ALIGN\t16\n".$nmdecor.$func."\tPROC"; | ||
103 | |||
104 | if ($global) { $func.=" PUBLIC\n${begin}::\n"; } | ||
105 | else { $func.=" PRIVATE\n"; } | ||
106 | push(@out,$func); | ||
107 | $::stack=4; | ||
108 | } | ||
109 | sub ::function_end_B | ||
110 | { my $func=shift; | ||
111 | |||
112 | push(@out,"$nmdecor$func ENDP\n"); | ||
113 | $::stack=0; | ||
114 | &::wipe_labels(); | ||
115 | } | ||
116 | |||
117 | sub ::file_end | ||
118 | { my $xmmheader=<<___; | ||
119 | .686 | ||
120 | .XMM | ||
121 | IF \@Version LT 800 | ||
122 | XMMWORD STRUCT 16 | ||
123 | DQ 2 dup (?) | ||
124 | XMMWORD ENDS | ||
125 | ENDIF | ||
126 | ___ | ||
127 | if (grep {/\b[x]?mm[0-7]\b/i} @out) { | ||
128 | grep {s/\.[3-7]86/$xmmheader/} @out; | ||
129 | } | ||
130 | |||
131 | push(@out,"$segment ENDS\n"); | ||
132 | |||
133 | if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) | ||
134 | { my $comm=<<___; | ||
135 | .bss SEGMENT 'BSS' | ||
136 | COMM ${nmdecor}OPENSSL_ia32cap_P:QWORD | ||
137 | .bss ENDS | ||
138 | ___ | ||
139 | # comment out OPENSSL_ia32cap_P declarations | ||
140 | grep {s/(^EXTERN\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out; | ||
141 | push (@out,$comm); | ||
142 | } | ||
143 | push (@out,$initseg) if ($initseg); | ||
144 | push (@out,"END\n"); | ||
145 | } | ||
146 | |||
147 | sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } } | ||
148 | |||
149 | *::set_label_B = sub | ||
150 | { my $l=shift; push(@out,$l.($l=~/^\Q${::lbdecor}\E[0-9]{3}/?":\n":"::\n")); }; | ||
151 | |||
152 | sub ::external_label | ||
153 | { foreach(@_) | ||
154 | { push(@out, "EXTERN\t".&::LABEL($_,$nmdecor.$_).":NEAR\n"); } | ||
155 | } | ||
156 | |||
157 | sub ::public_label | ||
158 | { push(@out,"PUBLIC\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } | ||
159 | |||
160 | sub ::data_byte | ||
161 | { push(@out,("DB\t").join(',',@_)."\n"); } | ||
162 | |||
163 | sub ::data_short | ||
164 | { push(@out,("DW\t").join(',',@_)."\n"); } | ||
165 | |||
166 | sub ::data_word | ||
167 | { push(@out,("DD\t").join(',',@_)."\n"); } | ||
168 | |||
169 | sub ::align | ||
170 | { push(@out,"ALIGN\t$_[0]\n"); } | ||
171 | |||
172 | sub ::picmeup | ||
173 | { my($dst,$sym)=@_; | ||
174 | &::lea($dst,&::DWP($sym)); | ||
175 | } | ||
176 | |||
177 | sub ::initseg | ||
178 | { my $f=$nmdecor.shift; | ||
179 | |||
180 | $initseg.=<<___; | ||
181 | .CRT\$XCU SEGMENT DWORD PUBLIC 'DATA' | ||
182 | EXTERN $f:NEAR | ||
183 | DD $f | ||
184 | .CRT\$XCU ENDS | ||
185 | ___ | ||
186 | } | ||
187 | |||
188 | sub ::dataseg | ||
189 | { push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA"; } | ||
190 | |||
191 | sub ::safeseh | ||
192 | { my $nm=shift; | ||
193 | push(@out,"IF \@Version GE 710\n"); | ||
194 | push(@out,".SAFESEH ".&::LABEL($nm,$nmdecor.$nm)."\n"); | ||
195 | push(@out,"ENDIF\n"); | ||
196 | } | ||
197 | |||
198 | 1; | ||
diff --git a/src/lib/libssl/src/crypto/perlasm/x86nasm.pl b/src/lib/libssl/src/crypto/perlasm/x86nasm.pl deleted file mode 100644 index ca2511c9eb..0000000000 --- a/src/lib/libssl/src/crypto/perlasm/x86nasm.pl +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | |||
3 | package x86nasm; | ||
4 | |||
5 | *out=\@::out; | ||
6 | |||
7 | $::lbdecor="L\$"; # local label decoration | ||
8 | $nmdecor=$::netware?"":"_"; # external name decoration | ||
9 | $drdecor=$::mwerks?".":""; # directive decoration | ||
10 | |||
11 | $initseg=""; | ||
12 | |||
13 | sub ::generic | ||
14 | { my $opcode=shift; | ||
15 | my $tmp; | ||
16 | |||
17 | if (!$::mwerks) | ||
18 | { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps | ||
19 | { $_[0] = "NEAR $_[0]"; } | ||
20 | elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea | ||
21 | { $_[1] =~ s/^[^\[]*\[/\[/o; } | ||
22 | elsif ($opcode eq "clflush" && $#_==0) | ||
23 | { $_[0] =~ s/^[^\[]*\[/\[/o; } | ||
24 | } | ||
25 | &::emit($opcode,@_); | ||
26 | 1; | ||
27 | } | ||
28 | # | ||
29 | # opcodes not covered by ::generic above, mostly inconsistent namings... | ||
30 | # | ||
31 | sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } | ||
32 | sub ::call_ptr { &::emit("call",@_); } | ||
33 | sub ::jmp_ptr { &::emit("jmp",@_); } | ||
34 | |||
35 | sub get_mem | ||
36 | { my($size,$addr,$reg1,$reg2,$idx)=@_; | ||
37 | my($post,$ret); | ||
38 | |||
39 | if ($size ne "") | ||
40 | { $ret .= "$size"; | ||
41 | $ret .= " PTR" if ($::mwerks); | ||
42 | $ret .= " "; | ||
43 | } | ||
44 | $ret .= "["; | ||
45 | |||
46 | $addr =~ s/^\s+//; | ||
47 | # prepend global references with optional underscore | ||
48 | $addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige; | ||
49 | # put address arithmetic expression in parenthesis | ||
50 | $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/); | ||
51 | |||
52 | if (($addr ne "") && ($addr ne 0)) | ||
53 | { if ($addr !~ /^-/) { $ret .= "$addr+"; } | ||
54 | else { $post=$addr; } | ||
55 | } | ||
56 | |||
57 | if ($reg2 ne "") | ||
58 | { $idx!=0 or $idx=1; | ||
59 | $ret .= "$reg2*$idx"; | ||
60 | $ret .= "+$reg1" if ($reg1 ne ""); | ||
61 | } | ||
62 | else | ||
63 | { $ret .= "$reg1"; } | ||
64 | |||
65 | $ret .= "$post]"; | ||
66 | $ret =~ s/\+\]/]/; # in case $addr was the only argument | ||
67 | |||
68 | $ret; | ||
69 | } | ||
70 | sub ::BP { &get_mem("BYTE",@_); } | ||
71 | sub ::DWP { &get_mem("DWORD",@_); } | ||
72 | sub ::WP { &get_mem("WORD",@_); } | ||
73 | sub ::QWP { &get_mem("",@_); } | ||
74 | sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; } | ||
75 | sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; } | ||
76 | |||
77 | sub ::file | ||
78 | { if ($::mwerks) { push(@out,".section\t.text,64\n"); } | ||
79 | else | ||
80 | { my $tmp=<<___; | ||
81 | %ifidn __OUTPUT_FORMAT__,obj | ||
82 | section code use32 class=code align=64 | ||
83 | %elifidn __OUTPUT_FORMAT__,win32 | ||
84 | \$\@feat.00 equ 1 | ||
85 | section .text code align=64 | ||
86 | %else | ||
87 | section .text code | ||
88 | %endif | ||
89 | ___ | ||
90 | push(@out,$tmp); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | sub ::function_begin_B | ||
95 | { my $func=shift; | ||
96 | my $global=($func !~ /^_/); | ||
97 | my $begin="${::lbdecor}_${func}_begin"; | ||
98 | |||
99 | $begin =~ s/^\@/./ if ($::mwerks); # the torture never stops | ||
100 | |||
101 | &::LABEL($func,$global?"$begin":"$nmdecor$func"); | ||
102 | $func=$nmdecor.$func; | ||
103 | |||
104 | push(@out,"${drdecor}global $func\n") if ($global); | ||
105 | push(@out,"${drdecor}align 16\n"); | ||
106 | push(@out,"$func:\n"); | ||
107 | push(@out,"$begin:\n") if ($global); | ||
108 | $::stack=4; | ||
109 | } | ||
110 | |||
111 | sub ::function_end_B | ||
112 | { $::stack=0; | ||
113 | &::wipe_labels(); | ||
114 | } | ||
115 | |||
116 | sub ::file_end | ||
117 | { if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) | ||
118 | { my $comm=<<___; | ||
119 | ${drdecor}segment .bss | ||
120 | ${drdecor}common ${nmdecor}OPENSSL_ia32cap_P 8 | ||
121 | ___ | ||
122 | # comment out OPENSSL_ia32cap_P declarations | ||
123 | grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out; | ||
124 | push (@out,$comm) | ||
125 | } | ||
126 | push (@out,$initseg) if ($initseg); | ||
127 | } | ||
128 | |||
129 | sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } } | ||
130 | |||
131 | sub ::external_label | ||
132 | { foreach(@_) | ||
133 | { push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); } | ||
134 | } | ||
135 | |||
136 | sub ::public_label | ||
137 | { push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } | ||
138 | |||
139 | sub ::data_byte | ||
140 | { push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); } | ||
141 | sub ::data_short | ||
142 | { push(@out,(($::mwerks)?".word\t":"dw\t").join(',',@_)."\n"); } | ||
143 | sub ::data_word | ||
144 | { push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); } | ||
145 | |||
146 | sub ::align | ||
147 | { push(@out,"${drdecor}align\t$_[0]\n"); } | ||
148 | |||
149 | sub ::picmeup | ||
150 | { my($dst,$sym)=@_; | ||
151 | &::lea($dst,&::DWP($sym)); | ||
152 | } | ||
153 | |||
154 | sub ::initseg | ||
155 | { my $f=$nmdecor.shift; | ||
156 | if ($::win32) | ||
157 | { $initseg=<<___; | ||
158 | segment .CRT\$XCU data align=4 | ||
159 | extern $f | ||
160 | dd $f | ||
161 | ___ | ||
162 | } | ||
163 | } | ||
164 | |||
165 | sub ::dataseg | ||
166 | { if ($mwerks) { push(@out,".section\t.data,4\n"); } | ||
167 | else { push(@out,"section\t.data align=4\n"); } | ||
168 | } | ||
169 | |||
170 | sub ::safeseh | ||
171 | { my $nm=shift; | ||
172 | push(@out,"%if __NASM_VERSION_ID__ >= 0x02030000\n"); | ||
173 | push(@out,"safeseh ".&::LABEL($nm,$nmdecor.$nm)."\n"); | ||
174 | push(@out,"%endif\n"); | ||
175 | } | ||
176 | |||
177 | 1; | ||