Skip to content

Commit

Permalink
[WRAPPER] Fixed my_mmap64 on MAP_FIXED handling, helps wine 8.18 (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco authored Oct 26, 2023
1 parent 2a4fe80 commit d9a4fed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2566,15 +2566,17 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot
munmap(ret, length);
loadProtectionFromMap(); // reload map, because something went wrong previously
addr = find31bitBlockNearHint(old_addr, length); // is this the best way?
ret = mmap64(addr, length, prot, flags, fd, offset);
uint32_t new_flags = addr ? flags|MAP_FIXED : flags;
ret = mmap64(addr, length, prot, new_flags, fd, offset);
printf_log(LOG_DEBUG, " tried again with %p, got %p\n", addr, ret);
} else if((ret!=(void*)-1) && !(flags&MAP_FIXED) && (box64_wine) && (old_addr) && (addr!=ret) &&
(((uintptr_t)ret>0x7fffffffffffLL) || ((uintptr_t)ret&~0xffff))) {
printf_log(LOG_DEBUG, "Warning, mmap on 47bits didn't worked, ask %p, got %p ", addr, ret);
munmap(ret, length);
loadProtectionFromMap(); // reload map, because something went wrong previously
addr = find47bitBlockNearHint(old_addr, length); // is this the best way?
ret = mmap64(addr, length, prot, flags, fd, offset);
uint32_t new_flags = addr ? flags|MAP_FIXED : flags;
ret = mmap64(addr, length, prot, new_flags, fd, offset);
printf_log(LOG_DEBUG, " tried again with %p, got %p\n", addr, ret);
}
#endif
Expand Down

0 comments on commit d9a4fed

Please sign in to comment.