wine_anon_mmap MAP_FIXED patch
Ulrich Weigand
weigand at immd1.informatik.uni-erlangen.de
Wed Nov 14 20:03:02 CST 2001
Bang Jun-Young <junyoung at mogua.com> wrote:
> Why this is necessary is because most Win32 binaries expect itself
> to be loaded at fixed address (0x400000). GCC and M$ compilers seem
> to strip relocation info on .exe by default, so we need to ensure
> that on some OS, i.e. NetBSD. Refer to NetBSD/FreeBSD mmap(2) manpage
> on MAP_FIXED flag. On Linux, it shouldn't do any harm.
On Linux and Solaris, MAP_FIXED has a different meaning: it will
*replace* any pre-existing mapping at the given address, typically
causing corruption. I'm not sure what the BSD behaviour is; are
you sure they handle MAP_FIXED differently?
On Linux, this is not a problem because *without* MAP_FIXED, it
will always use the specified address unless there is a conflict
with existing mappings. On Solaris, we've implemented a hack
that emulates the Linux behaviour in this respect (look at the
routine solaris_try_mmap, which is called from wine_anon_mmap).
I guess the proper fix would be to implement a similiar BSD
specific workaround inside wine_anon_mmap. The Solaris version
will probably not work unchanged on BSD, however. If you are
correct in your interpretation of the semantics of MAP_FIXED
on BSD, a workaround could look like this: first, try mapping
with MAP_FIXED; if this fails, repeat without.
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand at informatik.uni-erlangen.de
More information about the wine-devel
mailing list