diff options
Diffstat (limited to 'src/lib/libcrypto/perlasm/x86unix.pl')
-rw-r--r-- | src/lib/libcrypto/perlasm/x86unix.pl | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl index a4c947165e..ae8f0964dc 100644 --- a/src/lib/libcrypto/perlasm/x86unix.pl +++ b/src/lib/libcrypto/perlasm/x86unix.pl | |||
@@ -16,6 +16,12 @@ sub main'asm_get_output { return(@out); } | |||
16 | sub main'get_labels { return(@labels); } | 16 | sub main'get_labels { return(@labels); } |
17 | sub main'external_label { push(@labels,@_); } | 17 | sub main'external_label { push(@labels,@_); } |
18 | 18 | ||
19 | if ($main'openbsd) | ||
20 | { | ||
21 | $com_start='/*'; | ||
22 | $com_end='*/'; | ||
23 | } | ||
24 | |||
19 | if ($main'cpp) | 25 | if ($main'cpp) |
20 | { | 26 | { |
21 | $align="ALIGN"; | 27 | $align="ALIGN"; |
@@ -338,6 +344,9 @@ sub main'file | |||
338 | { | 344 | { |
339 | local($file)=@_; | 345 | local($file)=@_; |
340 | 346 | ||
347 | if ($main'openbsd) | ||
348 | { push(@out,"#include <machine/asm.h>\n"); } | ||
349 | |||
341 | local($tmp)=<<"EOF"; | 350 | local($tmp)=<<"EOF"; |
342 | .file "$file.s" | 351 | .file "$file.s" |
343 | EOF | 352 | EOF |
@@ -346,11 +355,18 @@ EOF | |||
346 | 355 | ||
347 | sub main'function_begin | 356 | sub main'function_begin |
348 | { | 357 | { |
349 | local($func)=@_; | 358 | local($func,$junk,$llabel)=@_; |
350 | 359 | ||
351 | &main'external_label($func); | 360 | &main'external_label($func); |
352 | $func=$under.$func; | 361 | $func=$under.$func; |
353 | 362 | ||
363 | if ($main'openbsd) | ||
364 | { | ||
365 | push (@out, "\nENTRY($func)\n"); | ||
366 | push (@out, "$llabel:\n") if $llabel; | ||
367 | goto skip; | ||
368 | } | ||
369 | |||
354 | local($tmp)=<<"EOF"; | 370 | local($tmp)=<<"EOF"; |
355 | .text | 371 | .text |
356 | .globl $func | 372 | .globl $func |
@@ -365,6 +381,7 @@ EOF | |||
365 | else { $tmp=push(@out,".type\t$func,\@function\n"); } | 381 | else { $tmp=push(@out,".type\t$func,\@function\n"); } |
366 | push(@out,".align\t$align\n"); | 382 | push(@out,".align\t$align\n"); |
367 | push(@out,"$func:\n"); | 383 | push(@out,"$func:\n"); |
384 | skip: | ||
368 | $tmp=<<"EOF"; | 385 | $tmp=<<"EOF"; |
369 | pushl %ebp | 386 | pushl %ebp |
370 | pushl %ebx | 387 | pushl %ebx |
@@ -383,6 +400,47 @@ sub main'function_begin_B | |||
383 | &main'external_label($func); | 400 | &main'external_label($func); |
384 | $func=$under.$func; | 401 | $func=$under.$func; |
385 | 402 | ||
403 | if ($main'openbsd) | ||
404 | { push(@out, "\nENTRY($func)\n"); goto skip; } | ||
405 | |||
406 | local($tmp)=<<"EOF"; | ||
407 | .text | ||
408 | .globl $func | ||
409 | EOF | ||
410 | push(@out,$tmp); | ||
411 | if ($main'cpp) | ||
412 | { push(@out,"TYPE($func,\@function)\n"); } | ||
413 | elsif ($main'coff) | ||
414 | { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } | ||
415 | elsif ($main'aout and !$main'pic) | ||
416 | { } | ||
417 | else { push(@out,".type $func,\@function\n"); } | ||
418 | push(@out,".align\t$align\n"); | ||
419 | push(@out,"$func:\n"); | ||
420 | skip: | ||
421 | $stack=4; | ||
422 | } | ||
423 | |||
424 | # Like function_begin_B but with static linkage | ||
425 | sub main'function_begin_C | ||
426 | { | ||
427 | local($func,$extra)=@_; | ||
428 | |||
429 | &main'external_label($func); | ||
430 | $func=$under.$func; | ||
431 | |||
432 | if ($main'openbsd) | ||
433 | { | ||
434 | local($tmp)=<<"EOF"; | ||
435 | .text | ||
436 | _ALIGN_TEXT | ||
437 | .type $func,\@function | ||
438 | $func: | ||
439 | EOF | ||
440 | push(@out, $tmp); | ||
441 | goto skip; | ||
442 | } | ||
443 | |||
386 | local($tmp)=<<"EOF"; | 444 | local($tmp)=<<"EOF"; |
387 | .text | 445 | .text |
388 | .globl $func | 446 | .globl $func |
@@ -397,6 +455,7 @@ EOF | |||
397 | else { push(@out,".type $func,\@function\n"); } | 455 | else { push(@out,".type $func,\@function\n"); } |
398 | push(@out,".align\t$align\n"); | 456 | push(@out,".align\t$align\n"); |
399 | push(@out,"$func:\n"); | 457 | push(@out,"$func:\n"); |
458 | skip: | ||
400 | $stack=4; | 459 | $stack=4; |
401 | } | 460 | } |
402 | 461 | ||
@@ -457,6 +516,8 @@ sub main'function_end_B | |||
457 | %label=(); | 516 | %label=(); |
458 | } | 517 | } |
459 | 518 | ||
519 | sub main'function_end_C { function_end_B(@_); } | ||
520 | |||
460 | sub main'wparam | 521 | sub main'wparam |
461 | { | 522 | { |
462 | local($num)=@_; | 523 | local($num)=@_; |
@@ -493,7 +554,7 @@ sub main'swtmp | |||
493 | 554 | ||
494 | sub main'comment | 555 | sub main'comment |
495 | { | 556 | { |
496 | if (!defined($com_start) or $main'elf) | 557 | if (!defined($com_start) or (!$main'openbsd && $main'elf)) |
497 | { # Regarding $main'elf above... | 558 | { # Regarding $main'elf above... |
498 | # GNU and SVR4 as'es use different comment delimiters, | 559 | # GNU and SVR4 as'es use different comment delimiters, |
499 | push(@out,"\n"); # so we just skip ELF comments... | 560 | push(@out,"\n"); # so we just skip ELF comments... |
@@ -534,7 +595,13 @@ sub main'set_label | |||
534 | if ($_[1]!=0) | 595 | if ($_[1]!=0) |
535 | { | 596 | { |
536 | if ($_[1]>1) { main'align($_[1]); } | 597 | if ($_[1]>1) { main'align($_[1]); } |
537 | else { push(@out,".align $align\n"); } | 598 | else |
599 | { | ||
600 | if ($main'openbsd) | ||
601 | { push(@out,"_ALIGN_TEXT\n"); } | ||
602 | else | ||
603 | { push(@out,".align $align\n"); } | ||
604 | } | ||
538 | } | 605 | } |
539 | push(@out,"$label{$_[0]}:\n"); | 606 | push(@out,"$label{$_[0]}:\n"); |
540 | } | 607 | } |
@@ -578,6 +645,10 @@ sub main'align | |||
578 | $val.=",0x90"; | 645 | $val.=",0x90"; |
579 | } | 646 | } |
580 | push(@out,".align\t$val\n"); | 647 | push(@out,".align\t$val\n"); |
648 | if ($main'openbsd) | ||
649 | { push(@out,"_ALIGN_TEXT\n"); } | ||
650 | else | ||
651 | { push(@out,".align $tval\n"); } | ||
581 | } | 652 | } |
582 | 653 | ||
583 | # debug output functions: puts, putx, printf | 654 | # debug output functions: puts, putx, printf |
@@ -669,6 +740,16 @@ sub main'picmeup | |||
669 | ___ | 740 | ___ |
670 | push(@out,$tmp); | 741 | push(@out,$tmp); |
671 | } | 742 | } |
743 | elsif ($main'openbsd) | ||
744 | { | ||
745 | push(@out, "#ifdef PIC\n"); | ||
746 | push(@out, "\tPIC_PROLOGUE\n"); | ||
747 | &main'mov($dst,"PIC_GOT($sym)"); | ||
748 | push(@out, "\tPIC_EPILOGUE\n"); | ||
749 | push(@out, "#else\n"); | ||
750 | &main'lea($dst,&main'DWP($sym)); | ||
751 | push(@out, "#endif\n"); | ||
752 | } | ||
672 | elsif ($main'pic && ($main'elf || $main'aout)) | 753 | elsif ($main'pic && ($main'elf || $main'aout)) |
673 | { | 754 | { |
674 | &main'call(&main'label("PIC_me_up")); | 755 | &main'call(&main'label("PIC_me_up")); |
@@ -694,7 +775,9 @@ sub main'initseg | |||
694 | { | 775 | { |
695 | $tmp=<<___; | 776 | $tmp=<<___; |
696 | .section .init | 777 | .section .init |
697 | call $under$f | 778 | PIC_PROLOGUE |
779 | call PIC_PLT($under$f) | ||
780 | PIC_EPILOGUE | ||
698 | jmp .Linitalign | 781 | jmp .Linitalign |
699 | .align $align | 782 | .align $align |
700 | .Linitalign: | 783 | .Linitalign: |