1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
From f85bc709bd30286a310a6a98d4ab42cbadd94315 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Tue, 10 Nov 2020 21:42:36 +0100
Subject: [PATCH 9/9] runtime: allow callback functions with up to 8 arguments
on windows/arm
Previously, windows/arm programs would abort when trying to use
functions that took callbacks with more than 4 arguments. This caused
issues when using SetWinEventHook, which receives 7 arguments. Add 4
more by pulling them off the stack.
Change-Id: I15a6a3168237fd8bb1128cc2c11ff2d900d665d2
---
src/runtime/sys_windows_arm.s | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/runtime/sys_windows_arm.s b/src/runtime/sys_windows_arm.s
index e6c61a4e42..7bfeb7614f 100644
--- a/src/runtime/sys_windows_arm.s
+++ b/src/runtime/sys_windows_arm.s
@@ -315,10 +315,14 @@ GLOBL runtime·cbctxts(SB), NOPTR, $4
TEXT runtime·callbackasm1(SB),NOSPLIT|NOFRAME,$0
MOVM.DB.W [R4-R11, R14], (R13) // push {r4-r11, lr}
- SUB $36, R13 // space for locals
+ SUB $52, R13 // space for locals
- // save callback arguments to stack. We currently support up to 4 arguments
+ // save callback arguments to stack. We currently support up to 8 arguments
ADD $16, R13, R4
+ MOVM.IA.W [R0-R3], (R4)
+ // the remaining 4 arguments are on the stack
+ ADD $88, R13, R5
+ MOVM.IA (R5), [R0-R3]
MOVM.IA [R0-R3], (R4)
// load cbctxts[i]. The trampoline in zcallback_windows.s puts the callback
@@ -330,8 +334,8 @@ TEXT runtime·callbackasm1(SB),NOSPLIT|NOFRAME,$0
MOVW wincallbackcontext_argsize(R4), R5
MOVW wincallbackcontext_gobody(R4), R4
- // we currently support up to 4 arguments
- CMP $(4 * 4), R5
+ // we currently support up to 8 arguments
+ CMP $(4 * 8), R5
BL.GT runtime·abort(SB)
// extend argsize by size of return value
@@ -351,7 +355,7 @@ TEXT runtime·callbackasm1(SB),NOSPLIT|NOFRAME,$0
SUB $4, R1 // offset to return value
MOVW R1<<0(R0), R0 // load return value
- ADD $36, R13 // free locals
+ ADD $52, R13 // free locals
MOVM.IA.W (R13), [R4-R11, R15] // pop {r4-r11, pc}
// uint32 tstart_stdcall(M *newm);
--
2.29.1
|