PR driver/81523: Make -static override -pie
commit5a402d649a7cb96bbf93625335458b55fae05b1d
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Aug 2017 22:06:21 +0000 (8 22:06 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Aug 2017 22:06:21 +0000 (8 22:06 +0000)
tree07a5613ddad59abf64333e6a154a92353fc98b9d
parent17443aa35e6933b80e62ea2fd083548272d441b4
PR driver/81523: Make -static override -pie

-static and -pie together behave differently depending on whether GCC is
configured with --enable-default-pie.  On x86, "-static -pie" fails to
create executable when --enable-default-pie isn't used, but creates a
static executable when --enable-default-pie is used.  This patch makes
-static completely override -pie to create a static executable, regardless
if --enable-default-pie is used to configure GCC.

gcc/

PR driver/81523
* gcc.c (NO_PIE_SPEC): Delete.
(PIE_SPEC): Define as !no-pie/pie.  Move static|shared|r
exclusion..
(LINK_PIE_SPEC): ..to here.
(LINK_COMMAND_SPEC): Support -no-pie.
* config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Correct
chain of crtbegin*.o selection, update for PIE_SPEC changes and
format.
(GNU_USER_TARGET_ENDFILE_SPEC): Similarly.
* config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Similarly.
(ENDFILE_CRTEND_SPEC): Similarly.

gcc/testsuite/

PR driver/81523
* gcc.dg/pie-7.c: New test.
* gcc.dg/pie-static-1.c: Likewise.
* gcc.dg/pie-static-2.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250974 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/gnu-user.h
gcc/config/sol2.h
gcc/gcc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pie-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-static-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-static-2.c [new file with mode: 0644]