diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/custommem.c | 2 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/custommem.c b/src/custommem.c index 0e2b1a09..2dcc2b02 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -85,7 +85,7 @@ static uint64_t memprot_allocated = 0, memprot_max_allocated = 0; #endif static memprot_t memprot[1<<MEMPROT_SIZE0]; // x86_64 mem is 48bits, page is 12bits, so memory is tracked as [20][16][page protection] static uint8_t memprot_default[MEMPROT_SIZE]; -static int have48bits = 0; +int have48bits = 0; static int inited = 0; typedef struct mapmem_s { diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index b09e2b93..fe9d60db 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2571,6 +2571,7 @@ EXPORT int my_readlinkat(x64emu_t* emu, int fd, void* path, void* buf, size_t bu #ifndef MAP_32BIT #define MAP_32BIT 0x40 #endif +extern int have48bits; EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot, int flags, int fd, ssize_t offset) { (void)emu; @@ -2615,8 +2616,11 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot if(new_flags&(MAP_FIXED|MAP_FIXED_NOREPLACE)==(MAP_FIXED|MAP_FIXED_NOREPLACE)) new_flags&=~MAP_FIXED_NOREPLACE; ret = mmap64(addr, length, prot, new_flags, fd, offset); printf_log(LOG_DEBUG, " tried again with %p, got %p\n", addr, ret); - if(old_addr && ret!=old_addr) + if(old_addr && ret!=old_addr) { errno = olderr; + if(old_addr>(void*)0x7fffffffff && !have48bits) + errno = EEXIST; + } } #endif if((ret!=MAP_FAILED) && (flags&MAP_FIXED_NOREPLACE) && (ret!=addr)) { |