about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-07-14 10:40:09 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-07-14 10:40:09 +0200
commit9be89e8ba26dcffc4ae2a6477459dd2c115d1a5b (patch)
tree89c1c5a8e98a7a2e89152282e15ec1a3f322bd62 /src
parent5287e42b028314b2e5fb2a8e9d8fad604ad8fb28 (diff)
downloadbox64-9be89e8ba26dcffc4ae2a6477459dd2c115d1a5b.tar.gz
box64-9be89e8ba26dcffc4ae2a6477459dd2c115d1a5b.zip
Try to make the 32bits mmap more resiliant
Diffstat (limited to 'src')
-rwxr-xr-xsrc/wrapped/wrappedlibc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 9049851a..54942c7f 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -2025,6 +2025,15 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot
     }
     #endif
     void* ret = mmap64(addr, length, prot, flags, fd, offset);
+    if((ret!=(void*)-1) && (flags&0x40) && ((uintptr_t)ret>0xffffffff)) {
+        printf_log(LOG_INFO, "Warning, mmap on 32bits didn't worked, ask %p, got %p ", addr, ret);
+        // the 32bit mmap didn't worded, lets try again
+        munmap(ret, length);
+        loadProtectionFromMap();    // reload map, because something went wrong previously
+        addr = findBlockNearHint(addr, length); // is this the best way?
+        ret = mmap64(addr, length, prot, flags, fd, offset);
+        printf_log(LOG_INFO, " tried again with %p, got %p\n", addr, ret);
+    }
     if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "%p\n", ret);}
     #ifdef DYNAREC
     if(box64_dynarec && ret!=(void*)-1) {