Print this page
4853 illumos-gate is not lint-clean when built with openssl 1.0
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/openssl/libsunw_crypto/pl/x86asm.pl
+++ new/usr/src/lib/openssl/libsunw_crypto/pl/x86asm.pl
1 1 #!/usr/bin/env perl
2 2
3 3 # require 'x86asm.pl';
4 4 # &asm_init(<flavor>,"des-586.pl"[,$i386only]);
5 5 # &function_begin("foo");
6 6 # ...
7 7 # &function_end("foo");
8 8 # &asm_finish
9 9
10 10 $out=();
11 11 $i386=0;
12 12
13 13 # AUTOLOAD is this context has quite unpleasant side effect, namely
14 14 # that typos in function calls effectively go to assembler output,
15 15 # but on the pros side we don't have to implement one subroutine per
16 16 # each opcode...
17 17 sub ::AUTOLOAD
18 18 { my $opcode = $AUTOLOAD;
19 19
20 20 die "more than 4 arguments passed to $opcode" if ($#_>3);
21 21
22 22 $opcode =~ s/.*:://;
23 23 if ($opcode =~ /^push/) { $stack+=4; }
24 24 elsif ($opcode =~ /^pop/) { $stack-=4; }
25 25
26 26 &generic($opcode,@_) or die "undefined subroutine \&$AUTOLOAD";
27 27 }
28 28
29 29 sub ::emit
30 30 { my $opcode=shift;
31 31
32 32 if ($#_==-1) { push(@out,"\t$opcode\n"); }
33 33 else { push(@out,"\t$opcode\t".join(',',@_)."\n"); }
34 34 }
35 35
36 36 sub ::LB
37 37 { $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'";
38 38 $1."l";
39 39 }
40 40 sub ::HB
41 41 { $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'high byte'";
42 42 $1."h";
43 43 }
44 44 sub ::stack_push{ my $num=$_[0]*4; $stack+=$num; &sub("esp",$num); }
45 45 sub ::stack_pop { my $num=$_[0]*4; $stack-=$num; &add("esp",$num); }
46 46 sub ::blindpop { &pop($_[0]); $stack+=4; }
47 47 sub ::wparam { &DWP($stack+4*$_[0],"esp"); }
48 48 sub ::swtmp { &DWP(4*$_[0],"esp"); }
49 49
50 50 sub ::bswap
51 51 { if ($i386) # emulate bswap for i386
52 52 { &comment("bswap @_");
53 53 &xchg(&HB(@_),&LB(@_));
54 54 &ror (@_,16);
55 55 &xchg(&HB(@_),&LB(@_));
56 56 }
57 57 else
58 58 { &generic("bswap",@_); }
59 59 }
60 60 # These are made-up opcodes introduced over the years essentially
61 61 # by ignorance, just alias them to real ones...
62 62 sub ::movb { &mov(@_); }
63 63 sub ::xorb { &xor(@_); }
64 64 sub ::rotl { &rol(@_); }
65 65 sub ::rotr { &ror(@_); }
66 66 sub ::exch { &xchg(@_); }
67 67 sub ::halt { &hlt; }
68 68 sub ::movz { &movzx(@_); }
69 69 sub ::pushf { &pushfd; }
70 70 sub ::popf { &popfd; }
71 71
72 72 # 3 argument instructions
73 73 sub ::movq
74 74 { my($p1,$p2,$optimize)=@_;
75 75
76 76 if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
77 77 # movq between mmx registers can sink Intel CPUs
78 78 { &::pshufw($p1,$p2,0xe4); }
79 79 else
80 80 { &::generic("movq",@_); }
81 81 }
82 82
83 83 # SSE>2 instructions
84 84 my %regrm = ( "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3,
85 85 "esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7 );
86 86 sub ::pextrd
87 87 { my($dst,$src,$imm)=@_;
88 88 if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/)
89 89 { &::data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm); }
90 90 else
91 91 { &::generic("pextrd",@_); }
92 92 }
93 93
94 94 sub ::pinsrd
95 95 { my($dst,$src,$imm)=@_;
96 96 if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/)
97 97 { &::data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm); }
98 98 else
99 99 { &::generic("pinsrd",@_); }
100 100 }
101 101
102 102 sub ::pshufb
103 103 { my($dst,$src)=@_;
104 104 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
105 105 { &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2); }
106 106 else
107 107 { &::generic("pshufb",@_); }
108 108 }
109 109
110 110 sub ::palignr
111 111 { my($dst,$src,$imm)=@_;
112 112 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
113 113 { &::data_byte(0x66,0x0f,0x3a,0x0f,0xc0|($1<<3)|$2,$imm); }
114 114 else
115 115 { &::generic("palignr",@_); }
116 116 }
117 117
118 118 sub ::pclmulqdq
119 119 { my($dst,$src,$imm)=@_;
120 120 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
121 121 { &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); }
122 122 else
123 123 { &::generic("pclmulqdq",@_); }
124 124 }
125 125
126 126 sub ::rdrand
127 127 { my ($dst)=@_;
128 128 if ($dst =~ /(e[a-dsd][ixp])/)
129 129 { &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
↓ open down ↓ |
129 lines elided |
↑ open up ↑ |
130 130 else
131 131 { &::generic("rdrand",@_); }
132 132 }
133 133
134 134 # label management
135 135 $lbdecor="L"; # local label decoration, set by package
136 136 $label="000";
137 137
138 138 sub ::islabel # see is argument is a known label
139 139 { my $i;
140 + if ($_[0] eq "_GLOBAL_OFFSET_TABLE_") { return $_[0]; }
140 141 foreach $i (values %label) { return $i if ($i eq $_[0]); }
141 142 $label{$_[0]}; # can be undef
142 143 }
143 144
144 145 sub ::label # instantiate a function-scope label
145 146 { if (!defined($label{$_[0]}))
146 147 { $label{$_[0]}="${lbdecor}${label}${_[0]}"; $label++; }
147 148 $label{$_[0]};
148 149 }
149 150
150 151 sub ::LABEL # instantiate a file-scope label
151 152 { $label{$_[0]}=$_[1] if (!defined($label{$_[0]}));
152 153 $label{$_[0]};
153 154 }
154 155
155 156 sub ::static_label { &::LABEL($_[0],$lbdecor.$_[0]); }
156 157
157 158 sub ::set_label_B { push(@out,"@_:\n"); }
158 159 sub ::set_label
159 160 { my $label=&::label($_[0]);
160 161 &::align($_[1]) if ($_[1]>1);
161 162 &::set_label_B($label);
162 163 $label;
163 164 }
164 165
165 166 sub ::wipe_labels # wipes function-scope labels
166 167 { foreach $i (keys %label)
167 168 { delete $label{$i} if ($label{$i} =~ /^\Q${lbdecor}\E[0-9]{3}/); }
168 169 }
169 170
170 171 # subroutine management
171 172 sub ::function_begin
172 173 { &function_begin_B(@_);
173 174 $stack=4;
174 175 &push("ebp");
175 176 &push("ebx");
176 177 &push("esi");
177 178 &push("edi");
178 179 }
179 180
180 181 sub ::function_end
181 182 { &pop("edi");
182 183 &pop("esi");
183 184 &pop("ebx");
184 185 &pop("ebp");
185 186 &ret();
186 187 &function_end_B(@_);
187 188 $stack=0;
188 189 &wipe_labels();
189 190 }
190 191
191 192 sub ::function_end_A
192 193 { &pop("edi");
193 194 &pop("esi");
194 195 &pop("ebx");
195 196 &pop("ebp");
196 197 &ret();
197 198 $stack+=16; # readjust esp as if we didn't pop anything
198 199 }
199 200
200 201 sub ::asciz
201 202 { my @str=unpack("C*",shift);
202 203 push @str,0;
203 204 while ($#str>15) {
204 205 &data_byte(@str[0..15]);
205 206 foreach (0..15) { shift @str; }
206 207 }
207 208 &data_byte(@str) if (@str);
208 209 }
209 210
210 211 sub ::asm_finish
211 212 { &file_end();
212 213 print @out;
213 214 }
214 215
215 216 sub ::asm_init
216 217 { my ($type,$fn,$cpu)=@_;
217 218
218 219 $filename=$fn;
219 220 $i386=$cpu;
220 221
221 222 $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$android=0;
222 223 if (($type eq "elf"))
223 224 { $elf=1; require "x86gas.pl"; }
224 225 elsif (($type eq "a\.out"))
225 226 { $aout=1; require "x86gas.pl"; }
226 227 elsif (($type eq "coff" or $type eq "gaswin"))
227 228 { $coff=1; require "x86gas.pl"; }
228 229 elsif (($type eq "win32n"))
229 230 { $win32=1; require "x86nasm.pl"; }
230 231 elsif (($type eq "nw-nasm"))
231 232 { $netware=1; require "x86nasm.pl"; }
232 233 #elsif (($type eq "nw-mwasm"))
233 234 #{ $netware=1; $mwerks=1; require "x86nasm.pl"; }
234 235 elsif (($type eq "win32"))
235 236 { $win32=1; require "x86masm.pl"; }
236 237 elsif (($type eq "macosx"))
237 238 { $aout=1; $macosx=1; require "x86gas.pl"; }
238 239 elsif (($type eq "android"))
239 240 { $elf=1; $android=1; require "x86gas.pl"; }
240 241 else
241 242 { print STDERR <<"EOF";
242 243 Pick one target type from
243 244 elf - Linux, FreeBSD, Solaris x86, etc.
244 245 a.out - DJGPP, elder OpenBSD, etc.
245 246 coff - GAS/COFF such as Win32 targets
246 247 win32n - Windows 95/Windows NT NASM format
247 248 nw-nasm - NetWare NASM format
248 249 macosx - Mac OS X
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
249 250 EOF
250 251 exit(1);
251 252 }
252 253
253 254 $pic=0;
254 255 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
255 256
256 257 $filename =~ s/\.pl$//;
257 258 &file($filename);
258 259 }
260 +
261 +sub ::hidden {}
259 262
260 263 1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX