This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug driver/81498] New: Support build static PIE
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 20 Jul 2017 19:51:58 +0000
- Subject: [Bug driver/81498] New: Support build static PIE
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81498
Bug ID: 81498
Summary: Support build static PIE
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
Glibc hjl/pie/static branch at
https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/hjl/pie/static
supports static PIE, which is similar to static executable, but can be loaded
at any address without a dynamic linker:
[hjl@gnu-6 elf]$ readelf -hl 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: 0x8290
Start of program headers: 64 (bytes into file)
Start of section headers: 4532888 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 8
Size of section headers: 64 (bytes)
Number of section headers: 45
Section header string table index: 44
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000099905 0x0000000000099905 R E 0x200000
LOAD 0x000000000009a5a0 0x000000000029a5a0 0x000000000029a5a0
0x0000000000004d40 0x0000000000006230 RW 0x200000
DYNAMIC 0x000000000009cd48 0x000000000029cd48 0x000000000029cd48
0x00000000000001a0 0x00000000000001a0 RW 0x8
NOTE 0x0000000000000200 0x0000000000000200 0x0000000000000200
0x0000000000000044 0x0000000000000044 R 0x4
TLS 0x000000000009a5a0 0x000000000029a5a0 0x000000000029a5a0
0x0000000000000020 0x0000000000000060 R 0x8
GNU_EH_FRAME 0x000000000008ee18 0x000000000008ee18 0x000000000008ee18
0x00000000000018bc 0x00000000000018bc R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_RELRO 0x000000000009a5a0 0x000000000029a5a0 0x000000000029a5a0
0x0000000000002a60 0x0000000000002a60 R 0x1
Section to Segment mapping:
Segment Sections...
00 .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .rela.dyn
.rela.plt .init .plt .plt.got .text __libc_freeres_fn __libc_thread_freeres_fn
.fini .rodata .eh_frame_hdr .eh_frame .gcc_except_table
01 .tdata .init_array .fini_array .data.rel.ro .dynamic .got .got.plt
.data __libc_subfreeres __libc_IO_vtables __libc_atexit
__libc_thread_subfreeres .bss __libc_freeres_ptrs
02 .dynamic
03 .note.ABI-tag .note.gnu.build-id
04 .tdata .tbss
05 .eh_frame_hdr
06
07 .tdata .init_array .fini_array .data.rel.ro .dynamic .got
[hjl@gnu-6 elf]$ sln
Usage: sln src dest|file
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
[hjl@gnu-6 elf]$
To do that, we need to pass both -static and -pie as well as the PIE version
of crt*.o files to linker.