aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-10 21:58:15 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-10 22:18:55 +0100
commit0d7907e0328f5eeeb84e5b89f91047917b3a45dc (patch)
tree44ca0ee83447c1bac8de2a1fe03d3f9a8d6294b3
parentmain: direct users to hotfix URL for KB2921916 (diff)
downloadwireguard-windows-0d7907e0328f5eeeb84e5b89f91047917b3a45dc.tar.xz
wireguard-windows-0d7907e0328f5eeeb84e5b89f91047917b3a45dc.zip
go-patches: support 8 callback arguments on arm
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--go-patches/0001-cmd-link-recognize-arm-header-of-PE-objects.patch2
-rw-r--r--go-patches/0002-cmd-link-deal-with-ADDR32NB-relocations-the-same-way.patch2
-rw-r--r--go-patches/0003-cmd-link-ignore-SEH-marking-on-PE-objects.patch2
-rw-r--r--go-patches/0004-cmd-link-do-not-mark-resource-section-as-writable.patch2
-rw-r--r--go-patches/0005-cmd-link-handle-grouped-resource-sections.patch2
-rw-r--r--go-patches/0006-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch2
-rw-r--r--go-patches/0007-Revert-release-branch.go1.15-runtime-detect-services.patch2
-rw-r--r--go-patches/0008-runtime-do-not-explicitly-exit-on-ctrl-handler.patch2
-rw-r--r--go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch62
9 files changed, 70 insertions, 8 deletions
diff --git a/go-patches/0001-cmd-link-recognize-arm-header-of-PE-objects.patch b/go-patches/0001-cmd-link-recognize-arm-header-of-PE-objects.patch
index 3a310c5d..8a1df6b6 100644
--- a/go-patches/0001-cmd-link-recognize-arm-header-of-PE-objects.patch
+++ b/go-patches/0001-cmd-link-recognize-arm-header-of-PE-objects.patch
@@ -1,7 +1,7 @@
From 2b3975549a043f66ad1580b0330c2bf47916f042 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 8 Nov 2020 02:48:09 +0100
-Subject: [PATCH 1/8] cmd/link: recognize arm header of PE objects
+Subject: [PATCH 1/9] cmd/link: recognize arm header of PE objects
The linker recognizes headers for 386 and amd64 PE objects, but not arm
objects. This is easily overlooked, since its the same as the 386 header
diff --git a/go-patches/0002-cmd-link-deal-with-ADDR32NB-relocations-the-same-way.patch b/go-patches/0002-cmd-link-deal-with-ADDR32NB-relocations-the-same-way.patch
index 10137735..97764070 100644
--- a/go-patches/0002-cmd-link-deal-with-ADDR32NB-relocations-the-same-way.patch
+++ b/go-patches/0002-cmd-link-deal-with-ADDR32NB-relocations-the-same-way.patch
@@ -1,7 +1,7 @@
From b82dc55e45ee47e0df9604593c34d41654db45c8 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 8 Nov 2020 03:09:42 +0100
-Subject: [PATCH 2/8] cmd/link: deal with ADDR32NB relocations the same way as
+Subject: [PATCH 2/9] cmd/link: deal with ADDR32NB relocations the same way as
ADDR32 on arm
As far as I can tell, the addend is the same for both of these, and in
diff --git a/go-patches/0003-cmd-link-ignore-SEH-marking-on-PE-objects.patch b/go-patches/0003-cmd-link-ignore-SEH-marking-on-PE-objects.patch
index 34bd75fb..39102b65 100644
--- a/go-patches/0003-cmd-link-ignore-SEH-marking-on-PE-objects.patch
+++ b/go-patches/0003-cmd-link-ignore-SEH-marking-on-PE-objects.patch
@@ -1,7 +1,7 @@
From b3b6bbb7094e9d1f8c73a13bdf2461dea5072265 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 8 Nov 2020 03:20:36 +0100
-Subject: [PATCH 3/8] cmd/link: ignore SEH marking on PE objects
+Subject: [PATCH 3/9] cmd/link: ignore SEH marking on PE objects
Microsoft's linker looks at whether all input objects have an empty
section called @feat.00. If all of them do, then it enables SEH;
diff --git a/go-patches/0004-cmd-link-do-not-mark-resource-section-as-writable.patch b/go-patches/0004-cmd-link-do-not-mark-resource-section-as-writable.patch
index 7898b32a..925fd8cd 100644
--- a/go-patches/0004-cmd-link-do-not-mark-resource-section-as-writable.patch
+++ b/go-patches/0004-cmd-link-do-not-mark-resource-section-as-writable.patch
@@ -1,7 +1,7 @@
From 3d9d47826907f8836cf4f364e45b8e2580dbc470 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 8 Nov 2020 11:11:27 +0100
-Subject: [PATCH 4/8] cmd/link: do not mark resource section as writable
+Subject: [PATCH 4/9] cmd/link: do not mark resource section as writable
Resources are immutable, and all other linkers set this section to be
read-only and not read-write. Fix this oversight by rmoving the writable
diff --git a/go-patches/0005-cmd-link-handle-grouped-resource-sections.patch b/go-patches/0005-cmd-link-handle-grouped-resource-sections.patch
index 0d57392f..6a2e3e7e 100644
--- a/go-patches/0005-cmd-link-handle-grouped-resource-sections.patch
+++ b/go-patches/0005-cmd-link-handle-grouped-resource-sections.patch
@@ -1,7 +1,7 @@
From 98ed6f945dbc81a238d079353cab576941f7bb79 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sun, 8 Nov 2020 11:57:42 +0100
-Subject: [PATCH 5/8] cmd/link: handle grouped resource sections
+Subject: [PATCH 5/9] cmd/link: handle grouped resource sections
The Go PE linker does not support enough generalized PE logic to
properly handle .rsrc sections gracefully. Instead a few things are
diff --git a/go-patches/0006-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch b/go-patches/0006-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch
index 240d097e..13ecd50d 100644
--- a/go-patches/0006-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch
+++ b/go-patches/0006-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch
@@ -1,7 +1,7 @@
From ef97bba4eec391707d08870252e555f3797ce270 Mon Sep 17 00:00:00 2001
From: Alex Brainman <alex.brainman@gmail.com>
Date: Sun, 19 Jul 2020 16:06:48 +1000
-Subject: [PATCH 6/8] runtime: use CreateWaitableTimerEx to implement usleep
+Subject: [PATCH 6/9] runtime: use CreateWaitableTimerEx to implement usleep
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
diff --git a/go-patches/0007-Revert-release-branch.go1.15-runtime-detect-services.patch b/go-patches/0007-Revert-release-branch.go1.15-runtime-detect-services.patch
index 5d09b3c2..3077a41b 100644
--- a/go-patches/0007-Revert-release-branch.go1.15-runtime-detect-services.patch
+++ b/go-patches/0007-Revert-release-branch.go1.15-runtime-detect-services.patch
@@ -1,7 +1,7 @@
From 82dfc8240f58880ec59a98ed9403d9997571573a Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Fri, 11 Sep 2020 13:04:11 +0200
-Subject: [PATCH 7/8] Revert "[release-branch.go1.15] runtime: detect services
+Subject: [PATCH 7/9] Revert "[release-branch.go1.15] runtime: detect services
in signal handler"
This reverts commit b1253d24e159129c778377c3a2a0bde15904a417.
diff --git a/go-patches/0008-runtime-do-not-explicitly-exit-on-ctrl-handler.patch b/go-patches/0008-runtime-do-not-explicitly-exit-on-ctrl-handler.patch
index 4bc255c4..a937b11e 100644
--- a/go-patches/0008-runtime-do-not-explicitly-exit-on-ctrl-handler.patch
+++ b/go-patches/0008-runtime-do-not-explicitly-exit-on-ctrl-handler.patch
@@ -1,7 +1,7 @@
From a9e2ff1fa414106c130907ac993600bd3adcd6cd Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Tue, 14 Jul 2020 01:41:03 -0600
-Subject: [PATCH 8/8] runtime: do not explicitly exit on ctrl handler
+Subject: [PATCH 8/9] runtime: do not explicitly exit on ctrl handler
The default ctrl+c handler should process exits in situations where it
makes sense, like console apps, but not in situations where it doesn't,
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..5c5bdf17
--- /dev/null
+++ b/go-patches/0009-runtime-allow-callback-functions-with-up-to-8-argume.patch
@@ -0,0 +1,62 @@
+From 41c3582b39b7840c4cd3187e2e43c92b3715a3f3 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 | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/src/runtime/sys_windows_arm.s b/src/runtime/sys_windows_arm.s
+index e6c61a4e42..effaa65a7c 100644
+--- a/src/runtime/sys_windows_arm.s
++++ b/src/runtime/sys_windows_arm.s
+@@ -315,11 +315,16 @@ 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 [R0-R3], (R4)
++ // the remaining 4 arguments are on the stack
++ ADD $88, R13, R5
++ MOVM.IA (R5), [R0-R3]
++ ADD $32, R13, R4
++ MOVM.IA [R0-R3], (R4)
+
+ // load cbctxts[i]. The trampoline in zcallback_windows.s puts the callback
+ // index in R12
+@@ -330,8 +335,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 +356,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
+