Commit 55ba3648 authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

libwine: Add support for mmap at fixed start addresses on FreeBSD.

The way to implement MAP_TRYFIXED on FreeBSD is call mmap() with MAP_FIXED | MAP_EXCL, which will allocate the mapping from the exact starting address if possible, and if that fails, call mmap() again without them. This gets PE DLLs loading at their correct base addresses, and fixes a FreeBSD-specific problem with Cygwin's fork() caused by cygwin1.dll loading at different base addresses in the parent and child. Signed-off-by: 's avatarDamjan Jovanovic <damjan.jov@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent b9dc3324
......@@ -211,18 +211,21 @@ void *wine_anon_mmap( void *start, size_t size, int prot, int flags )
if (!(flags & MAP_FIXED))
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
/* Even FreeBSD 5.3 does not properly support NULL here. */
if( start == NULL ) start = (void *)0x110000;
#endif
#ifdef MAP_TRYFIXED
/* If available, this will attempt a fixed mapping in-kernel */
flags |= MAP_TRYFIXED;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if ( start && mmap( start, size, prot, flags | MAP_FIXED | MAP_EXCL, get_fdzero(), 0 ) )
return start;
#elif defined(__svr4__) || defined(__NetBSD__) || defined(__APPLE__)
if ( try_mmap_fixed( start, size, prot, flags, get_fdzero(), 0 ) )
return start;
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
/* Even FreeBSD 5.3 does not properly support NULL here. */
if( start == NULL ) start = (void *)0x110000;
#endif
}
return mmap( start, size, prot, flags, get_fdzero(), 0 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment