qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH] rules.mak: Use -r instead of -Wl


From: Paolo Bonzini
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] rules.mak: Use -r instead of -Wl, -r to fix building when PIE is default
Date: Tue, 29 Nov 2016 13:09:23 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0


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 <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?

Yes, I've already sent a pull request for it.

Paolo



reply via email to

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