emulators/linux-wine: Help in porting to FreeBSD

Tijl Coosemans tijl at ulyssis.org
Fri Mar 9 19:24:31 UTC 2007

On Tuesday 06 March 2007 15:01, Alexander Leidinger wrote:
> Quoting Scot Hetzel <swhetzel at gmail.com> (from Sat, 14 Oct 2006  
> 00:55:17 -0500):
> > I'm trying to create a port for emulators/linux-wine, so that we can
> > at least have wine running on FreeBSD/amd64 using the linuxator.  This
> > would then silence users who want wine (amd64/104311) to run under
> > FreeBSD/amd64.
> >
> > Currently, I am having a problem running linux-wine.  When it is run
> > as either root or as a user I get the following error:
> >
> > $ /compat/linux/usr/bin/wine
> > wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map
> > segment from shared object: Cannot allocate memory
> Do you get the same error with a recent current? I hope it may be  
> fixed with the mmap changes. But it may also be the way the memory is  
> laid out in FreeBSD vs. Linux. IIRC the native wine had a similar  
> problem until someone fixed the code for wine on FreeBSD. But I'm not  
> sure about this.

This is a problem with the FreeBSD mmap.

* The wine executable is loaded at 0x7bf00000.
* It reserves 0x00000000-0x60000000 and 0x80000000-(stack).
* Then a couple dlls are dlopen'ed (ntdll,kernel32,...).
* This fails because the freebsd mmap, when called without MAP_FIXED
  and NULL for the addr argument, looks for free space after the
  executable + maximum possible data segment (to preserve space for
  brk(2) style allocations). The default maximum data segment size is
  512MiB, so mmap is looking for free space well beyond 0x80000000
  which isn't there.

In current you could work around this by setting kern.maxdsiz="8M" or
so in /boot/loader.conf, but that probably causes problems for programs
that use brk(2). A better solutions would be to create a wrapper
program that reduces the data segment size with setrlimit(2) and then
runs wine with execv(3).

Anyway, I don't think that will give you a better Wine than the native
version. FreeBSD devices are not the same as on Linux for instance.

More information about the freebsd-emulation mailing list