qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] rules.mak: Use -r instead of -Wl, -r to fix bui


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] rules.mak: Use -r instead of -Wl, -r to fix building when PIE is default
Date: Tue, 29 Nov 2016 09:33:54 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

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 <address@hidden>
> >>>
> >>> 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 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 what
> > you mean by "position independent is already relocatable".
> 
> Aha, I looked at GCC source code and this is incorrect: "Use -r instead
> 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 linker.

Should we merge this patch for 2.8 with the commit updated to reflect this?

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]