Rich Salz | e0a6519 | 2016-04-19 22:10:43 -0400 | [diff] [blame] | 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 |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 8 | |
Andy Polyakov | acf1525 | 2016-03-18 23:31:17 +0100 | [diff] [blame] | 9 | $output=pop; |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 10 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; |
Andy Polyakov | cfe1d99 | 2016-05-28 16:25:38 +0200 | [diff] [blame] | 11 | open OUT,"| \"$^X\" \"${dir}../crypto/perlasm/x86_64-xlate.pl\" \"$output\""; |
Andy Polyakov | 46bf83f | 2013-01-22 22:11:31 +0100 | [diff] [blame] | 12 | *STDOUT=*OUT; |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 13 | push(@INC,"${dir}."); |
| 14 | |
| 15 | require "uplink-common.pl"; |
| 16 | |
| 17 | $prefix="_lazy"; |
| 18 | |
| 19 | print <<___; |
| 20 | .text |
| 21 | .extern OPENSSL_Uplink |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 22 | .globl OPENSSL_UplinkTable |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 23 | ___ |
| 24 | for ($i=1;$i<=$N;$i++) { |
| 25 | print <<___; |
| 26 | .type $prefix${i},\@abi-omnipotent |
| 27 | .align 16 |
| 28 | $prefix${i}: |
| 29 | .byte 0x48,0x83,0xEC,0x28 # sub rsp,40 |
| 30 | mov %rcx,48(%rsp) |
| 31 | mov %rdx,56(%rsp) |
| 32 | mov %r8,64(%rsp) |
| 33 | mov %r9,72(%rsp) |
| 34 | lea OPENSSL_UplinkTable(%rip),%rcx |
| 35 | mov \$$i,%rdx |
| 36 | call OPENSSL_Uplink |
| 37 | mov 48(%rsp),%rcx |
| 38 | mov 56(%rsp),%rdx |
| 39 | mov 64(%rsp),%r8 |
| 40 | mov 72(%rsp),%r9 |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 41 | lea OPENSSL_UplinkTable(%rip),%rax |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 42 | add \$40,%rsp |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 43 | jmp *8*$i(%rax) |
| 44 | $prefix${i}_end: |
| 45 | .size $prefix${i},.-$prefix${i} |
| 46 | ___ |
| 47 | } |
| 48 | print <<___; |
| 49 | .data |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 50 | OPENSSL_UplinkTable: |
| 51 | .quad $N |
| 52 | ___ |
| 53 | for ($i=1;$i<=$N;$i++) { print " .quad $prefix$i\n"; } |
| 54 | print <<___; |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 55 | .section .pdata,"r" |
| 56 | .align 4 |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 57 | ___ |
| 58 | for ($i=1;$i<=$N;$i++) { |
| 59 | print <<___; |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 60 | .rva $prefix${i},$prefix${i}_end,${prefix}_unwind_info |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 61 | ___ |
| 62 | } |
| 63 | print <<___; |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 64 | .section .xdata,"r" |
| 65 | .align 8 |
Andy Polyakov | 4c04821 | 2008-07-22 08:47:35 +0000 | [diff] [blame] | 66 | ${prefix}_unwind_info: |
| 67 | .byte 0x01,0x04,0x01,0x00 |
| 68 | .byte 0x04,0x42,0x00,0x00 |
| 69 | ___ |
Andy Polyakov | be01f79 | 2008-12-19 11:17:29 +0000 | [diff] [blame] | 70 | |
| 71 | close STDOUT; |