on iko/ghcjs-patch-master help sign in
patch out calls to mprotect with len=0 to stop qemu 6.0.0 from signalling ENOMEM (#1289)

* patch out calls to mprotect with len=0 to stop qemu 6.0.0 from signalling ENOMEM * widen scope of mprotect len=0 patch back to 8.10.1, when the mprotect call was introduced Co-authored-by: Ross MacLeod <ross@vitalbio.com>

commitaaf4e230c69507fb3a1c6fe4c1f6603d659d5543 authorRoss MacLeod <Dridus@users.noreply.github.com> dateFri 12 Nov 2021, 02:30 (5 years ago) parent0f89172
2 files changed+15
overlays/bootstrap.nix+1 overlays/patches/ghc/ghc-mprotect-nonzero-len.patch+14
overlays/bootstrap.nix+1
@@ -164,6 +164,7 @@ in {
164164 ++ final.lib.optional (versionAtLeast "8.10.3" && final.targetPlatform.isAarch64) ./patches/ghc/3434.patch
165165
166166 ++ from "8.10.1" ./patches/ghc/ghc-acrt-iob-func.patch
167+ ++ from "8.10.1" ./patches/ghc/ghc-mprotect-nonzero-len.patch
167168
168169 ++ fromUntil "8.10.1" "8.10.3" ./patches/ghc/ghc-8.10-ubxt.patch
169170 ++ fromUntil "8.10.3" "8.10.5" ./patches/ghc/ghc-8.10.3-ubxt.patch
overlays/patches/ghc/ghc-mprotect-nonzero-len.patchnew file+14
@@ -0,0 +1,14 @@
1+diff --git a/rts/Linker.c b/rts/Linker.c
2+index f1c0db7c92..10b0764b38 100644
3+--- a/rts/Linker.c
4++++ b/rts/Linker.c
5+@@ -1161,6 +1161,9 @@ void mmapForLinkerMarkExecutable(void *start, size_t len)
6+ IF_DEBUG(linker,
7+ debugBelch("mmapForLinkerMarkExecutable: protecting %" FMT_Word
8+ " bytes starting at %p\n", (W_)len, start));
9++ if (len == 0) {
10++ return;
11++ }
12+ if (mprotect(start, len, PROT_READ|PROT_EXEC) == -1) {
13+ barf("mmapForLinkerMarkExecutable: mprotect: %s\n", strerror(errno));
14+ }