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