From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBO1B-0003Og-0h for qemu-devel@nongnu.org; Mon, 28 Nov 2016 10:38:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBO1A-0001rd-77 for qemu-devel@nongnu.org; Mon, 28 Nov 2016 10:38:57 -0500 References: <20161127162817.15144-1-bunk@stusta.de> <20161128152404.sywmey4pdcv7btup@bunk.spdns.de> From: Paolo Bonzini Message-ID: <36ee35dd-49ea-f2e3-fa1e-600483b9d4e7@redhat.com> Date: Mon, 28 Nov 2016 16:38:50 +0100 MIME-Version: 1.0 In-Reply-To: <20161128152404.sywmey4pdcv7btup@bunk.spdns.de> Content-Type: text/plain; charset=utf-8 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: Adrian Bunk Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org 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. Have y= ou >> tried asking the binutils folks about it too? >=20 > 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 what you mean by "position independent is already relocatable". Paolo