3 # For Microsoft CL this is implemented as inline assembler. So that
4 # even though this script can generate even Win32 code, we'll be
5 # using it primarily to generate Win64 modules. Both IA-64 and AMD64
8 # pull APPLINK_MAX value from applink.c...
10 $applink_c=~s
|[^/\\]+$||g
;
11 $applink_c.="applink.c";
12 open(INPUT
,$applink_c) || die "can't open $applink_c: $!";
13 @max=grep {/APPLINK_MAX\s+(\d+)/} <INPUT
>;
15 ($#max==0) or die "can't find APPLINK_MAX in $applink_c";
17 $max[0]=~/APPLINK_MAX\s+(\d+)/;
18 $N=$1; # number of entries in OPENSSL_UplinkTable not including
19 # OPENSSL_UplinkTable[0], which contains this value...
21 # Idea is to fill the OPENSSL_UplinkTable with pointers to stubs
22 # which invoke 'void OPENSSL_Uplink (ULONG_PTR *table,int index)';
23 # and then dereference themselves. Latter shall result in endless
24 # loop *unless* OPENSSL_Uplink does not replace 'table[index]' with
25 # something else, e.g. as 'table[index]=unimplemented;'...
28 #( defined shift || open STDOUT,">$arg" ) || die "can't open $arg: $!";
30 if ($arg =~ /win32n/) { ia32nasm
(); }
31 elsif ($arg =~ /win32/) { ia32masm
(); }
32 elsif ($arg =~ /coff/) { ia32gas
(); }
33 elsif ($arg =~ /win64i/ or $arg =~ /ia64/) { ia64ias
(); }
34 elsif ($arg =~ /win64a/ or $arg =~ /amd64/) { amd64masm
(); }
35 else { die "nonsense $arg"; }
41 for ($i=1;$i<=$N;$i++) {
43 .def
.Lazy
$i; .scl
3; .type
32; .endef
47 pushl \
$_OPENSSL_UplinkTable
50 jmp
*(_OPENSSL_UplinkTable
+4*$i)
56 .globl _OPENSSL_UplinkTable
60 for ($i=1;$i<=$N;$i++) { print " .long .Lazy$i\n"; }
69 PUBLIC _OPENSSL_UplinkTable
70 _OPENSSL_UplinkTable DD
$N ; amount of following entries
72 for ($i=1;$i<=$N;$i++) { print " DD FLAT:\$lazy$i\n"; }
77 EXTRN _OPENSSL_Uplink
:NEAR
79 for ($i=1;$i<=$N;$i++) {
84 push OFFSET FLAT
:_OPENSSL_UplinkTable
87 jmp DWORD PTR _OPENSSL_UplinkTable
+4*$i
101 GLOBAL _OPENSSL_UplinkTable
102 _OPENSSL_UplinkTable DD
$N ; amount of following entries
104 for ($i=1;$i<=$N;$i++) { print " DD \$lazy$i\n"; }
108 EXTERN _OPENSSL_Uplink
110 for ($i=1;$i<=$N;$i++) {
115 push _OPENSSL_UplinkTable
118 jmp
[_OPENSSL_UplinkTable
+4*$i]
128 local $V=8; # max number of args uplink functions may accept...
131 .global OPENSSL_UplinkTable
#
132 OPENSSL_UplinkTable
: data8
$N // amount of following entries
134 for ($i=1;$i<=$N;$i++) { print " data8 \@fptr(lazy$i#)\n"; }
136 .size OPENSSL_UplinkTable
,.-OPENSSL_UplinkTable
#
139 .global OPENSSL_Uplink
#
140 .type OPENSSL_Uplink
#,\@function
142 for ($i=1;$i<=$N;$i++) {
146 { .mii
; alloc loc0
=ar
.pfs
,$V,3,2,0
148 addl loc2
=\
@ltoff(OPENSSL_UplinkTable
#),gp };;
149 { .mmi
; ld8 out0
=[loc2
]
151 { .mib
; adds loc2
=8*$i,out0
152 br
.call
.sptk
.many b0
=OPENSSL_Uplink
# };;
153 { .mmi
; ld8 r31
=[loc2
];;
158 { .mib
; mov ar
.pfs
=loc0
168 PUBLIC OPENSSL_UplinkTable
169 OPENSSL_UplinkTable DQ
$N
171 for ($i=1;$i<=$N;$i++) { print " DQ \$lazy$i\n"; }
176 EXTERN OPENSSL_Uplink
:PROC
178 for ($i=1;$i<=$N;$i++) {
187 lea rcx
,OFFSET OPENSSL_UplinkTable
195 jmp QWORD PTR OPENSSL_UplinkTable
+8*$i