+2015-05-27 Magnus Granberg <zorry@gentoo.org>
+ H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile.in (COMPILER): Add @NO_PIE_CFLAGS@.
+ (BUILD_CFLAGS): Likewise.
+ (BUILD_CXXFLAGS): Likewise.
+ (LINKER): Add @NO_PIE_FLAG@.
+ (BUILD_LDFLAGS): Likewise.
+ (libgcc.mvars): Set NO_PIE_CFLAGS to -fno-PIE for
+ --enable-default-pie.
+ * common.opt (fPIE): Initialize to -1.
+ (fpie): Likewise.
+ (no-pie): New option.
+ (pie): Replace "Negative(shared)" with "Negative(no-pie)".
+ * configure.ac: Add --enable-default-pie.
+ (NO_PIE_CFLAGS): New. Check if -fno-PIE works. AC_SUBST.
+ (NO_PIE_FLAG): New. Check if -no-pie works. AC_SUBST.
+ * defaults.h (DEFAULT_FLAG_PIE): New. Default PIE to -fPIE.
+ * gcc.c (NO_PIE_SPEC): New.
+ (PIE_SPEC): Likewise.
+ (NO_FPIE1_SPEC): Likewise.
+ (FPIE1_SPEC): Likewise.
+ (NO_FPIE2_SPEC): Likewise.
+ (FPIE2_SPEC): Likewise.
+ (NO_FPIE2_SPEC): Likewise.
+ (FPIE_SPEC): Likewise.
+ (NO_FPIE_SPEC): Likewise.
+ (NO_FPIC1_SPEC): Likewise.
+ (FPIC1_SPEC): Likewise.
+ (NO_FPIC2_SPEC): Likewise.
+ (FPIC2_SPEC): Likewise.
+ (NO_FPIC2_SPEC): Likewise.
+ (FPIC_SPEC): Likewise.
+ (NO_FPIC_SPEC): Likewise.
+ (NO_FPIE1_AND_FPIC1_SPEC): Likewise.
+ (FPIE1_OR_FPIC1_SPEC): Likewise.
+ (NO_FPIE2_AND_FPIC2_SPEC): Likewise.
+ (FPIE2_OR_FPIC2_SPEC): Likewise.
+ (NO_FPIE_AND_FPIC_SPEC): Likewise.
+ (FPIE_OR_FPIC_SPEC): Likewise.
+ (LD_PIE_SPEC): Likewise.
+ (LINK_PIE_SPEC): Handle -no-pie. Use PIE_SPEC and LD_PIE_SPEC.
+ * opts.c (finish_options): Update opts->x_flag_pie if it is -1.
+ * config/darwin.h (PIE_SPEC): Renamed to ...
+ (DARWIN_PIE_SPEC): This.
+ (LINK_SPEC): Replace PIE_SPEC with DARWIN_PIE_SPEC.
+ * config/darwin9.h (PIE_SPEC): Renamed to ...
+ (DARWIN_PIE_SPEC): This.
+ * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
+ PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
+ * config/openbsd.h (ASM_SPEC): Use FPIE1_OR_FPIC1_SPEC and
+ FPIE2_OR_FPIC2_SPEC.
+ * config/m68k/netbsd-elf.h (ASM_SPEC): Likewise.
+ * config/m68k/openbsd.h (ASM_SPEC): Likewise.
+ * gcc/config/sol2.h (ASM_PIC_SPEC): Likewise.
+ * config/arm/freebsd.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise.
+ * config/arm/netbsd-elf.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise.
+ * config/arm/semi.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise.
+ * config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise.
+ * config/m32r/m32r.h (ASM_SPEC): Likewise.
+ * config/m68k/uclinux.h (DRIVER_SELF_SPECS): Likewise.
+ * config/rs6000/linux64.h (ASM_SPEC32): Likewise.
+ * config/rs6000/sysv4.h (ASM_SPEC): Likewise.
+ * config/sparc/freebsd.h (ASM_SPEC): Likewise.
+ * config/sparc/linux.h (ASM_SPEC): Likewise.
+ * config/sparc/linux64.h (ASM_SPEC): Likewise.
+ * config/sparc/netbsd-elf.h (ASM_SPEC): Likewise.
+ * config/sparc/openbsd64.h (ASM_SPEC): Likewise.
+ * config/sparc/sp-elf.h (ASM_SPEC): Likewise.
+ * config/sparc/sp64-elf.h (ASM_SPEC): Likewise.
+ * config/sparc/sparc.h (ASM_SPEC): Likewise.
+ * config/sparc/sysv4.h (ASM_SPEC): Likewise.
+ * config/sparc/vxworks.h (ASM_SPEC): Likewise.
+ * config/c6x/elf-common.h (ASM_SPEC): Use NO_FPIC2_SPEC,
+ FPIC2_SPEC, FPIC1_SPEC and FPIC2_SPEC.
+ * config/c6x/uclinux-elf.h (LINK_SPEC): Use FPIE_SPEC.
+ * config/frv/frv.h (DRIVER_SELF_SPECS): Use FPIC_SPEC,
+ NO_FPIC_SPEC and NO_FPIE1_AND_FPIC1_SPEC.
+ (ASM_SPEC): Use FPIE1_OR_FPIC1_SPEC and FPIE2_OR_FPIC2_SPEC.
+ * config/m68k/m68k.h (ASM_PCREL_SPEC): Use FPIC_SPEC and
+ NO_FPIC_SPEC.
+ * config/mips/gnu-user.h (NO_SHARED_SPECS): Use
+ NO_FPIE_AND_FPIC_SPEC.
+ * config/mips/vxworks.h (SUBTARGET_ASM_SPEC): Use FPIC_SPEC.
+ * config/rs6000/freebsd64.h (ASM_SPEC32): Likewise.
+ * config/rs6000/vxworks.h (ASM_SPEC): Likewise.
+ * config/vax/linux.h (ASM_SPEC): Likewise.
+ * doc/install.texi: Document --enable-default-pie.
+ * doc/invoke.texi: Document -no-pie.
+ * config.in: Regenerated.
+ * configure: Likewise.
+
2015-05-28 Thomas Preud'homme <thomas.preudhomme@arm.com>
PR rtl-optimization/66168
LINKER_FLAGS = $(CFLAGS)
endif
+# We don't want to compile the compilers with -fPIE, it make PCH fail.
+COMPILER += @NO_PIE_CFLAGS@
+
+# Link with -no-pie since we compile the compiler with -fno-PIE.
+LINKER += @NO_PIE_FLAG@
+
# Like LINKER, but use a mutex for serializing front end links.
ifeq (@DO_LINK_MUTEX@,true)
LLINKER = $(SHELL) $(srcdir)/lock-and-run.sh linkfe.lck $(LINKER)
CXX_FOR_BUILD = @CXX_FOR_BUILD@
BUILD_CFLAGS= @BUILD_CFLAGS@ -DGENERATOR_FILE
BUILD_CXXFLAGS = @BUILD_CXXFLAGS@ -DGENERATOR_FILE
+BUILD_CFLAGS += @NO_PIE_CFLAGS@
+BUILD_CXXFLAGS += @NO_PIE_CFLAGS@
# Native compiler that we use. This may be C++ some day.
COMPILER_FOR_BUILD = $(CXX_FOR_BUILD)
# Native linker and preprocessor flags. For x-fragment overrides.
BUILD_LDFLAGS=@BUILD_LDFLAGS@
+BUILD_LDFLAGS += @NO_PIE_FLAG@
BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
-I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS)
echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars
echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars
echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars
+ if test @enable_default_pie@ = yes; then \
+ NO_PIE_CFLAGS="-fno-PIE"; \
+ else \
+ NO_PIE_CFLAGS=; \
+ fi; \
+ echo NO_PIE_CFLAGS = "$$NO_PIE_CFLAGS" >> tmp-libgcc.mvars
mv tmp-libgcc.mvars libgcc.mvars
+2015-05-27 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gcc-interface/Makefile.in (TOOLS_LIBS): Add @NO_PIE_FLAG@.
+
2015-05-27 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (elaborate_all_entities): Do not elaborate an
../../libcommon.a ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
../$(LIBBACKTRACE) ../$(LIBIBERTY) $(SYSLIBS) $(TGT_LIB)
+# Add -no-pie to TOOLS_LIBS since some of them are compiled with -fno-PIE.
+TOOLS_LIBS += @NO_PIE_FLAG@
+
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation
Generate position-independent code if possible (large mode)
fPIE
-Common Report Var(flag_pie,2) Negative(fpic)
+Common Report Var(flag_pie,2) Negative(fpic) Init(-1)
Generate position-independent code for executables if possible (large mode)
fpic
Generate position-independent code if possible (small mode)
fpie
-Common Report Var(flag_pie,1) Negative(fPIC)
+Common Report Var(flag_pie,1) Negative(fPIC) Init(-1)
Generate position-independent code for executables if possible (small mode)
fplt
symbolic
Driver
-pie
+no-pie
Driver RejectNegative Negative(shared)
+Don't create a position independent executable
+
+pie
+Driver RejectNegative Negative(no-pie)
Create a position independent executable
z
#endif
+/* Define if your target supports default PIE and it is enabled. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_DEFAULT_PIE
+#endif
+
+
/* Define if you want more run-time sanity checks for dataflow. */
#ifndef USED_FOR_TARGET
#undef ENABLE_DF_CHECKING
#undef SUBTARGET_EXTRA_ASM_SPEC
#define SUBTARGET_EXTRA_ASM_SPEC \
"%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5} " TARGET_FIX_V4BX_SPEC " \
- %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+ %{" FPIE_OR_FPIC_SPEC ":-k}"
#undef SUBTARGET_ASM_FLOAT_SPEC
#ifdef TARGET_FREEBSD_ARM_HARD_FLOAT
#undef SUBTARGET_EXTRA_ASM_SPEC
#define SUBTARGET_EXTRA_ASM_SPEC \
- "-matpcs %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+ "-matpcs %{" FPIE_OR_FPIC_SPEC ":-k}"
/* Default to full VFP if -mfloat-abi=hard is specified. */
#undef SUBTARGET_ASM_FLOAT_SPEC
binutils can't. */
#ifndef ASM_SPEC
#define ASM_SPEC "\
-%{fpic|fpie: -k} %{fPIC|fPIE: -k} \
+%{" FPIE_OR_FPIC_SPEC ": -k} \
%{mbig-endian:-EB} \
%(arm_cpu_spec) \
%{mapcs-float:-mfloat} \
#undef ASM_SPEC
#define ASM_SPEC "%{march=*:-march=%*} %{mbig-endian:-mbig-endian} \
- %{mdsbt:-mdsbt %{!fPIC:-mpid=near} %{fPIC:-mpid=far -mpic} %{fpic:-mpic}} \
- %{!mdsbt:%{fpic:-mpic -mpid=near} %{fPIC:-mpic -mpid=far}}"
+ %{mdsbt:-mdsbt %{" NO_FPIC2_SPEC ":-mpid=near} \
+ %{" FPIC2_SPEC ":-mpid=far -mpic} %{" FPIC1_SPEC ":-mpic}} \
+ %{!mdsbt:%{" FPIC1_SPEC ":-mpic -mpid=near} \
+ %{" FPIC2_SPEC ":-mpic -mpid=far}}"
#undef DATA_SECTION_ASM_OP
#define DATA_SECTION_ASM_OP "\t.section\t\".fardata\",\"aw\""
#undef LINK_SPEC
#define LINK_SPEC ENDIAN_LINK_SPEC \
- "%{shared} %{fpie|fPIE:-pie} \
+ "%{shared} %{" FPIE_SPEC ":-pie} \
%{!shared: %{!static: \
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker " UCLIBC_DYNAMIC_LINKER "}} \
"--em=criself \
%{!march=*:%{!mcpu=*:--march=v32}} \
%{!fleading-underscore:--no-underscore}\
- %{fPIC|fpic|fPIE|fpie: --pic}"
+ %{" FPIE_OR_FPIC_SPEC ": --pic}"
#else
# define CRIS_ASM_SUBTARGET_SPEC \
"--em=criself \
%{!march=*:%{!mcpu=*:--march=v10}} \
%{!fleading-underscore:--no-underscore}\
- %{fPIC|fpic|fPIE|fpie: --pic}"
+ %{" FPIE_OR_FPIC_SPEC ": --pic}"
#endif
/* Previously controlled by target_flags. */
#define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*}"
#endif
-#define PIE_SPEC "%{fpie|pie|fPIE:}"
+#define DARWIN_PIE_SPEC "%{fpie|pie|fPIE:}"
/* Please keep the random linker options in alphabetical order (modulo
'Z' and 'no' prefixes). Note that options taking arguments may appear
%:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \
%:version-compare(< 10.5 mmacosx-version-min= suppress)}} \
%{Zmultiplydefinedunused*:-multiply_defined_unused %*} \
- " PIE_SPEC " \
+ " DARWIN_PIE_SPEC " \
%{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \
%{read_only_relocs} \
%{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \
/* Tell collect2 to run dsymutil for us as necessary. */
#define COLLECT_RUN_DSYMUTIL 1
-#undef PIE_SPEC
-#define PIE_SPEC \
+#undef DARWIN_PIE_SPEC
+#define DARWIN_PIE_SPEC \
"%{fpie|pie|fPIE: \
%{mdynamic-no-pic: %n'-mdynamic-no-pic' overrides '-pie', '-fpie' or '-fPIE'; \
:-pie}}"
"%{mno-pack:\
%{!mhard-float:-msoft-float}\
%{!mmedia:-mno-media}}\
- %{!mfdpic:%{fpic|fPIC: -multilib-library-pic}}\
+ %{!mfdpic:%{" FPIC_SPEC ": -multilib-library-pic}}\
%{mfdpic:%{!fpic:%{!fpie:%{!fPIC:%{!fPIE:\
%{!fno-pic:%{!fno-pie:%{!fno-PIC:%{!fno-PIE:-fPIE}}}}}}}} \
- %{!mno-inline-plt:%{O*:%{!O0:%{!Os:%{fpic|fPIC:-minline-plt} \
- %{!fpic:%{!fPIC:%{!O:%{!O1:%{!O2:-minline-plt}}}}}}}}} \
- %{!mno-gprel-ro:%{!fpic:%{!fpie:-mgprel-ro}}}} \
+ %{!mno-inline-plt:%{O*:%{!O0:%{!Os:%{" FPIC_SPEC ":-minline-plt} \
+ %{" NO_FPIC_SPEC ":%{!O:%{!O1:%{!O2:-minline-plt}}}}}}}} \
+ %{!mno-gprel-ro:%{" NO_FPIE1_AND_FPIC1_SPEC ":-mgprel-ro}}} \
"
#ifndef SUBTARGET_DRIVER_SELF_SPECS
# define SUBTARGET_DRIVER_SELF_SPECS
%{mmuladd} %{mno-muladd} \
%{mpack} %{mno-pack} \
%{mno-fdpic:-mnopic} %{mfdpic} \
- %{fpic|fpie: -mpic} %{fPIC|fPIE: -mPIC} %{mlibrary-pic}}"
+ %{" FPIE1_OR_FPIC1_SPEC ":-mpic} %{" FPIE2_OR_FPIC2_SPEC ":-mPIC} %{mlibrary-pic}}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "crt0%O%s frvbegin%O%s"
#if defined HAVE_LD_PIE
#define GNU_USER_TARGET_STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
+ "%{!shared: %{pg|p|profile:gcrt1.o%s;: \
+ %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \
+ crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \
+ %{" PIE_SPEC ":crtbeginS.o%s} \
+ %{" NO_PIE_SPEC ":crtbegin.o%s}} \
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_start_preinit.o%s; \
fvtable-verify=std:vtv_start.o%s}"
/* Options to pass on to the assembler. */
#undef ASM_SPEC
-#define ASM_SPEC "%(asm_cpu) %(relax) %{fpic|fpie:-K PIC} %{fPIC|fPIE:-K PIC}"
+#define ASM_SPEC "%(asm_cpu) %(relax) %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
#define LINK_SPEC "%{v} %(link_cpu) %(relax)"
%{m68020-40:-m68040}%{m68020-60:-m68040}\
%{mcpu=*:-mcpu=%*}%{march=*:-march=%*}\
"
-#define ASM_PCREL_SPEC "%{fPIC|fpic|mpcrel:--pcrel} \
+#define ASM_PCREL_SPEC "%{" FPIC_SPEC ":--pcrel} \
+ %{mpcrel:%{" NO_FPIC_SPEC ":--pcrel}} \
%{msep-data|mid-shared-library:--pcrel} \
"
to pass PIC code generation options. */
#undef ASM_SPEC
-#define ASM_SPEC "%(asm_cpu_spec) %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
+#define ASM_SPEC \
+ "%(asm_cpu_spec) %{" FPIE1_OR_FPIC1_SPEC ":-k} %{" FPIE2_OR_FPIC2_SPEC ":-k -K}"
/* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */
#define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
#undef ASM_SPEC
-#define ASM_SPEC "%(asm_cpu_spec) %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
+#define ASM_SPEC \
+ "%(asm_cpu_spec) %{" FPIE1_OR_FPIC1_SPEC ":-k} %{" FPIE2_OR_FPIC2_SPEC ":-k -K}"
/* Layout of source language data types. */
/* -msep-data is the default PIC mode on this target. */
#define DRIVER_SELF_SPECS \
- "%{fpie|fPIE|fpic|fPIC:%{!msep-data:%{!mid-shared-library: -msep-data}}}"
+ "%{" FPIE_OR_FPIC_SPEC ":%{!msep-data:%{!mid-shared-library: -msep-data}}}"
/* The uclinux binary format relies on relocations against a segment being
within that segment. Conservatively apply this rule to individual
#ifdef HAVE_AS_NO_SHARED
/* Default to -mno-shared for non-PIC. */
# define NO_SHARED_SPECS \
- " %{mshared|mno-shared|fpic|fPIC|fpie|fPIE:;:-mno-shared}"
+ " %{mshared|mno-shared:;:%{" NO_FPIE_AND_FPIC_SPEC ":-mno-shared}}"
#else
# define NO_SHARED_SPECS ""
#endif
#define FUNCTION_PROFILER VXWORKS_FUNCTION_PROFILER
#undef SUBTARGET_ASM_SPEC
-#define SUBTARGET_ASM_SPEC "%{mrtp:%{fPIC|fpic:-mvxworks-pic}}"
+#define SUBTARGET_ASM_SPEC "%{mrtp:%{" FPIC_SPEC ":-mvxworks-pic}}"
#undef SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS VXWORKS_OVERRIDE_OPTIONS
still uses a special flavor of gas that needs to be told when generating
pic code. */
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
+#define ASM_SPEC "%{" FPIE1_OR_FPIC1_SPEC ":-k} %{" FPIE2_OR_FPIC2_SPEC ":-k -K}"
#endif
/* Since we use gas, stdin -> - is a good idea. */
#define LINK_OS_FREEBSD_SPEC "%{m32:%(link_os_freebsd_spec32)}%{!m32:%(link_os_freebsd_spec64)}"
#define ASM_SPEC32 "-a32 \
-%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
+%{mrelocatable} %{mrelocatable-lib} %{" FPIC_SPEC ":-K PIC} \
%{memb} %{!memb: %{msdata=eabi: -memb}} \
%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
%{mcall-freebsd: -mbig} \
#endif
#define ASM_SPEC32 "-a32 \
-%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
+%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%{memb|msdata=eabi: -memb}"
#define ASM_SPEC64 "-a64"
#undef ASM_SPEC
#define ASM_SPEC "%(asm_cpu) \
%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
-%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
+%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%{memb|msdata=eabi: -memb}" \
ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
#define ASM_SPEC \
"%(asm_cpu) \
%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
- %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} -mbig"
+ %{mrelocatable} %{mrelocatable-lib} %{" FPIC_SPEC ":-K PIC} -mbig"
#undef LIB_SPEC
#define LIB_SPEC VXWORKS_LIB_SPEC
#define ASM_SPEC_BASE \
"%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
-#define ASM_PIC_SPEC " %{fpic|fpie|fPIC|fPIE:-K PIC}"
+#define ASM_PIC_SPEC " %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
#undef ASM_CPU_DEFAULT_SPEC
#define ASM_CPU_DEFAULT_SPEC \
while (0)
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)"
+#define ASM_SPEC "%{" FPIE_OR_FPIC_SPEC ":-K PIC} %(asm_cpu)"
#define LINK_SPEC "%(link_arch) \
%{!mno-relax:%{!r:-relax}} \
#undef ASM_SPEC
#define ASM_SPEC "\
-s \
-%{fpic|fPIC|fpie|fPIE:-K PIC} \
+%{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%{!.c:%{findirect-dispatch:-K PIC}} \
%(asm_cpu) %(asm_relax)"
#undef ASM_SPEC
#define ASM_SPEC "\
-s \
-%{fpic|fPIC|fpie|fPIE:-K PIC} \
+%{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%{!.c:%{findirect-dispatch:-K PIC}} \
%(asm_cpu) %(asm_arch) %(asm_relax)"
#define USER_LABEL_PREFIX ""
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} \
+#define ASM_SPEC "%{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%(asm_cpu) %(asm_arch) %(asm_relax)"
#undef STDC_0_IN_SYSTEM_HEADERS
#undef ASM_SPEC
#define ASM_SPEC "\
--s %{fpic|fPIC|fpie|fPIE:-K PIC} \
+-s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%(asm_cpu) %(asm_arch) \
"
#undef ASM_SPEC
#define ASM_SPEC \
"-s \
- %{fpic|fpie|fPIC|fPIE:-K PIC} %(asm_cpu)"
+ %{" FPIE_OR_FPIC_SPEC ":-K PIC} %(asm_cpu)"
/* Use the default. */
#undef LINK_SPEC
#undef ASM_SPEC
#define ASM_SPEC "\
--s %{fpic|fPIC|fpie|fPIE:-K PIC} \
+-s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
%(asm_cpu) %(asm_arch) \
"
/* Special flags to the Sun-4 assembler when using pipe for input. */
#define ASM_SPEC "\
-%{!pg:%{!p:%{fpic|fPIC|fpie|fPIE:-k}}} %{keep-local-as-symbols:-L} \
+%{!pg:%{!p:%{" FPIE_OR_FPIC_SPEC ":-k}}} %{keep-local-as-symbols:-L} \
%(asm_cpu) %(asm_relax)"
/* This macro defines names of additional specifications to put in the specs
#undef ASM_SPEC
#define ASM_SPEC \
"%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} \
- %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)"
+ %{" FPIE_OR_FPIC_SPEC ":-K PIC} %(asm_cpu)"
/* Define the names of various pseudo-op used by the SPARC/svr4 assembler.
Note that many of these are different from the typical pseudo-ops used
#define CPP_SUBTARGET_SPEC VXWORKS_ADDITIONAL_CPP_SPEC
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)"
+#define ASM_SPEC "%{" FPIE_OR_FPIC_SPEC ":-K PIC} %(asm_cpu)"
#undef LIB_SPEC
#define LIB_SPEC VXWORKS_LIB_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
#undef ASM_SPEC
-#define ASM_SPEC "%{fpic|fPIC:-k}"
+#define ASM_SPEC "%{" FPIC_SPEC ":-k}"
#undef LINK_SPEC
#define LINK_SPEC \
ac_subst_vars='LTLIBOBJS
LIBOBJS
+NO_PIE_FLAG
+NO_PIE_CFLAGS
+enable_default_pie
PICFLAG
enable_host_shared
enable_plugin
enable_libquadmath_support
with_linker_hash_style
with_diagnostics_color
+enable_default_pie
'
ac_precious_vars='build_alias
host_alias
--enable-host-shared build host code as shared libraries
--disable-libquadmath-support
disable libquadmath support for Fortran
+ --enable-default-pie enable Position Independent Executable as default
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 18296 "configure"
+#line 18301 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 18402 "configure"
+#line 18407 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
#define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_BASEVER}${exeext}"
EOF
+# Check whether --enable-default-pie was given.
+# Check whether --enable-default-pie was given.
+if test "${enable_default_pie+set}" = set; then :
+ enableval=$enable_default_pie; enable_default_pie=$enableval
+else
+ enable_default_pie=no
+fi
+
+if test x$enable_default_pie == xyes ; then
+
+$as_echo "#define ENABLE_DEFAULT_PIE 1" >>confdefs.h
+
+fi
+
+
+# Check if -fno-PIE works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-PIE option" >&5
+$as_echo_n "checking for -fno-PIE option... " >&6; }
+if test "${gcc_cv_c_no_fpie+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fno-PIE"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gcc_cv_c_no_fpie=yes
+else
+ gcc_cv_c_no_fpie=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$saved_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
+$as_echo "$gcc_cv_c_no_fpie" >&6; }
+if test "$gcc_cv_c_no_fpie" = "yes"; then
+ NO_PIE_CFLAGS="-fno-PIE"
+fi
+
+
+# Check if -no-pie works.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
+$as_echo_n "checking for -no-pie option... " >&6; }
+if test "${gcc_cv_no_pie+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -no-pie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) {return 0;}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ gcc_cv_no_pie=yes
+else
+ gcc_cv_no_pie=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$saved_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
+$as_echo "$gcc_cv_no_pie" >&6; }
+if test "$gcc_cv_no_pie" = "yes"; then
+ NO_PIE_FLAG="-no-pie"
+fi
+
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
#define GCC_DRIVER_NAME "${target_noncanonical}-gcc-${gcc_BASEVER}${exeext}"
EOF
+# Check whether --enable-default-pie was given.
+AC_ARG_ENABLE(default-pie,
+[AS_HELP_STRING([--enable-default-pie],
+ [enable Position Independent Executable as default])],
+enable_default_pie=$enableval,
+enable_default_pie=no)
+if test x$enable_default_pie == xyes ; then
+ AC_DEFINE(ENABLE_DEFAULT_PIE, 1,
+ [Define if your target supports default PIE and it is enabled.])
+fi
+AC_SUBST([enable_default_pie])
+
+# Check if -fno-PIE works.
+AC_CACHE_CHECK([for -fno-PIE option],
+ [gcc_cv_c_no_fpie],
+ [saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fno-PIE"
+ AC_COMPILE_IFELSE([int main(void) {return 0;}],
+ [gcc_cv_c_no_fpie=yes],
+ [gcc_cv_c_no_fpie=no])
+ CFLAGS="$saved_CFLAGS"])
+if test "$gcc_cv_c_no_fpie" = "yes"; then
+ NO_PIE_CFLAGS="-fno-PIE"
+fi
+AC_SUBST([NO_PIE_CFLAGS])
+
+# Check if -no-pie works.
+AC_CACHE_CHECK([for -no-pie option],
+ [gcc_cv_no_pie],
+ [saved_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -no-pie"
+ AC_LINK_IFELSE([int main(void) {return 0;}],
+ [gcc_cv_no_pie=yes],
+ [gcc_cv_no_pie=no])
+ LDFLAGS="$saved_LDFLAGS"])
+if test "$gcc_cv_no_pie" = "yes"; then
+ NO_PIE_FLAG="-no-pie"
+fi
+AC_SUBST([NO_PIE_FLAG])
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
#endif
#endif
+/* Default value for flag_pie when flag_pie is initialized to -1:
+ --enable-default-pie: Default flag_pie to -fPIE.
+ --disable-default-pie: Default flag_pie to 0.
+ */
+#ifdef ENABLE_DEFAULT_PIE
+# ifndef DEFAULT_FLAG_PIE
+# define DEFAULT_FLAG_PIE 2
+# endif
+#else
+# define DEFAULT_FLAG_PIE 0
+#endif
+
#ifdef GCC_INSN_FLAGS_H
/* Dependent default target macro definitions
Currently, this option only affects sparc-linux, powerpc-linux, x86-linux,
mips-linux and s390-linux.
+@item --enable-default-pie
+Turn on @option{-fPIE} and @option{-pie} by default.
+
@item --enable-secureplt
This option enables @option{-msecure-plt} by default for powerpc-linux.
@ifnothtml
used for compilation (@option{-fpie}, @option{-fPIE},
or model suboptions) when you specify this linker option.
+@item -no-pie
+@opindex no-pie
+Don't produce a position independent executable.
+
@item -rdynamic
@opindex rdynamic
Pass the flag @option{-export-dynamic} to the ELF linker, on targets
#endif
#endif
+#ifdef ENABLE_DEFAULT_PIE
+#define NO_PIE_SPEC "no-pie|static"
+#define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
+#define NO_FPIE1_SPEC "fno-pie"
+#define FPIE1_SPEC NO_FPIE1_SPEC ":;"
+#define NO_FPIE2_SPEC "fno-PIE"
+#define FPIE2_SPEC NO_FPIE2_SPEC ":;"
+#define NO_FPIE_SPEC NO_FPIE1_SPEC "|" NO_FPIE2_SPEC
+#define FPIE_SPEC NO_FPIE_SPEC ":;"
+#define NO_FPIC1_SPEC "fno-pic"
+#define FPIC1_SPEC NO_FPIC1_SPEC ":;"
+#define NO_FPIC2_SPEC "fno-PIC"
+#define FPIC2_SPEC NO_FPIC2_SPEC ":;"
+#define NO_FPIC_SPEC NO_FPIC1_SPEC "|" NO_FPIC2_SPEC
+#define FPIC_SPEC NO_FPIC_SPEC ":;"
+#define NO_FPIE1_AND_FPIC1_SPEC NO_FPIE1_SPEC "|" NO_FPIC1_SPEC
+#define FPIE1_OR_FPIC1_SPEC NO_FPIE1_AND_FPIC1_SPEC ":;"
+#define NO_FPIE2_AND_FPIC2_SPEC NO_FPIE2_SPEC "|" NO_FPIC2_SPEC
+#define FPIE2_OR_FPIC2_SPEC NO_FPIE2_AND_FPIC2_SPEC ":;"
+#define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
+#define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
+#else
+#define PIE_SPEC "pie"
+#define NO_PIE_SPEC PIE_SPEC "|r|shared:;"
+#define FPIE1_SPEC "fpie"
+#define NO_FPIE1_SPEC FPIE1_SPEC ":;"
+#define FPIE2_SPEC "fPIE"
+#define NO_FPIE2_SPEC FPIE2_SPEC ":;"
+#define FPIE_SPEC FPIE1_SPEC "|" FPIE2_SPEC
+#define NO_FPIE_SPEC FPIE_SPEC ":;"
+#define FPIC1_SPEC "fpic"
+#define NO_FPIC1_SPEC FPIC1_SPEC ":;"
+#define FPIC2_SPEC "fPIC"
+#define NO_FPIC2_SPEC FPIC2_SPEC ":;"
+#define FPIC_SPEC FPIC1_SPEC "|" FPIC2_SPEC
+#define NO_FPIC_SPEC FPIC_SPEC ":;"
+#define FPIE1_OR_FPIC1_SPEC FPIE1_SPEC "|" FPIC1_SPEC
+#define NO_FPIE1_AND_FPIC1_SPEC FPIE1_OR_FPIC1_SPEC ":;"
+#define FPIE2_OR_FPIC2_SPEC FPIE2_SPEC "|" FPIC2_SPEC
+#define NO_FPIE2_AND_FPIC2_SPEC FPIE1_OR_FPIC2_SPEC ":;"
+#define FPIE_OR_FPIC_SPEC FPIE_SPEC "|" FPIC_SPEC
+#define NO_FPIE_AND_FPIC_SPEC FPIE_OR_FPIC_SPEC ":;"
+#endif
+
#ifndef LINK_PIE_SPEC
#ifdef HAVE_LD_PIE
-#define LINK_PIE_SPEC "%{pie:-pie} "
+#define LD_PIE_SPEC "-pie"
#else
-#define LINK_PIE_SPEC "%{pie:} "
+#define LD_PIE_SPEC ""
#endif
+#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} "
#endif
#ifndef LINK_BUILDID_SPEC
if (!opts->x_flag_opts_finished)
{
+ /* We initialize opts->x_flag_pie to -1 so that targets can set a
+ default value. */
+ if (opts->x_flag_pie == -1)
+ {
+ if (opts->x_flag_pic == 0)
+ opts->x_flag_pie = DEFAULT_FLAG_PIE;
+ else
+ opts->x_flag_pie = 0;
+ }
if (opts->x_flag_pie)
opts->x_flag_pic = opts->x_flag_pie;
if (opts->x_flag_pic && !opts->x_flag_pie)
+2015-05-27 H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile.in (CRTSTUFF_CFLAGS): Add $(NO_PIE_CFLAGS).
+
2015-05-27 John Marino <gnugcc@marino.st>
* config.host (i[34567]86-*-freebsd*, x86_64-*-freebsd*): Set
# Options to use when compiling crtbegin/end.
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
- -finhibit-size-directive -fno-inline -fno-exceptions \
+ $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
-fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
$(INHIBIT_LIBC_CFLAGS)