From 0c27b82ff3b8a1da27d7ed32e89c90518f9c2c0c Mon Sep 17 00:00:00 2001 From: mogery Date: Tue, 12 Oct 2021 19:47:31 +0200 Subject: Map bricks below first 2GB of address space This fixes an issue with mono where JIT compiled code would near-call wrapped libraries, but fail because the difference between PC and the call address did not fit into an imm32. This was fixed by replacing posix_memalign with my_mmap and providing the MAP_32BIT flag. Fixes #131 --- src/tools/bridge.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/bridge.c b/src/tools/bridge.c index 5f6bb5af..c800b8c5 100755 --- a/src/tools/bridge.c +++ b/src/tools/bridge.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "custommem.h" #include "bridge.h" @@ -36,9 +37,11 @@ typedef struct bridge_s { brick_t* NewBrick() { brick_t* ret = (brick_t*)calloc(1, sizeof(brick_t)); - if(posix_memalign((void**)&ret->b, box64_pagesize, NBRICK*sizeof(onebridge_t))) { + void* ptr = my_mmap(thread_get_emu(), NULL, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE, MAP_PRIVATE | 0x40 | MAP_ANONYMOUS, -1, 0); // 0x40 is MAP_32BIT + if(ptr == MAP_FAILED) { printf_log(LOG_NONE, "Warning, cannot allocate 0x%lx aligned bytes for bridge, will probably crash later\n", NBRICK*sizeof(onebridge_t)); } + ret->b = ptr; return ret; } -- cgit 1.4.1