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: RFC: Add --enable-static-pie to build static executables as PIE


On Mon, Jul 17, 2017 at 9:25 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Jul 17, 2017 at 03:57:47PM -0700, H.J. Lu wrote:
>> On Mon, Jul 17, 2017 at 3:29 PM, Rich Felker <dalias@libc.org> wrote:
>> > On Mon, Jul 17, 2017 at 08:58:22AM -0700, H.J. Lu wrote:
>> >> Hi,
>> >>
>> >> Are there any interests for --enable-static-pie, which builds static
>> >> executables as PIE?
>> >
>> > Can you clarify what you're asking about? Is this asking if glibc is
>> > interested in providing the runtime support (crt variant) for gcc to
>> > be able to produce static PIE executables using glibc? I'm unclear on
>> > whose configure script would need --enable-static-pie.
>> >
>>
>> --enable-static-pie will be a configure option to glibc:
>>
>> 1. Build libc.a with -fPIE.
>> 2. Update pointers in static PIE.
>> 3. Apply IREL relocations for static PIE.
>> 4 ....
>
> Explain first exactly what you mean by a "static PIE".
>
> - Will it be ET_EXEC or ET_DYN?

[hjl@gnu-tools-1 build-x86_64-linux]$ readelf -h elf/sln
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x84d0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          4567088 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         7
  Size of section headers:           64 (bytes)
  Number of section headers:         44
  Section header string table index: 43
[hjl@gnu-tools-1 build-x86_64-linux]$ ./elf/sln
Usage: sln src dest|file

For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
[hjl@gnu-tools-1 build-x86_64-linux]$ ldd elf/sln
statically linked
[hjl@gnu-tools-1 build-x86_64-linux]$

> - What practical benefit do you get with a "static PIE"?

A static PIE can be loaded at random address without
dynamic linker.

> - What linker and kernel changes will be needed?
>

No kernel change is needed.  Linker needs to support --no-dynamic-linker.
On x86-64, binutils 2.29 branch or master branch is needed for

https://sourceware.org/bugzilla/show_bug.cgi?id=21782

-- 
H.J.


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