This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING: [PATCH] Add --enable-static-pie to build static PIE


On 9/27/17, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> On 27/09/17 09:30, H.J. Lu wrote:
>> On 9/26/17, Joseph Myers <joseph@codesourcery.com> wrote:
>>> On Tue, 26 Sep 2017, H.J. Lu wrote:
>>>
>>>> Any objections?
>>>
>>> This is a complicated feature; it clearly needs someone to do a detailed
>>> technical review before it can go in, however long that takes.  It's
>>> only
>>> borderline-obvious patches one might consider committing after a while
>>> in
>>> the absence of objections but without review or relevant maintainership.
>>>
>>> Perhaps you could expand more on the design and the rationale for the
>>
>> Dynamic linker, ld.so, is a standalone program which can be loaded at
>> any address.  This patch adds a configure option, --enable-static-pie,
>> to embed the part of ld.so in static executable to create static position
>> independent executable (static PIE).
>>
>
> can it be too late to do the relocation in __libc_start_main?
>
> that comes after the crt1 startup code and an arch specific wrapper
> which may end up having R_*_RELATIVE relocs for various function
> pointers (including __libc_start_main itself and its arguments)
>
> what guarantees that __libc_start_main can always be called
> without relocations (pc relative calls have limits on some
> targets)?
>
> i'd expect the relocation to happen in the crt1.o startup code.
>

I expect that all relocations before __libc_start_main should be
resolved by linker.

For x86, I did

commit 5b736bc9b55115e67129e77db4de6cf193054cd2
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Aug 2 10:27:14 2017 -0700

    x86-64: Check PIC instead of SHARED in start.S

    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.

            * sysdeps/x86_64/start.S (_start): Check PIC instead of SHARED.

 commit 1e8e527dd9718eaebe8417b73befb0c821b7b327
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Aug 4 12:59:35 2017 -0700

    i386: Support static PIE in start.S

    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.  Also avoid dynamic relocation against main in static PIE since
    _start is the entry point before the executable is relocated.

            * sysdeps/i386/start.S (_start): Check Check PIC instead of
            SHARED.  Avoid dynamic relocation against main in static PIE.

I expected other targets can be fixed similarly.

H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]