[patch] Wine DLL base address patches

Konstantin Belousov kostikbel at gmail.com
Wed Feb 20 15:49:08 UTC 2013


On Wed, Feb 20, 2013 at 05:29:01PM +0200, Damjan Jovanovic wrote:
> Hi
> 
> Wine needs some of its libraries to be loaded at specific base
> addresses (https://wiki.freebsd.org/Wine), something FreeBSD currently
> lacks.
> 
> 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=176216), 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=176283). 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.
> 
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130220/94d8f9ef/attachment.sig>


More information about the freebsd-hackers mailing list