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 <[email protected]> >> >> 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". Paolo
