2
0

uplink-x86_64.pl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #! /usr/bin/env perl
  2. # Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. $output=pop;
  9. $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
  10. open OUT,"| \"$^X\" \"${dir}../crypto/perlasm/x86_64-xlate.pl\" \"$output\"";
  11. *STDOUT=*OUT;
  12. push(@INC,"${dir}.");
  13. require "uplink-common.pl";
  14. $prefix="_lazy";
  15. print <<___;
  16. .text
  17. .extern OPENSSL_Uplink
  18. .globl OPENSSL_UplinkTable
  19. ___
  20. for ($i=1;$i<=$N;$i++) {
  21. print <<___;
  22. .type $prefix${i},\@abi-omnipotent
  23. .align 16
  24. $prefix${i}:
  25. .byte 0x48,0x83,0xEC,0x28 # sub rsp,40
  26. mov %rcx,48(%rsp)
  27. mov %rdx,56(%rsp)
  28. mov %r8,64(%rsp)
  29. mov %r9,72(%rsp)
  30. lea OPENSSL_UplinkTable(%rip),%rcx
  31. mov \$$i,%rdx
  32. call OPENSSL_Uplink
  33. mov 48(%rsp),%rcx
  34. mov 56(%rsp),%rdx
  35. mov 64(%rsp),%r8
  36. mov 72(%rsp),%r9
  37. lea OPENSSL_UplinkTable(%rip),%rax
  38. add \$40,%rsp
  39. jmp *8*$i(%rax)
  40. $prefix${i}_end:
  41. .size $prefix${i},.-$prefix${i}
  42. ___
  43. }
  44. print <<___;
  45. .data
  46. OPENSSL_UplinkTable:
  47. .quad $N
  48. ___
  49. for ($i=1;$i<=$N;$i++) { print " .quad $prefix$i\n"; }
  50. print <<___;
  51. .section .pdata,"r"
  52. .align 4
  53. ___
  54. for ($i=1;$i<=$N;$i++) {
  55. print <<___;
  56. .rva $prefix${i},$prefix${i}_end,${prefix}_unwind_info
  57. ___
  58. }
  59. print <<___;
  60. .section .xdata,"r"
  61. .align 8
  62. ${prefix}_unwind_info:
  63. .byte 0x01,0x04,0x01,0x00
  64. .byte 0x04,0x42,0x00,0x00
  65. ___
  66. close STDOUT;