summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-06-28 10:21:51 -0700
committerMichael Pavone <pavone@retrodev.com>2015-06-28 10:21:51 -0700
commitf345f5d118a45778f46b478f438eb47fc31d6705 (patch)
tree796d90364ea3af6c0f7be2b98baeff424ceaa65a
parentb4ed5b152505ed1dc46d2af083acb19053661787 (diff)
Use MAP_32BIT on Linux since my hint seems to be ignored
-rw-r--r--mem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mem.c b/mem.c
index cb3a047..048f751 100644
--- a/mem.c
+++ b/mem.c
@@ -14,13 +14,17 @@
#define MAP_ANONYMOUS MAP_ANON
#endif
+#ifndef MAP_32BIT
+#define MAP_32BIT 0
+#endif
+
void * alloc_code(size_t *size)
{
//start at the 1GB mark to allow plenty of room for sbrk based malloc implementations
//while still keeping well within 32-bit displacement range for calling code compiled into the executable
static uint8_t *next = (uint8_t *)0x40000000;
*size += PAGE_SIZE - (*size & (PAGE_SIZE - 1));
- uint8_t *ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ uint8_t *ret = mmap(NULL, *size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
next = ret + *size;
return ret;
}