Skip to content

Commit

Permalink
Use rcrt1.o%s/grcrt1.o%s to relocate static PIE
Browse files Browse the repository at this point in the history
crt1.o is used to create dynamic and non-PIE static executables.  Static
PIE needs to link with rcrt1.o, instead of crt1.o, which is also used by
musl libc and OpenBSD:

https://gcc.gnu.org/ml/gcc/2015-06/msg00008.html

to relocate static PIE at run-time.  When -pg is used with -static-pie,
grcrt1.o should be used.

	* config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
	rcrt1.o%s/grcrt1.o%s for -static-pie.

From-SVN: r254890
  • Loading branch information
hjl-tools authored and H.J. Lu committed Nov 17, 2017
1 parent 274c2d3 commit 5dbc006
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-11-17 H.J. Lu <[email protected]>

* config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
rcrt1.o%s/grcrt1.o%s for -static-pie.

2017-11-17 Jan Hubicka <[email protected]>

* i386.c (ix86_multiplication_cost, ix86_division_cost,
Expand Down
5 changes: 3 additions & 2 deletions gcc/config/gnu-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined HAVE_LD_PIE
#define GNU_USER_TARGET_STARTFILE_SPEC \
"%{shared:; \
pg|p|profile:gcrt1.o%s; \
pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
static:crt1.o%s; \
static-pie|" PIE_SPEC ":Scrt1.o%s; \
static-pie:rcrt1.o%s; \
" PIE_SPEC ":Scrt1.o%s; \
:crt1.o%s} \
crti.o%s \
%{static:crtbeginT.o%s; \
Expand Down

0 comments on commit 5dbc006

Please sign in to comment.