This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: Add --enable-static-pie to build static executables as PIE
On Tue, Jul 18, 2017 at 12:57 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> On 18/07/17 19:58, H.J. Lu wrote:
>> On Tue, Jul 18, 2017 at 8:21 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>> On 18/07/17 14:48, Alan Modra wrote:
>>>> On Tue, Jul 18, 2017 at 05:30:48AM -0700, H.J. Lu wrote:
>>>>> On Mon, Jul 17, 2017 at 9:25 PM, Alan Modra <amodra@gmail.com> wrote:
>>>>> Linker needs to support --no-dynamic-linker.
>>>>
>>>> Is there really much to be gained from PIEs that don't use ld.so
>>>> versus those that do?
>>>>
>>>
>>> in glibc ld.so in principle only works with one particular
>>> version of glibc, you cannot move a static linked pie binary
>>> to another system if it has ld.so dependency.
>>>
>>
>> Please checkout hl/pie/static branch at
>>
>> https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/hl/pie/static
>>
>> It works surprising well on x86-64. The changes are relative minor and there
>> are no regressions. The gcc driver only needs some minor changes to create
>> static PIE.
>>
>> I am working on i386, mainly PIC vs SHARED.
>>
>
> how can you do it without introducing a new crt1
> file that jumps to __libc_start_main with pointer
> arguments relocated? i thought
>
> Scrt1.o assumes the dynlinker relocates
> crt1.o assumes non-pic.
On x86, both Scrt1.o and crt1.o are compiled from the source. With
static PIE, both are compiled with -DPIC and both support PIC.
> (you seem to have 'self relocation' in __libc_start_main
> but that seems too late: its arguments may already need
> relocations?)
>
Self relocation is performed before any arguments are used.
--
H.J.