From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 20 22:58:13 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 698E12D8; Wed, 20 Feb 2013 22:58:13 +0000 (UTC) (envelope-from damjan.jov@gmail.com) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by mx1.freebsd.org (Postfix) with ESMTP id B6828AF; Wed, 20 Feb 2013 22:58:12 +0000 (UTC) Received: by mail-lb0-f174.google.com with SMTP id l12so6395197lbo.19 for ; Wed, 20 Feb 2013 14:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=/V8kj3eFgSTjSq5Fy7prqZbw8GKmpMM1yOOo59+XPoA=; b=mB6ZzmtwR/IRBhdexuhSfb9NRMeS1uOTsxEbPcHXr3si7tBP39RejNbregbhkHWKUc wQDmRSsVZWgw/zkVYvg51c/BEyStpi+jcUZMY88hwx3ANtXFF1yReOgomHiIfPqUCP5C touga4jvIR3KplJdXtFFT8QzRo96tQpCQlqZSaswOeXa5ng/hOmAXmkHsDSSgEcEPku9 0T3MCOVmS5x5Xa+fsWsmNdauiQ8qXSKY3Ru8s3crfvYbPjkgwHpWW30fMhn7F/6qYWFN KJkDPUiEmWEgFqJtU4MkDKah4BpPNhEnu1FoIhPNNQ3pRNATozuZCd5OM3wTgYPTk4Bm yyXw== X-Received: by 10.152.111.67 with SMTP id ig3mr12427873lab.41.1361401085666; Wed, 20 Feb 2013 14:58:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.20.138 with HTTP; Wed, 20 Feb 2013 14:57:45 -0800 (PST) In-Reply-To: <51253759.70508@coosemans.org> References: <20130220154855.GF2598@kib.kiev.ua> <51253759.70508@coosemans.org> From: Damjan Jovanovic Date: Thu, 21 Feb 2013 00:57:45 +0200 Message-ID: Subject: Re: [patch] Wine DLL base address patches To: Tijl Coosemans Content-Type: multipart/mixed; boundary=f46d04088f171ba4d104d62fe4f9 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Konstantin Belousov , 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 22:58:13 -0000 --f46d04088f171ba4d104d62fe4f9 Content-Type: text/plain; charset=ISO-8859-1 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 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. 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. See my attached test cases, and examine the contents of /proc/.../map while they run. --f46d04088f171ba4d104d62fe4f9--