From 3dfb99b12884b95fa24735bca01d457cddfa8405 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 26 Nov 2020 22:59:03 +0100 Subject: go-patches: force PIE mode on arm Signed-off-by: Jason A. Donenfeld --- ...d-link-recognize-arm-header-of-PE-objects.patch | 2 +- ...al-with-ADDR32NB-relocations-the-same-way.patch | 2 +- ...cmd-link-ignore-SEH-marking-on-PE-objects.patch | 2 +- ...-do-not-mark-resource-section-as-writable.patch | 2 +- ...cmd-link-handle-grouped-resource-sections.patch | 2 +- ...ase-branch.go1.15-runtime-detect-services.patch | 2 +- ...me-do-not-explicitly-exit-on-ctrl-handler.patch | 2 +- ...ow-callback-functions-with-up-to-8-argume.patch | 2 +- ...-CreateWaitableTimerEx-to-implement-uslee.patch | 2 +- ...ow-for-usleep2HighRes-to-run-without-TLS-.patch | 2 +- ...windows-arm-is-all-pie-so-mark-it-as-such.patch | 44 ++++++++++++++++++++++ 11 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 go-patches/0011-cmd-link-windows-arm-is-all-pie-so-mark-it-as-such.patch (limited to 'go-patches') 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 4a287ee7..9cda62f8 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 fde4a13eb5eba28ac546b10752b38a80f389cc5a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Nov 2020 02:48:09 +0100 -Subject: [PATCH 01/10] cmd/link: recognize arm header of PE objects +Subject: [PATCH 01/11] 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 91d90f67..48247bf2 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 a0a59fc25f4d8aef3c7bce38c84f04c504745f0e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Nov 2020 03:09:42 +0100 -Subject: [PATCH 02/10] cmd/link: deal with ADDR32NB relocations the same way +Subject: [PATCH 02/11] 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 8dfdcb7f..8d4dda45 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 e8142ab5e3b3a513683a8e3792e6197644547981 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Nov 2020 03:20:36 +0100 -Subject: [PATCH 03/10] cmd/link: ignore SEH marking on PE objects +Subject: [PATCH 03/11] 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 f98fa79b..6ef0564f 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 8255e115f325a58fd4746741f9f35c2f54d70d63 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Nov 2020 11:11:27 +0100 -Subject: [PATCH 04/10] cmd/link: do not mark resource section as writable +Subject: [PATCH 04/11] 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 2254b175..e917b60d 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 5d5d74f35dd3375cda8ef2ba8257547aad107ecb Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Nov 2020 11:57:42 +0100 -Subject: [PATCH 05/10] cmd/link: handle grouped resource sections +Subject: [PATCH 05/11] 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-Revert-release-branch.go1.15-runtime-detect-services.patch b/go-patches/0006-Revert-release-branch.go1.15-runtime-detect-services.patch index c2c63812..c30713a9 100644 --- a/go-patches/0006-Revert-release-branch.go1.15-runtime-detect-services.patch +++ b/go-patches/0006-Revert-release-branch.go1.15-runtime-detect-services.patch @@ -1,7 +1,7 @@ From e6b4c1b3beb4f843ed40abead27c8132d29a0db8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 11 Sep 2020 13:04:11 +0200 -Subject: [PATCH 06/10] Revert "[release-branch.go1.15] runtime: detect +Subject: [PATCH 06/11] Revert "[release-branch.go1.15] runtime: detect services in signal handler" This reverts commit b1253d24e159129c778377c3a2a0bde15904a417. diff --git a/go-patches/0007-runtime-do-not-explicitly-exit-on-ctrl-handler.patch b/go-patches/0007-runtime-do-not-explicitly-exit-on-ctrl-handler.patch index 42216e9a..8dd22e3c 100644 --- a/go-patches/0007-runtime-do-not-explicitly-exit-on-ctrl-handler.patch +++ b/go-patches/0007-runtime-do-not-explicitly-exit-on-ctrl-handler.patch @@ -1,7 +1,7 @@ From af4eb34d920c0c727041ebf587e0de608068ed59 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 14 Jul 2020 01:41:03 -0600 -Subject: [PATCH 07/10] runtime: do not explicitly exit on ctrl handler +Subject: [PATCH 07/11] 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/0008-runtime-allow-callback-functions-with-up-to-8-argume.patch b/go-patches/0008-runtime-allow-callback-functions-with-up-to-8-argume.patch index b0eb68f8..96d39ca6 100644 --- a/go-patches/0008-runtime-allow-callback-functions-with-up-to-8-argume.patch +++ b/go-patches/0008-runtime-allow-callback-functions-with-up-to-8-argume.patch @@ -1,7 +1,7 @@ From 5a7c808cbacb8c0477395c5656c1eba3ef38cd6e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 10 Nov 2020 21:42:36 +0100 -Subject: [PATCH 08/10] runtime: allow callback functions with up to 8 +Subject: [PATCH 08/11] runtime: allow callback functions with up to 8 arguments on windows/arm Previously, windows/arm programs would abort when trying to use diff --git a/go-patches/0009-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch b/go-patches/0009-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch index 3fbb1fee..4aa40061 100644 --- a/go-patches/0009-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch +++ b/go-patches/0009-runtime-use-CreateWaitableTimerEx-to-implement-uslee.patch @@ -1,7 +1,7 @@ From 1a163f2e676e4664f2db3f614eb4168bda9d4fd8 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sun, 19 Jul 2020 16:06:48 +1000 -Subject: [PATCH 09/10] runtime: use CreateWaitableTimerEx to implement usleep +Subject: [PATCH 09/11] 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/0010-runtime-allow-for-usleep2HighRes-to-run-without-TLS-.patch b/go-patches/0010-runtime-allow-for-usleep2HighRes-to-run-without-TLS-.patch index 582f585c..890c80ea 100644 --- a/go-patches/0010-runtime-allow-for-usleep2HighRes-to-run-without-TLS-.patch +++ b/go-patches/0010-runtime-allow-for-usleep2HighRes-to-run-without-TLS-.patch @@ -1,7 +1,7 @@ From 1edac4879e2d4a36d339353c151cb7b9871e135f Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sat, 21 Nov 2020 14:56:26 +1100 -Subject: [PATCH 10/10] runtime: allow for usleep2HighRes to run without TLS +Subject: [PATCH 10/11] runtime: allow for usleep2HighRes to run without TLS setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 diff --git a/go-patches/0011-cmd-link-windows-arm-is-all-pie-so-mark-it-as-such.patch b/go-patches/0011-cmd-link-windows-arm-is-all-pie-so-mark-it-as-such.patch new file mode 100644 index 00000000..4fc38459 --- /dev/null +++ b/go-patches/0011-cmd-link-windows-arm-is-all-pie-so-mark-it-as-such.patch @@ -0,0 +1,44 @@ +From fee7906e1a7e62b655bea0f25c921572ee29fc44 Mon Sep 17 00:00:00 2001 +From: "Jason A. Donenfeld" +Date: Thu, 26 Nov 2020 22:38:45 +0100 +Subject: [PATCH 11/11] cmd/link: windows/arm is all pie, so mark it as such + +If the linker thinks that it's making an exe instead of a pie object, it +won't apply relocations to the pclntab and we wind up with crashes like: + + Building Go toolchain2 using go_bootstrap and Go toolchain1. + fatal error: minpc or maxpc invalid + runtime: panic before malloc heap initialized + +This problem was already solved by darwin/arm64, so solve it the same +way here for windows/arm. + +Fixes CL 228478. +Updates #42786. + +Change-Id: I6d1db6907c131183649fc263ccca06783188f344 +--- + src/cmd/link/internal/ld/config.go | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go +index 2373b500e3..83a8698289 100644 +--- a/src/cmd/link/internal/ld/config.go ++++ b/src/cmd/link/internal/ld/config.go +@@ -35,7 +35,12 @@ func (mode *BuildMode) Set(s string) error { + default: + return fmt.Errorf("invalid buildmode: %q", s) + case "exe": +- *mode = BuildModeExe ++ switch objabi.GOOS + "/" + objabi.GOARCH { ++ case "windows/arm": // On these platforms, everything is PIE ++ *mode = BuildModePIE ++ default: ++ *mode = BuildModeExe ++ } + case "pie": + switch objabi.GOOS { + case "aix", "android", "linux", "windows": +-- +2.29.2 + -- cgit v1.2.3-59-g8ed1b