From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 21 22:22:14 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5AC76403; Thu, 21 Feb 2013 22:22:14 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay003.isp.belgacom.be (mailrelay003.isp.belgacom.be [195.238.6.53]) by mx1.freebsd.org (Postfix) with ESMTP id BEFFFE2; Thu, 21 Feb 2013 22:22:13 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgEFAG2dJlFbs5l5/2dsb2JhbABFwRKBBRdzgh8BAQVWGAoBEAsOCgkWDwkDAgECASceBgEMAQUCAQEFiA0IvyGPDgeDQAOPHoElllGDCA Received: from 121.153-179-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.179.153.121]) by relay.skynet.be with ESMTP; 21 Feb 2013 23:20:43 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.6/8.14.6) with ESMTP id r1LMKg9M006426; Thu, 21 Feb 2013 23:20:42 +0100 (CET) (envelope-from tijl@coosemans.org) Message-ID: <51269DB3.2070603@coosemans.org> Date: Thu, 21 Feb 2013 23:20:35 +0100 From: Tijl Coosemans User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:17.0) Gecko/20130129 Thunderbird/17.0.2 MIME-Version: 1.0 To: Konstantin Belousov , Damjan Jovanovic Subject: Re: [patch] Wine DLL base address patches References: <20130220154855.GF2598@kib.kiev.ua> <51253759.70508@coosemans.org> <20130221154433.GY2598@kib.kiev.ua> In-Reply-To: <20130221154433.GY2598@kib.kiev.ua> X-Enigmail-Version: 1.4.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigF08F74E68299AB2CD11F700A" Cc: freebsd-hackers@freebsd.org, freebsd-emulation@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Feb 2013 22:22:14 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigF08F74E68299AB2CD11F700A Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 21-02-2013 16:44, Konstantin Belousov wrote: > On Thu, Feb 21, 2013 at 12:57:45AM +0200, Damjan Jovanovic wrote: >> On Wed, Feb 20, 2013 at 10:51 PM, Tijl Coosemans = 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 curren= tly >>>>> lacks. >>>>> >>>>> I've written a patch to the dynamic loader (/libexec/ld-elf.so.1) t= hat >>>>> 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. >>>>> >>>>> Please review/test/comment/commit. >>>> >>>> Unfortunately, it is not safe. MAP_FIXED overrides any previous mapp= ings >>>> which could exist at the specified address. >>> >>> I've simplified the rtld patch to a single line. The second patch mak= es >>> 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.= >=20 >> >> 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. >=20 > You can also take a look at the default linker script to see how > -Ttext-segment is used, look for SEGMENT_START("text-segment"). Yes, -Ttext sets the address of the .text section and -Ttext-segment that of the text segment. It does work for me. The output of /proc/.../ma= p looks correct as does the output of "info share" in winedbg, but to be sure I've asked on wine-devel mailing list if they see any problem with this approach. --------------enigF08F74E68299AB2CD11F700A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iF4EAREIAAYFAlEmnbkACgkQfoCS2CCgtiuqEgD8CK7u+iaYSadNZnZE7cQSc87a YvdFZnnS/TY6Ny+j40oA/3AREjS15QyntDDo+E+1v2sxuqkYhBCzteaRtAJnyeNV =KKZp -----END PGP SIGNATURE----- --------------enigF08F74E68299AB2CD11F700A--