2
0

uplink-x86_64.pl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /usr/bin/env perl
  2. # Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (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 is the last argument if it looks like a file (it has an extension)
  9. $output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
  10. $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
  11. open OUT,"| \"$^X\" \"${dir}../crypto/perlasm/x86_64-xlate.pl\" \"$output\""
  12. or die "can't call ${dir}../crypto/perlasm/x86_64-xlate.pl: $!";
  13. *STDOUT=*OUT;
  14. push(@INC,"${dir}.");
  15. require "uplink-common.pl";
  16. $prefix="_lazy";
  17. print <<___;
  18. .text
  19. .extern OPENSSL_Uplink
  20. .globl OPENSSL_UplinkTable
  21. ___
  22. for ($i=1;$i<=$N;$i++) {
  23. print <<___;
  24. .type $prefix${i},\@abi-omnipotent
  25. .align 16
  26. $prefix${i}:
  27. .byte 0x48,0x83,0xEC,0x28 # sub rsp,40
  28. mov %rcx,48(%rsp)
  29. mov %rdx,56(%rsp)
  30. mov %r8,64(%rsp)
  31. mov %r9,72(%rsp)
  32. lea OPENSSL_UplinkTable(%rip),%rcx
  33. mov \$$i,%rdx
  34. call OPENSSL_Uplink
  35. mov 48(%rsp),%rcx
  36. mov 56(%rsp),%rdx
  37. mov 64(%rsp),%r8
  38. mov 72(%rsp),%r9
  39. lea OPENSSL_UplinkTable(%rip),%rax
  40. add \$40,%rsp
  41. jmp *8*$i(%rax)
  42. $prefix${i}_end:
  43. .size $prefix${i},.-$prefix${i}
  44. ___
  45. }
  46. print <<___;
  47. .data
  48. OPENSSL_UplinkTable:
  49. .quad $N
  50. ___
  51. for ($i=1;$i<=$N;$i++) { print " .quad $prefix$i\n"; }
  52. print <<___;
  53. .section .pdata,"r"
  54. .align 4
  55. ___
  56. for ($i=1;$i<=$N;$i++) {
  57. print <<___;
  58. .rva $prefix${i},$prefix${i}_end,${prefix}_unwind_info
  59. ___
  60. }
  61. print <<___;
  62. .section .xdata,"r"
  63. .align 8
  64. ${prefix}_unwind_info:
  65. .byte 0x01,0x04,0x01,0x00
  66. .byte 0x04,0x42,0x00,0x00
  67. ___
  68. close STDOUT;