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