This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch ob] Disallow -pie and -static
Mike Frysinger <vapier@gentoo.org> writes:
> On Monday 27 February 2012 14:01:37 Ian Lance Taylor wrote:
>> Mike Frysinger <vapier@gentoo.org> writes:
>> > On Monday 27 February 2012 12:41:22 Ian Lance Taylor wrote:
>> >> Mike Frysinger writes:
>> >> > On Tuesday 14 February 2012 19:48:43 Cary Coutant wrote:
>> >> >> I'm committing this patch under the trivial and obvious rule. If -pie
>> >> >> and -static are both given together, gold will currently issue an
>> >> >> internal error.
>> >> >
>> >> > shouldn't there be a bug to fix this then ? there's no technical
>> >> > reason for disallowing static pie's from the perspective of the
>> >> > linker ...
>> >>
>> >> On GNU/Linux a PIE is just an executable shared library. How would you
>> >> implement a statically linked PIE?
>> >
>> > from what perspective ? if i build all my code with -fPIE (including
>> > libc.a and friends), then link with -static -pie, i should have an ELF
>> > that doesn't need shared libraries nor runtime ldso and can be run from
>> > any address.
>>
>> But linking with -pie really just generates a shared library. And a
>> shared library requires ld.so. So I don't understand what you would
>> generate.
>
> my point was from the perspective of the linker, it should not care. from the
> perspective of glibc, there is work to be done.
But the linker has to care, because generating a shared library that
uses ld.so is one thing, and doing something else that does not use
ld.so is a different thing.
For example: should the linker create a PT_INTERP segment for -static
-pie?
> my point was just that saying, from the perspective of the linker, "-pie and -
> static are incompatible" is wrong.
With the current definitions of the options as used in gold, it is not
wrong. -static means a statically linked executable with no dynamic
relocations and only PT_LOAD segments. -pie means a shared library with
dynamic relocations and PT_INTERP and PT_DYNAMIC segments. These are
purely linker issues, not affected by startup files or libraries.
Again, we could define what -static -pie means, but that definition
would include defining how the linker is supposed to handle the option
combination.
Ian