diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-10 21:58:15 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-13 14:42:54 +0100 |
commit | 5f5da6def00972aeb2ace394f2e1cd7bb4b73a7a (patch) | |
tree | 8b20de4b3320864778fdb3a112aa6f54c17915f0 /go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch | |
parent | main: only do Wow64 check on ARM (diff) | |
download | wireguard-windows-5f5da6def00972aeb2ace394f2e1cd7bb4b73a7a.tar.xz wireguard-windows-5f5da6def00972aeb2ace394f2e1cd7bb4b73a7a.zip |
go-patches: support 8 callback arguments on arm
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch b/go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch new file mode 100644 index 00000000..20e835dc --- /dev/null +++ b/go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch @@ -0,0 +1,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 + |