Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Apr 1999 15:05:29 +1000
From:      "Andrew Reilly" <andrew@lake.com.au>
To:        Luoqi Chen <luoqi@watermarkgroup.com>
Cc:        andrew@lake.com.au, nox@jelal.kn-bremen.de, freebsd-emulation@FreeBSD.ORG
Subject:   Re: Wine, Win32 stripped executables vs FreeBSD mmap()
Message-ID:  <19990428150529.A26340@gurney.reilly.home>
In-Reply-To: <199904280141.VAA29678@lor.watermarkgroup.com>; from Luoqi Chen on Tue, Apr 27, 1999 at 09:41:22PM -0400
References:  <199904280141.VAA29678@lor.watermarkgroup.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Apr 27, 1999 at 09:41:22PM -0400, Luoqi Chen wrote:
> > As a simultaneous expert in Wine and FreeBSD, do you have any
> > thoughts on the problem I reported last week: I found that Wine
> > could not execute any of my Win32 programs, because the FreeBSD mmap
> > system call refused to allocate a block of VM at 0x4000000 for
> > the executable.  I poked around in /proc a little, and it didn't
> > nothing appeared to use virtual addresses lower than 0x8048000.
> > Is there some architectural reason for that space to be off
> > limmits in FreeBSD?
> > 
> You should be able to mmap at any address in user space (currently address
> <0xc0000000). I wrote a test program to map one anonymous page at 0x4000000
> and it worked. What's the errno from the mmap() call? How big is the block
> wine tried to allocate? What's the flag argument passed to mmap()?

I've done some poking around of my own, with ktrace this time,
and found some interesting things.

First, to answer your questions:

Errno: 0: mmap doesn't think it's failing, it just isn't
returning a block with the address we've requested.

How big? 0x6b000.

The whole call was:
mmap(0x400000,0x6b000,7,0x1002,-1,0)
which produced the result: 0x28a70000

Those flags are MAP_ANON and MAP_PRIVATE, as I'm sure you know.

The poking I did this morning was to try adding MAP_FIXED to the
flags, so that at least we'd see an error from the failure.
Well, now the map works and I get the address 0x400000 returned.
I've added a one-line patch to wine to include this flag:

--- work/wine-990214/files/file.c.orig  Wed Apr 28 15:00:48 1999
+++ work/wine-990214/files/file.c       Wed Apr 28 13:54:08 1999
@@ -1604,6 +1604,7 @@
 #ifdef MAP_PRIVATE
        flags |= MAP_PRIVATE;
 #endif
+/*AR:TRIAL:*/if (start) flags |= MAP_FIXED;    /* see if this helps */
     }
     else fd = unix_handle;
 
Well, that has done the trick for me.  I can now execute the Win32
assemblers and simulators that I was using before the upgrade,
so I'm a happy camper.

I'll send the patch to the Wine folk, to see if they want to try
it, but if you have any thoughts about why mmap was ignoring my
address "hint", I'd be keen to hear them.

-- 
Andrew


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990428150529.A26340>