[patch] Wine DLL base address patches

Konstantin Belousov kostikbel at gmail.com
Thu Feb 21 15:44:46 UTC 2013


On Thu, Feb 21, 2013 at 12:57:45AM +0200, Damjan Jovanovic wrote:
> On Wed, Feb 20, 2013 at 10:51 PM, Tijl Coosemans <tijl at coosemans.org> wrote:
> > On 20-02-2013 16:48, Konstantin Belousov wrote:
> >> 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.
> >
> > I've simplified the rtld patch to a single line. The second patch makes
> > Wine use -Ttext-segment linker flag instead of prelink. This requires
> > binutils from ports, but it's easier than porting prelink.
> >
> 
> All of that occurred to me as well.
> 
> The problem with that one-line rtld patch is that loading an
> application will now fail if any of its libraries cannot be loaded at
> their requested address.
But this is intended behaviour. Also, the default virtaddr base for the
shared libraries is 0, so the existing binaries should be not affected.

> 
> The problem with -Ttext-segment (and isn't it just -Ttext?) is that it
> doesn't seem to work: the base_vaddr seen by rtld will remain 0, and
> the address listed in /proc/.../map is different from what it should
> be. Also run "readelf -l" on a library compiled that way and compare
> with the output of one run through "prelink --reloc-only", you'll see
> the lowest VirtAddr and PhysAddr in LOAD headers change only with
> prelink. I really ported prelink because there was no other choice.
The -Ttext-segment does work. As indicated by Tijl, you need recent
binutils.  I just verified that ld 2.32.1 obeys -Ttext-segment.

You can also take a look at the default linker script to see how
-Ttext-segment is used, look for SEGMENT_START("text-segment").

> 
> See my attached test cases, and examine the contents of /proc/.../map
> while they run.


-------------- 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-emulation/attachments/20130221/1ea040e2/attachment.sig>


More information about the freebsd-emulation mailing list