Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2013 17:48:55 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Damjan Jovanovic <damjan.jov@gmail.com>
Cc:        freebsd-hackers@freebsd.org, freebsd-emulation@freebsd.org, tijl@coosemans.org
Subject:   Re: [patch] Wine DLL base address patches
Message-ID:  <20130220154855.GF2598@kib.kiev.ua>
In-Reply-To: <CAJm2B-mtXqZn0nQH4B9=fYik9gxSM8KAD5QcrLeqDOjXEnYfmg@mail.gmail.com>
References:  <CAJm2B-mtXqZn0nQH4B9=fYik9gxSM8KAD5QcrLeqDOjXEnYfmg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--L2zmpNdaDxUzilj2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 20, 2013 at 05:29:01PM +0200, Damjan Jovanovic wrote:
> Hi
>=20
> Wine needs some of its libraries to be loaded at specific base
> addresses (https://wiki.freebsd.org/Wine), something FreeBSD currently
> lacks.
>=20
> I've written a patch to the dynamic loader (/libexec/ld-elf.so.1) that
> loads libraries at their preferred base addresses
> (http://www.freebsd.org/cgi/query-pr.cgi?pr=3D176216), as well as a port
> of Prelink to FreeBSD which Wine uses to set base addresses
> (http://www.freebsd.org/cgi/query-pr.cgi?pr=3D176283). Both work :-),
> the changed dynamic loader doesn't show any problems in a few days of
> testing, and prelink works with the --reloc-only option as used by
> Wine.
>=20
> Please review/test/comment/commit.

Unfortunately, it is not safe. MAP_FIXED overrides any previous mappings
which could exist at the specified address.

What you could do, is
- either specify the desired base without MAP_FIXED. Kernel takes the base
  as the hint, but only uses it if the request completely fits into the
  hinted area without overriding any existing mapping. Also, the heap
  is explicitely avoided.
  The code would need to check if kernel honored hint by comparing the
  actual map address with the desired address, and act accordingly.
- or add a new mmap(2) flag, which would specify that mapping should be
  done at that address, if possible to not overlap with existing mapping,
  otherwise the mapping should fail.

--L2zmpNdaDxUzilj2
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQIcBAEBAgAGBQJRJPBnAAoJEJDCuSvBvK1B6RgP/14vXBpPuyAVre0mJ3Dh3TMl
zYVmheN9j5Un2a0LTq1U9UcD6FADWwY0G+0J2eSZHVSFOXA3YFxHq73+H9XNawOF
U+AHH0+4qQ/27jTJjr4vThjfiFuvN0ArkUrj+haAPMZlhQdr0y1FZl7stuyLo+gb
YYkYnZOu/tqvvT5MHVPNjgl9vWMANGcm41BzrGRK40NZ24kOhXwr5I1h5uCGFR7/
gxD5SUtKHVhT1ZF5pMVvObOcTAQrz/nlb6gI2sxhpdU7AnOLpCCGm0+ThNI3tmA8
fmqGze92fU0TFdAWMootevLVuOwgfZwlyUno++RG56zdtFJHBsHCCqvMlsywcRHD
4U15XSmFFDU5+WA4xjbPou/JVOQBUnyRQ6oYYQR8sdt7/tF77pYSvVcR9/V+eujU
cI/Zma512iwIW6uwHh9bI1dC1Os3Zqi+OBMelXFdF6zLqZfaMVtygS+E6comvj6j
7EvkzhGNJbByD8+3BD1huHPC7dP0E7f7sYIFLK72WQNLGm68RNl55IjB5EuhcBXP
nzgyMyCKCr8XhtB5Kzzwjs9rAVS14WljX00+WJUH4JhF24ddPs/huLDzM9wAb554
zDMTvicHFZSjG+uX7F9/3cgzm6X6Wbw1f5Tnip46FVkUyMfWs+7lq6uUn18oaR3w
GHjLcqV1zuKbcFyUUvuY
=j2JC
-----END PGP SIGNATURE-----

--L2zmpNdaDxUzilj2--



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