From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBhE7-00041h-5C for qemu-devel@nongnu.org; Tue, 29 Nov 2016 07:09:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBhE1-0005cs-5U for qemu-devel@nongnu.org; Tue, 29 Nov 2016 07:09:35 -0500 References: <20161127162817.15144-1-bunk@stusta.de> <20161128152404.sywmey4pdcv7btup@bunk.spdns.de> <36ee35dd-49ea-f2e3-fa1e-600483b9d4e7@redhat.com> <460f994a-fe47-1d1e-0d26-1220d8a05256@redhat.com> <20161129093354.GF5152@stefanha-x1.localdomain> From: Paolo Bonzini Message-ID: <3496f2a1-cb1d-9be0-b004-3f4812d60660@redhat.com> Date: Tue, 29 Nov 2016 13:09:23 +0100 MIME-Version: 1.0 In-Reply-To: <20161129093354.GF5152@stefanha-x1.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] rules.mak: Use -r instead of -Wl, -r to fix building when PIE is default List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Adrian Bunk , qemu-trivial@nongnu.org, qemu-devel@nongnu.org On 29/11/2016 10:33, Stefan Hajnoczi wrote: > On Mon, Nov 28, 2016 at 04:42:54PM +0100, Paolo Bonzini wrote: >> >> >> On 28/11/2016 16:38, Paolo Bonzini wrote: >>> >>> >>> On 28/11/2016 16:24, Adrian Bunk wrote: >>>> On Mon, Nov 28, 2016 at 04:05:33PM +0100, Paolo Bonzini wrote: >>>>> >>>>> >>>>> On 27/11/2016 17:28, Adrian Bunk wrote: >>>>>> Building qemu fails in distributions where gcc enables PIE >>>>>> by default (e.g. Debian unstable) with: >>>>>> /usr/bin/ld: -r and -pie may not be used together >>>>>> >>>>>> -r and -pie cannot be used together in the linker, >>>>>> and position independent is already relocatable. >>>>>> >>>>>> Use -r instead of -Wl,-r to avoid gcc passing -r to the >>>>>> linker when PIE is enabled. >>>>>> >>>>>> Signed-off-by: Adrian Bunk >>>>> >>>>> I think this is a bug in the linker. If the linker is producing >>>>> relocatable objects by default, it has no reason to refuse -r. Hav= e you >>>>> tried asking the binutils folks about it too? >>>> >>>> The linker knows nothing about this default, gcc is passing -pie >>>> to the linker. >>> >>> The linker is receiving "-r -pie". It can satisfy the requirement of >>> producing a relocatable object by discarding the "-r", but it doesn't= . >>> That'd be a linker bug. >>> >>> But in fact ELF makes PIE ET_DYN and relocatable ET_REL. That would >>> make the linker error the right thing, but then I don't understand wh= at >>> you mean by "position independent is already relocatable". >> >> Aha, I looked at GCC source code and this is incorrect: "Use -r instea= d >> of -Wl,-r to avoid gcc passing -r to the linker when PIE is enabled". >> When GCC sees -r (as opposed to -Wl,-r) it does not pass -pie to the l= inker. >=20 > Should we merge this patch for 2.8 with the commit updated to reflect t= his? Yes, I've already sent a pull request for it. Paolo