From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 20 20:51:55 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 DE5E7E4C; Wed, 20 Feb 2013 20:51:55 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay010.isp.belgacom.be (mailrelay010.isp.belgacom.be [195.238.6.177]) by mx1.freebsd.org (Postfix) with ESMTP id EE1053F4; Wed, 20 Feb 2013 20:51:54 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAFAGw2JVFbs5l5/2dsb2JhbABFwF+BARdzgh8BAQUnLyMQCw4KBQQlDwIoHgYBDAEHAQEFiA0IwE6PDgeDQAOPGIElAZZJgwg 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; 20 Feb 2013 21:51:46 +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 r1KKpj4e088264; Wed, 20 Feb 2013 21:51:46 +0100 (CET) (envelope-from tijl@coosemans.org) Message-ID: <51253759.70508@coosemans.org> Date: Wed, 20 Feb 2013 21:51:37 +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> In-Reply-To: <20130220154855.GF2598@kib.kiev.ua> X-Enigmail-Version: 1.4.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig4D62C2023304E37962419127" 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: Wed, 20 Feb 2013 20:51:55 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4D62C2023304E37962419127 Content-Type: multipart/mixed; boundary="------------080104070008010904010603" This is a multi-part message in MIME format. --------------080104070008010904010603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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=3D176216), as well as a po= rt >> 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. >=20 > Unfortunately, it is not safe. MAP_FIXED overrides any previous mapping= s > 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. --------------080104070008010904010603 Content-Type: text/plain; charset=ISO-8859-15; name="rtld-wine.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rtld-wine.diff" Index: libexec/rtld-elf/map_object.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- libexec/rtld-elf/map_object.c (revision 246986) +++ libexec/rtld-elf/map_object.c (working copy) @@ -175,7 +175,7 @@ map_object(int fd, const char *path, const struct base_vaddr =3D trunc_page(segs[0]->p_vaddr); base_vlimit =3D round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_mem= sz); mapsize =3D base_vlimit - base_vaddr; - base_addr =3D hdr->e_type =3D=3D ET_EXEC ? (caddr_t) base_vaddr : NU= LL; + base_addr =3D (caddr_t) base_vaddr; =20 mapbase =3D mmap(base_addr, mapsize, PROT_NONE, MAP_ANON | MAP_PRIVA= TE | MAP_NOCORE, -1, 0); --------------080104070008010904010603 Content-Type: text/plain; charset=ISO-8859-15; name="wine-devel-image-base.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="wine-devel-image-base.diff" Index: Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- Makefile (revision 312556) +++ Makefile (working copy) @@ -28,7 +28,7 @@ LATEST_LINK=3D wine-devel CPPFLAGS+=3D -I${LOCALBASE}/include LDFLAGS+=3D -L${LOCALBASE}/lib -USE_GCC=3D any +USE_GCC=3D 4.7 GNU_CONFIGURE=3D yes CONFIGURE_ARGS+=3D--verbose --disable-tests \ --without-alsa --without-capi --without-dbus \ Index: files/patch-tools-winegcc-utils.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- files/patch-tools-winegcc-utils.h (revision 0) +++ files/patch-tools-winegcc-utils.h (working copy) @@ -0,0 +1,12 @@ +--- tools/winegcc/utils.h.orig ++++ tools/winegcc/utils.h +@@ -42,7 +42,8 @@ +=20 + enum target_platform + { +- PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_SOLARIS, PLATFORM_WI= NDOWS, PLATFORM_CYGWIN ++ PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_FREEBSD, PLATFORM_SO= LARIS, ++ PLATFORM_WINDOWS, PLATFORM_CYGWIN + }; +=20 + void error(const char* s, ...) DECLSPEC_NORETURN; Index: files/patch-tools-winegcc-winegcc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- files/patch-tools-winegcc-winegcc.c (revision 0) +++ files/patch-tools-winegcc-winegcc.c (working copy) @@ -0,0 +1,32 @@ +--- tools/winegcc/winegcc.c.orig ++++ tools/winegcc/winegcc.c +@@ -172,6 +172,7 @@ + { + { "macos", PLATFORM_APPLE }, + { "darwin", PLATFORM_APPLE }, ++ { "freebsd", PLATFORM_FREEBSD }, + { "solaris", PLATFORM_SOLARIS }, + { "cygwin", PLATFORM_CYGWIN }, + { "mingw32", PLATFORM_WINDOWS }, +@@ -232,6 +233,8 @@ +=20 + #ifdef __APPLE__ + static enum target_platform build_platform =3D PLATFORM_APPLE; ++#elif defined(__FreeBSD__) ++static enum target_platform build_platform =3D PLATFORM_FREEBSD; + #elif defined(__sun) + static enum target_platform build_platform =3D PLATFORM_SOLARIS; + #elif defined(__CYGWIN__) +@@ -1020,6 +1023,12 @@ + if (opts->strip) + strarray_add(link_args, "-Wl,-x"); + break; ++ case PLATFORM_FREEBSD: ++ if (opts->image_base) ++ { ++ strarray_add(link_args, strmake("-Wl,-Ttext-segment=3D%s", = opts->image_base)); ++ } ++ break; + case PLATFORM_SOLARIS: + { + char *mapfile =3D get_temp_file( output_name, ".map" ); --------------080104070008010904010603-- --------------enig4D62C2023304E37962419127 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) iF4EAREIAAYFAlElN2EACgkQfoCS2CCgtisDnAD9GONXdn6WPP8p/XyoBD88blqC ddZpmexN7gZj7nGrtGoA/0Khh2ETumbLDXjIkXceVf2xxzOwJSinzMXEAr+3X6LR =0GBW -----END PGP SIGNATURE----- --------------enig4D62C2023304E37962419127--