summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/perlasm/x86unix.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/perlasm/x86unix.pl')
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index a31a25c12b..b61425e951 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -15,6 +15,12 @@ sub main'asm_get_output { return(@out); }
15sub main'get_labels { return(@labels); } 15sub main'get_labels { return(@labels); }
16sub main'external_label { push(@labels,@_); } 16sub main'external_label { push(@labels,@_); }
17 17
18if ($main'openbsd)
19 {
20 $com_start='/*';
21 $com_end='*/';
22 }
23
18if ($main'cpp) 24if ($main'cpp)
19 { 25 {
20 $align="ALIGN"; 26 $align="ALIGN";
@@ -173,7 +179,9 @@ sub main'not { &out1("notl",@_); }
173sub main'call { &out1("call",($_[0]=~/^\.L/?'':$under).$_[0]); } 179sub main'call { &out1("call",($_[0]=~/^\.L/?'':$under).$_[0]); }
174sub main'ret { &out0("ret"); } 180sub main'ret { &out0("ret"); }
175sub main'nop { &out0("nop"); } 181sub main'nop { &out0("nop"); }
182sub main'test { &out2("testl",@_); }
176sub main'movz { &out2("movzbl",@_); } 183sub main'movz { &out2("movzbl",@_); }
184sub main'neg { &out1("negl",@_); }
177 185
178# The bswapl instruction is new for the 486. Emulate if i386. 186# The bswapl instruction is new for the 486. Emulate if i386.
179sub main'bswap 187sub main'bswap
@@ -277,6 +285,9 @@ sub main'file
277 { 285 {
278 local($file)=@_; 286 local($file)=@_;
279 287
288 if ($main'openbsd)
289 { push(@out,"#include <machine/asm.h>\n"); return; }
290
280 local($tmp)=<<"EOF"; 291 local($tmp)=<<"EOF";
281 .file "$file.s" 292 .file "$file.s"
282 .version "01.01" 293 .version "01.01"
@@ -292,6 +303,9 @@ sub main'function_begin
292 &main'external_label($func); 303 &main'external_label($func);
293 $func=$under.$func; 304 $func=$under.$func;
294 305
306 if ($main'openbsd)
307 { push (@out, "\nENTRY($func)\n"); goto skip; }
308
295 local($tmp)=<<"EOF"; 309 local($tmp)=<<"EOF";
296.text 310.text
297 .align $align 311 .align $align
@@ -304,6 +318,7 @@ EOF
304 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } 318 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
305 else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } 319 else { $tmp=push(@out,"\t.type\t$func,\@function\n"); }
306 push(@out,"$func:\n"); 320 push(@out,"$func:\n");
321skip:
307 $tmp=<<"EOF"; 322 $tmp=<<"EOF";
308 pushl %ebp 323 pushl %ebp
309 pushl %ebx 324 pushl %ebx
@@ -322,6 +337,9 @@ sub main'function_begin_B
322 &main'external_label($func); 337 &main'external_label($func);
323 $func=$under.$func; 338 $func=$under.$func;
324 339
340 if ($main'openbsd)
341 { push(@out, "\nENTRY($func)\n"); goto skip; }
342
325 local($tmp)=<<"EOF"; 343 local($tmp)=<<"EOF";
326.text 344.text
327 .align $align 345 .align $align
@@ -334,6 +352,7 @@ EOF
334 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } 352 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
335 else { push(@out,"\t.type $func,\@function\n"); } 353 else { push(@out,"\t.type $func,\@function\n"); }
336 push(@out,"$func:\n"); 354 push(@out,"$func:\n");
355skip:
337 $stack=4; 356 $stack=4;
338 } 357 }
339 358
@@ -430,7 +449,8 @@ sub main'swtmp
430 449
431sub main'comment 450sub main'comment
432 { 451 {
433 if ($main'elf) # GNU and SVR4 as'es use different comment delimiters, 452 if (!$main'openbsd && $main'elf)
453 # GNU and SVR4 as'es use different comment delimiters,
434 { # so we just skip comments... 454 { # so we just skip comments...
435 push(@out,"\n"); 455 push(@out,"\n");
436 return; 456 return;
@@ -444,6 +464,12 @@ sub main'comment
444 } 464 }
445 } 465 }
446 466
467sub main'public_label
468 {
469 $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
470 push(@out,".globl\t$label{$_[0]}\n");
471 }
472
447sub main'label 473sub main'label
448 { 474 {
449 if (!defined($label{$_[0]})) 475 if (!defined($label{$_[0]}))
@@ -461,7 +487,10 @@ sub main'set_label
461 $label{$_[0]}=".${label}${_[0]}"; 487 $label{$_[0]}=".${label}${_[0]}";
462 $label++; 488 $label++;
463 } 489 }
464 push(@out,".align $align\n") if ($_[1] != 0); 490 if ($main'openbsd)
491 { push(@out,"_ALIGN_TEXT\n") if ($_[1] != 0); }
492 else
493 { push(@out,".align $align\n") if ($_[1] != 0); }
465 push(@out,"$label{$_[0]}:\n"); 494 push(@out,"$label{$_[0]}:\n");
466 } 495 }
467 496
@@ -477,7 +506,7 @@ sub main'file_end
477 506
478sub main'data_word 507sub main'data_word
479 { 508 {
480 push(@out,"\t.long $_[0]\n"); 509 push(@out,"\t.long\t".join(',',@_)."\n");
481 } 510 }
482 511
483# debug output functions: puts, putx, printf 512# debug output functions: puts, putx, printf
@@ -570,6 +599,16 @@ sub main'picmeup
570___ 599___
571 push(@out,$tmp); 600 push(@out,$tmp);
572 } 601 }
602 elsif ($main'openbsd)
603 {
604 push(@out, "#ifdef PIC\n");
605 push(@out, "\tPIC_PROLOGUE\n");
606 &main'mov($dst,"PIC_GOT($sym)");
607 push(@out, "\tPIC_EPILOGUE\n");
608 push(@out, "#else\n");
609 &main'lea($dst,&main'DWP($sym));
610 push(@out, "#endif\n");
611 }
573 elsif ($main'pic && ($main'elf || $main'aout)) 612 elsif ($main'pic && ($main'elf || $main'aout))
574 { 613 {
575 push(@out,"\t.align\t8\n"); 614 push(@out,"\t.align\t8\n");