summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-23 14:35:56 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-12-01 19:58:17 -0500
commitadd0aeaefd4d823d31315564e924ce8c018fb69e (patch)
tree4fc39929885b53bd774d7a8eedde70917cd37bfe /rts/Linker.c
parentd66660ba4c491f9937a1a959b009d90f08a4fbee (diff)
downloadhaskell-add0aeaefd4d823d31315564e924ce8c018fb69e.tar.gz
rts: Introduce mmapAnonForLinker
Previously most of the uses of mmapForLinker were mapping anonymous memory, resulting in a great deal of unnecessary repetition. Factor this out into a new helper. Also fixes a few places where error checking was missing or suboptimal.
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index ef08a282dc..6873b1a9b7 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1080,7 +1080,7 @@ mmap_again:
fixed = MAP_FIXED;
goto mmap_again;
#else
- errorBelch("loadObj: failed to mmap() memory below 2Gb; "
+ errorBelch("mmapForLinker: failed to mmap() memory below 2Gb; "
"asked for %lu bytes at %p. "
"Try specifying an address with +RTS -xm<addr> -RTS",
size, map_addr);
@@ -1140,6 +1140,16 @@ mmap_again:
return result;
}
+/*
+ * Map read/write pages in low memory. Returns NULL on failure.
+ */
+void *
+mmapAnonForLinker (size_t bytes)
+{
+ return mmapForLinker (bytes, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, -1, 0);
+}
+
+
/* Note [Memory protection in the linker]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* For many years the linker would simply map all of its memory