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/x86gas.pl
+++ new/usr/src/lib/openssl/libsunw_crypto/pl/x86gas.pl
1 1 #!/usr/bin/env perl
2 2
3 3 package x86gas;
4 4
5 5 *out=\@::out;
6 6
7 7 $::lbdecor=$::aout?"L":".L"; # local label decoration
8 -$nmdecor=($::aout or $::coff)?"_":""; # external name decoration
8 +$nmdecor=($::aout or $::coff)?"_":"sunw_"; # external name decoration
9 9
10 10 $initseg="";
11 11
12 12 $align=16;
13 13 $align=log($align)/log(2) if ($::aout);
14 14 $com_start="#" if ($::aout or $::coff);
15 15
16 16 sub opsize()
17 17 { my $reg=shift;
18 18 if ($reg =~ m/^%e/o) { "l"; }
19 19 elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; }
20 20 elsif ($reg =~ m/^%[xm]/o) { undef; }
21 21 else { "w"; }
22 22 }
23 23
24 24 # swap arguments;
25 25 # expand opcode with size suffix;
26 26 # prefix numeric constants with $;
27 27 sub ::generic
28 28 { my($opcode,@arg)=@_;
29 29 my($suffix,$dst,$src);
30 30
31 31 @arg=reverse(@arg);
32 32
33 33 for (@arg)
34 34 { s/^(\*?)(e?[a-dsixphl]{2})$/$1%$2/o; # gp registers
35 35 s/^([xy]?mm[0-7])$/%$1/o; # xmm/mmx registers
36 36 s/^(\-?[0-9]+)$/\$$1/o; # constants
37 37 s/^(\-?0x[0-9a-f]+)$/\$$1/o; # constants
38 38 }
39 39
40 40 $dst = $arg[$#arg] if ($#arg>=0);
41 41 $src = $arg[$#arg-1] if ($#arg>=1);
42 42 if ($dst =~ m/^%/o) { $suffix=&opsize($dst); }
43 43 elsif ($src =~ m/^%/o) { $suffix=&opsize($src); }
44 44 else { $suffix="l"; }
45 45 undef $suffix if ($dst =~ m/^%[xm]/o || $src =~ m/^%[xm]/o);
46 46
47 47 if ($#_==0) { &::emit($opcode); }
48 48 elsif ($#_==1 && $opcode =~ m/^(call|clflush|j|loop|set)/o)
49 49 { &::emit($opcode,@arg); }
50 50 else { &::emit($opcode.$suffix,@arg);}
51 51
52 52 1;
53 53 }
54 54 #
55 55 # opcodes not covered by ::generic above, mostly inconsistent namings...
56 56 #
57 57 sub ::movzx { &::movzb(@_); }
58 58 sub ::pushfd { &::pushfl; }
59 59 sub ::popfd { &::popfl; }
60 60 sub ::cpuid { &::emit(".byte\t0x0f,0xa2"); }
61 61 sub ::rdtsc { &::emit(".byte\t0x0f,0x31"); }
62 62
63 63 sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
64 64 sub ::call_ptr { &::generic("call","*$_[0]"); }
65 65 sub ::jmp_ptr { &::generic("jmp","*$_[0]"); }
66 66
67 67 *::bswap = sub { &::emit("bswap","%$_[0]"); } if (!$::i386);
68 68
69 69 sub ::DWP
70 70 { my($addr,$reg1,$reg2,$idx)=@_;
71 71 my $ret="";
72 72
73 73 $addr =~ s/^\s+//;
74 74 # prepend global references with optional underscore
75 75 $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige;
76 76
77 77 $reg1 = "%$reg1" if ($reg1);
78 78 $reg2 = "%$reg2" if ($reg2);
79 79
80 80 $ret .= $addr if (($addr ne "") && ($addr ne 0));
81 81
82 82 if ($reg2)
83 83 { $idx!= 0 or $idx=1;
84 84 $ret .= "($reg1,$reg2,$idx)";
85 85 }
86 86 elsif ($reg1)
87 87 { $ret .= "($reg1)"; }
88 88
89 89 $ret;
90 90 }
91 91 sub ::QWP { &::DWP(@_); }
92 92 sub ::BP { &::DWP(@_); }
93 93 sub ::WP { &::DWP(@_); }
94 94 sub ::BC { @_; }
95 95 sub ::DWC { @_; }
96 96
97 97 sub ::file
98 98 { push(@out,".file\t\"$_[0].s\"\n.text\n"); }
99 99
100 100 sub ::function_begin_B
101 101 { my $func=shift;
102 102 my $global=($func !~ /^_/);
103 103 my $begin="${::lbdecor}_${func}_begin";
104 104
105 105 &::LABEL($func,$global?"$begin":"$nmdecor$func");
106 106 $func=$nmdecor.$func;
107 107
108 108 push(@out,".globl\t$func\n") if ($global);
109 109 if ($::coff)
110 110 { push(@out,".def\t$func;\t.scl\t".(3-$global).";\t.type\t32;\t.endef\n"); }
111 111 elsif (($::aout and !$::pic) or $::macosx)
112 112 { }
113 113 else
114 114 { push(@out,".type $func,\@function\n"); }
115 115 push(@out,".align\t$align\n");
116 116 push(@out,"$func:\n");
117 117 push(@out,"$begin:\n") if ($global);
118 118 $::stack=4;
119 119 }
120 120
121 121 sub ::function_end_B
122 122 { my $func=shift;
123 123 push(@out,".size\t$nmdecor$func,.-".&::LABEL($func)."\n") if ($::elf);
124 124 $::stack=0;
125 125 &::wipe_labels();
126 126 }
127 127
128 128 sub ::comment
129 129 {
130 130 if (!defined($com_start) or $::elf)
131 131 { # Regarding $::elf above...
132 132 # GNU and SVR4 as'es use different comment delimiters,
133 133 push(@out,"\n"); # so we just skip ELF comments...
134 134 return;
135 135 }
136 136 foreach (@_)
137 137 {
138 138 if (/^\s*$/)
139 139 { push(@out,"\n"); }
140 140 else
141 141 { push(@out,"\t$com_start $_ $com_end\n"); }
142 142 }
143 143 }
144 144
145 145 sub ::external_label
146 146 { foreach(@_) { &::LABEL($_,$nmdecor.$_); } }
147 147
148 148 sub ::public_label
149 149 { push(@out,".globl\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
150 150
151 151 sub ::file_end
152 152 { if ($::macosx)
153 153 { if (%non_lazy_ptr)
154 154 { push(@out,".section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
155 155 foreach $i (keys %non_lazy_ptr)
156 156 { push(@out,"$non_lazy_ptr{$i}:\n.indirect_symbol\t$i\n.long\t0\n"); }
157 157 }
158 158 }
159 159 if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) {
160 160 my $tmp=".comm\t${nmdecor}OPENSSL_ia32cap_P,8";
161 161 if ($::macosx) { push (@out,"$tmp,2\n"); }
162 162 elsif ($::elf) { push (@out,"$tmp,4\n"); }
163 163 else { push (@out,"$tmp\n"); }
164 164 }
165 165 push(@out,$initseg) if ($initseg);
166 166 }
167 167
168 168 sub ::data_byte { push(@out,".byte\t".join(',',@_)."\n"); }
169 169 sub ::data_short{ push(@out,".value\t".join(',',@_)."\n"); }
170 170 sub ::data_word { push(@out,".long\t".join(',',@_)."\n"); }
171 171
172 172 sub ::align
173 173 { my $val=$_[0],$p2,$i;
174 174 if ($::aout)
175 175 { for ($p2=0;$val!=0;$val>>=1) { $p2++; }
176 176 $val=$p2-1;
177 177 $val.=",0x90";
178 178 }
179 179 push(@out,".align\t$val\n");
180 180 }
181 181
182 182 sub ::picmeup
183 183 { my($dst,$sym,$base,$reflabel)=@_;
184 184
185 185 if (($::pic && ($::elf || $::aout)) || $::macosx)
186 186 { if (!defined($base))
187 187 { &::call(&::label("PIC_me_up"));
188 188 &::set_label("PIC_me_up");
189 189 &::blindpop($dst);
190 190 $base=$dst;
191 191 $reflabel=&::label("PIC_me_up");
192 192 }
193 193 if ($::macosx)
194 194 { my $indirect=&::static_label("$nmdecor$sym\$non_lazy_ptr");
195 195 &::mov($dst,&::DWP("$indirect-$reflabel",$base));
196 196 $non_lazy_ptr{"$nmdecor$sym"}=$indirect;
197 197 }
198 198 else
199 199 { &::lea($dst,&::DWP("_GLOBAL_OFFSET_TABLE_+[.-$reflabel]",
200 200 $base));
201 201 &::mov($dst,&::DWP("$sym\@GOT",$dst));
202 202 }
203 203 }
204 204 else
205 205 { &::lea($dst,&::DWP($sym)); }
206 206 }
207 207
208 208 sub ::initseg
209 209 { my $f=$nmdecor.shift;
210 210
211 211 if ($::android)
212 212 { $initseg.=<<___;
213 213 .section .init_array
214 214 .align 4
215 215 .long $f
216 216 ___
217 217 }
218 218 elsif ($::elf)
219 219 { $initseg.=<<___;
220 220 .section .init
221 221 call $f
222 222 ___
223 223 }
224 224 elsif ($::coff)
225 225 { $initseg.=<<___; # applies to both Cygwin and Mingw
226 226 .section .ctors
227 227 .long $f
228 228 ___
229 229 }
230 230 elsif ($::macosx)
231 231 { $initseg.=<<___;
232 232 .mod_init_func
233 233 .align 2
234 234 .long $f
235 235 ___
236 236 }
237 237 elsif ($::aout)
238 238 { my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
239 239 $initseg.=".text\n";
240 240 $initseg.=".type $ctor,\@function\n" if ($::pic);
241 241 $initseg.=<<___; # OpenBSD way...
↓ open down ↓ |
223 lines elided |
↑ open up ↑ |
242 242 .globl $ctor
243 243 .align 2
244 244 $ctor:
245 245 jmp $f
246 246 ___
247 247 }
248 248 }
249 249
250 250 sub ::dataseg
251 251 { push(@out,".data\n"); }
252 +
253 +*::hidden = sub { push(@out,".hidden\t$nmdecor$_[0]\n"); } if ($::elf);
252 254
253 255 1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX