Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alistair23/pmaports
  • exkc/pmaports
  • fossdd/pmaports
  • JustSoup321/pmaports
  • Eisenbahnfan/pmaports
  • raihan2000/pmaports
  • sleirsgoevy/pmaports
  • Adrian/pmaports
  • adamthiede/pmaports
  • jianhua/pmaports
  • knuxify/pmaports
  • Arnavion/pmaports
  • barni2000/pmaports
  • longnoserob/pmaports
  • smankusors/pmaports
  • Aren/pmaports
  • langfingaz/pmaports
  • sicelo/pmaports
  • kouta-kun/pmaports
  • craftyguy/pmaports
  • rdacayan/pmaports
  • rmader/pmaports
  • Haui111/pmaports
  • jakko/pmaports
  • dujem/pmaports
  • methanal/pmaports
  • WeirdTreeThing/pmaports
  • MightyM17/pmaports
  • sertonix/pmaports
  • amessier/pmaports
  • akemnade/pmaports
  • setotau/pmaports
  • kevinwidjaja21/pmaports
  • NekoCWD/pmaports
  • ollieparanoid/pmaports
  • manoedinata/pmaports
  • Drakulix/pmaports
  • grimler/pmaports
  • benpicco/pmaports
  • Frieder.Hannenheim/pmaports
  • andrisas/pmaports
  • EspiDev/pmaports
  • maze42/pmaports
  • anjandev/pmaports
  • danct12/pmaports
  • ijiki16/pmaports
  • jja2000/pmaports
  • fancsali/pmaports
  • bolilingmeng89006/pmaports
  • Minecrell/pmaports
  • chipiguay/pmaports
  • cherrypicker/pmaports
  • fortuna-mainline/pmaports
  • pevik/pmaports
  • Patriot-06/pmaports
  • JoseskVolpe/pmaports
  • verdre/pmaports
  • proycon/pmaports
  • AutumnSpark1226/pmaports
  • PsychoGame/pmaports
  • fraolt/pmaports
  • VaporGame/pmaports
  • pugzarecute/pmaports
  • CalcProgrammer1/pmaports
  • hexaheximal/pmaports
  • dabao1955/pmaports
  • HenriDellal/pmaports
  • semfault/pmaports
  • strobo5/pmaports
  • andrewgigena/pmaports
  • Athozus/pmaports
  • 1peter10/pmaports
  • vixalien/pmaports
  • Tooniis/pmaports
  • adomerle/pmaports
  • bjorn3/pmaports
  • StacyHarper/pmaports
  • Jack_Kekzoz/pmaports
  • Ceddicedced/pmaports
  • Justin_Zobel/pmaports
  • airtower-luna/pmaports
  • f-izzo/pmaports
  • cosmo/pmaports
  • 9lore/pmaports
  • postmarketOS/pmaports
  • Johnnynator/pmaports
  • iAboothahir/pmaports
  • N1kroks/pmaports
  • neuschaefer/pmaports
  • DylanVanAssche/pmaports
  • yehiashamaa987/pmaports
  • Operachi/pmaports
  • faveoled/pmaports
  • ilpianista/pmaports
  • johkra/pmaports
  • HDDTHR/pmaports
  • zsoltiv/pmaports
  • Justin/pmaports
  • Kaloyan501/pmaports_huawei_p8_lite_2015_fix
  • joelselvaraj/pmaports
  • rontti/pmaports
  • dsankouski/pmaports
  • StandaSK/pmaports
  • paricbat/pmaports
  • asdfugil/pmaports
  • komaru-yml/pmaports
  • MasterPlexus/pmaports
  • Felix/pmaports
  • ayakael/pmaports
  • feisuzhu/pmaports
  • AJ-RR/pmaports
  • SzczurekYT/pmaports
  • mediaberry/pmaports
  • justsomeguy/pmaports
  • Augis154/pmaports
  • hrdl/pmaports
  • sib0ndt/pmaports
  • 19atlas/pmaports
  • vipaoL/pmaports
  • wannjanjic/pmaports
  • dh/pmaports
  • LogicalErzor/pmaports
  • halamix2/pmaports
  • Shamilkv34/pmaports
  • Cogitri/pmaports
  • fallenritemonk/pmaports
  • user0-07161/pmaports
  • rock3tsprocket/pmaports
  • ellyq/pmaports
  • rodent/pmaports
  • mkorpershoek/pmaports
  • candrew/pmaports
  • fallaciousreasoning/pmaports
  • chalkin/pmaports
  • ungeskriptet/pmaports
  • r00t/pmaports
  • panpanpanpan/pmaports
  • celiffe/pmaports
  • davidfurey/pmaports
  • kidd/pmaports
  • tpikonen/pmaports
  • camelCaseNick/pmaports
  • ermine/pmaports
  • lgh/pmaports
  • sajattack/pmaports
  • StephanieBread/pmaports
  • M0Rf30/pmaports
  • notfound405/pmaports
  • samueldr/pmaports
  • r10nw7fd3/pmaports
  • treid998/pmaports-merge
  • denysvitali/pmaports
  • rodriguezst/pmaports
  • puppiestdoggo1/pmaports
  • donihalim/pmaports
  • EDKPiepaint/pmaports-apple-tonga-test
  • SanyaPilot/pmaports
157 results
Show changes
Commits on Source (10)
Showing
with 1520 additions and 0 deletions
2013-12-30 Magnus Granberg <zorry@gentoo.org>
* gcc/configure.ac Add --enable-esp and define ENABLE_ESP.
Check if we support crtbeginP and define ENABLE_CRTBEGINP.
* gcc/configure Regenerated
--- a/gcc/configure.ac 2011-11-18 11:52:32.000000000 +0100
+++ b/gcc/configure.ac 2012-10-02 17:39:15.649526241 +0200
@@ -5130,6 +5237,55 @@ if test x"${LINKER_HASH_STYLE}" != x; th
[The linker hash style])
fi
+# --------------
+# Esp checks
+# --------------
+
+# Check whether --enable-esp was given and target have the support.
+AC_ARG_ENABLE([esp],
+[AS_HELP_STRING([--enable-esp],
+ [Enable Stack protector and Position independent executable as
+ default if we have suppot for it when compiling
+ and link with -z now as default.
+ Linux targets supported i*86, x86_64, x32,
+ powerpc, powerpc64, ia64, arm and mips.])],
+ enable_esp=$enableval,
+ enable_esp=no)
+if test $enable_esp = yes ; then
+ AC_MSG_CHECKING(if $target support esp)
+ case "$target" in
+ i?86*-*-linux* | x86_64-*-linux* | powerpc*-*-linux* | mips-*-linux* | arm*-*-linux* | ia64-*-linux*)
+ enable_esp=yes
+ AC_DEFINE(ENABLE_ESP, 1,
+ [Define if your target support esp and you have enable it.])
+ ;;
+ *)
+ enable_esp=no
+ ;;
+ esac
+AC_MSG_RESULT($enable_esp)
+fi
+AC_SUBST([enable_esp])
+if test $enable_esp = yes ; then
+ AC_MSG_CHECKING(checking for crtbeginP.o support)
+ if test x$enable_esp = xyes ; then
+ case "$target" in
+ ia64*-*-linux*)
+ enable_crtbeginP=no ;;
+ *-*-linux*)
+ if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
+ enable_crtbeginP=yes
+ AC_DEFINE(ENABLE_CRTBEGINP, 1,
+ [Define if your compiler will support crtbeginP.])
+ fi
+ ;;
+ *) enable_crtbeginP=no ;;
+ esac
+ fi
+ AC_MSG_RESULT($enable_crtbeginP)
+fi
+AC_SUBST([enable_crtbeginP])
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
--- a/gcc/configure 2013-02-01 21:26:24.000000000 +0100
+++ b/gcc/configure 2013-02-12 01:59:20.000000000 +0100
@@ -600,6 +600,8 @@
ac_subst_vars='LTLIBOBJS
LIBOBJS
PICFLAG
+enable_crtbeginP
+enable_esp
enable_host_shared
enable_plugin
pluginlibs
@@ -920,6 +922,7 @@
enable_plugin
enable_libquadmath_support
with_linker_hash_style
+enable_esp
'
ac_precious_vars='build_alias
host_alias
@@ -1633,6 +1636,11 @@
--enable-plugin enable plugin support
--disable-libquadmath-support
disable libquadmath support for Fortran
+ --enable-esp Enable Stack protector and Position independent
+ executable as default if we have suppot for it when
+ compiling and link with -z now as default.
+ Linux targets supported i*86, x86_64, x32,
+ powerpc, powerpc64, ia64, arm and mips.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -27419,6 +27427,59 @@
fi
+# --------------
+# Esp checks
+# --------------
+
+# Check whether --enable-esp was given and target have the support.
+# Check whether --enable-esp was given.
+if test "${enable_esp+set}" = set; then :
+ enableval=$enable_esp; enable_esp=$enableval
+else
+ enable_esp=no
+fi
+
+if test $enable_esp = yes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $target support esp" >&5
+$as_echo_n "checking if $target support esp... " >&6; }
+ case "$target" in
+ i?86*-*-linux* | x86_64-*-linux* | powerpc*-*-linux* | mips*-*-linux* | arm*-*-linux* | ia64-*-linux*)
+ enable_esp=yes
+
+$as_echo "#define ENABLE_ESP 1" >>confdefs.h
+
+ ;;
+ *)
+ enable_esp=no
+ ;;
+ esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_esp" >&5
+$as_echo "$enable_esp" >&6; }
+fi
+
+if test $enable_esp = yes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking checking for crtbeginP.o support" >&5
+$as_echo_n "checking checking for crtbeginP.o support... " >&6; }
+ if test x$enable_esp = xyes ; then
+ case "$target" in
+ ia64*-*-linux*)
+ enable_crtbeginP=no ;;
+ *-*-linux*)
+ if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
+ enable_crtbeginP=yes
+
+$as_echo "#define ENABLE_CRTBEGINP 1" >>confdefs.h
+
+ fi
+ ;;
+ *) enable_crtbeginP=no ;;
+ esac
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_crtbeginP" >&5
+$as_echo "$enable_crtbeginP" >&6; }
+fi
+
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
2013-02-13 Magnus Granberg <zorry@gentoo.org>
* gcc/config.in Add ENABLE_CRTBEGINP, ENABLE_ESP
--- ./gcc/config.in 2009-04-21 11:08:08.000000000 +0200
+++ ./gcc/config.in 2009-05-12 00:10:08.000000000 +0200
@@ -46,6 +46,12 @@
#endif
+/* Define to 1 to enable crtbeginP.o. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_CRTBEGINP
+#endif
+
+
/* Define to 1 to specify that we are using the BID decimal floating point
format instead of DPD */
#ifndef USED_FOR_TARGET
@@ -65,6 +65,12 @@
#endif
+/* Define to 1 to enable esp. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_ESP
+#endif
+
+
/* Define to 1 to enable fixed-point arithmetic extension to C. */
#ifndef USED_FOR_TARGET
#undef ENABLE_FIXED_POINT
2012-01-17 Magnus Granberg <zorry@gentoo.org>
* gcc/Makefile.in Add -fno-PIE. to ALL_CFLAGS and
ALL_CXXFLAGS if enable_esp yes.
Echo enable_esp and enable_crtbeginP to tmp-libgcc.mvars.
* libgcc/Makefile.in Add crtbeginP.o to EXTRA_PARTS if enable_crtbeginP yes
We add new file crtbeginP.o if enable_crtbeginP yes
Add -fno-PIE. to CRTSTUFF_CFLAGS.
--- a/gcc/Makefile.in 2011-11-09 02:20:14.000000000 +0100
+++ b/gcc/Makefile.in 2011-12-24 22:28:08.864804375 +0100
@@ -247,6 +247,14 @@ LINKER_FLAGS = $(CFLAGS)
endif
endif
+# We don't want to compile the compiler with -fPIE, it make PCH fail.
+enable_esp = @enable_esp@
+ifeq ($(enable_esp),yes)
+ESP_NOPIE_CFLAGS = -fno-PIE
+else
+ESP_NOPIE_CFLAGS=
+endif
+
# -------------------------------------------
# Programs which operate on the build machine
# -------------------------------------------
@@ -974,12 +982,13 @@ INTERNAL_CFLAGS = -DIN_GCC @CROSS@
# This is the variable actually used when we compile. If you change this,
# you probably want to update BUILD_CFLAGS in configure.ac
-ALL_CFLAGS = $(T_CFLAGS) $(CFLAGS-$@) \
+ALL_CFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) \
$(CFLAGS) $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) @DEFS@
# The C++ version.
-ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
- $(COVERAGE_FLAGS) $(NOEXCEPTION_FLAGS) $(WARN_CXXFLAGS) @DEFS@
+ALL_CXXFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) \
+ $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(NOEXCEPTION_FLAGS) \
+ $(WARN_CXXFLAGS) @DEFS@
# Likewise. Put INCLUDES at the beginning: this way, if some autoconf macro
# puts -I options in CPPFLAGS, our include files in the srcdir will always
@@ -1814,6 +1823,8 @@ libgcc.mvars: config.status Makefile spe
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
+ echo enable_esp = '$(enable_esp)' >> tmp-libgcc.mvars
+ echo enable_crtbeginP = '@enable_crtbeginP@' >> tmp-libgcc.mvars
mv tmp-libgcc.mvars libgcc.mvars
--- a/libgcc/Makefile.in 2011-11-22 04:01:02.000000000 +0100
+++ b/libgcc/Makefile.in 2011-12-25 15:18:22.449610631 +0100
@@ -219,6 +219,17 @@ else
DECNUMINC =
endif
+ifeq ($(enable_esp),yes)
+ESP_NOPIE_CFLAGS = -fno-PIE
+else
+ESP_NOPIE_CFLAGS=
+endif
+
+# We add crtbeginP.o to the EXTRA_PARTS list if enable_crtbeginP = yes
+ifeq ($(enable_crtbeginP),yes)
+EXTRA_PARTS += crtbeginP.o
+endif
+
# Options to use when compiling libgcc2.a.
#
LIBGCC2_DEBUG_CFLAGS = -g
@@ -279,7 +290,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CF
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-finhibit-size-directive -fno-inline -fno-exceptions \
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
- -fno-stack-protector \
+ -fno-stack-protector $(ESP_NOPIE_CFLAGS) \
$(INHIBIT_LIBC_CFLAGS)
# Extra flags to use when compiling crt{begin,end}.o.
@@ -966,6 +977,13 @@ crtendS$(objext): $(srcdir)/crtstuff.c
# This is a version of crtbegin for -static links.
crtbeginT$(objext): $(srcdir)/crtstuff.c
$(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN -DCRTSTUFFT_O
+
+# This is a version of crtbegin for -static -fPIE links.
+ifeq ($(enable_crtbeginP),yes)
+crtbeginP$(objext): $(srcdir)/crtstuff.c
+ $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
+ -c $< -DCRT_BEGIN -DCRTSTUFFT_O -DCRTSTUFFS_O
+endif
ifeq ($(enable_vtable_verify),yes)
# These are used in vtable verification; see comments in source files for
\ No newline at end of file
2013-03-24 Magnus Granberg <zorry@gentoo.org>
* gcc/gcc.c include esp.h
static const char *cc1_spec We set that in esp.h if ENABLE_ESP.
--- ./gcc/gcc.c 2010-01-21 10:29:30.000000000 -0500
+++ ./gcc/gcc.c 2010-01-29 23:29:16.000000000 -0500
@@ -44,6 +44,7 @@
#include "opts.h"
#include "params.h"
#include "vec.h"
+#include "config/esp.h" /* for --enable-esp support */
#include "filenames.h"
/* By default there is no special suffix for target executables. */
@@ -822,7 +823,9 @@
static const char *asm_debug;
static const char *cpp_spec = CPP_SPEC;
+#ifndef ENABLE_ESP
static const char *cc1_spec = CC1_SPEC;
+#endif
static const char *cc1plus_spec = CC1PLUS_SPEC;
static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
static const char *link_ssp_spec = LINK_SSP_SPEC;
Enable -D_FORTIFY_SOURCE=2 by default.
Original patch from:
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/gcc/4.9.2/gentoo/10_all_default-fortify-source.patch
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -951,6 +951,9 @@ c_cpp_builtins (cpp_reader *pfile)
builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
+ /* Fortify Source enabled by default w/optimization. */
+ cpp_define (pfile, "_FORTIFY_SOURCE=((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 : 0)");
+
/* Misc. */
if (flag_gnu89_inline)
cpp_define (pfile, "__GNUC_GNU_INLINE__");
--- a/gcc/doc/gcc.info
+++ b/gcc/doc/gcc.info
@@ -6255,6 +6255,11 @@ find out the exact set of optimizations that are enabled at each level.
Please note the warning under '-fgcse' about invoking '-O2' on
programs that use computed gotos.
+ NOTE: In Alpine Linux, `-D_FORTIFY_SOURCE=2' is set by default, and is
+ activated when `-Os' or `-O1' or higher is used. This enables additional
+ compile-time and run-time checks for several libc functions. To disable,
+ specify either `-U_FORTIFY_SOURCE' or `-D_FORTIFY_SOURCE=0'.
+
'-O3'
Optimize yet more. '-O3' turns on all optimizations specified by
'-O2' and also turns on the '-finline-functions',
Enable -Wtrampolines by default.
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -640,7 +640,7 @@ Common Var(warn_system_headers) Warning
Do not suppress warnings from system headers
Wtrampolines
-Common Var(warn_trampolines) Warning
+Common Var(warn_trampolines) Init(1) Warning
Warn whenever a trampoline is generated
Wtype-limits
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4007,6 +4007,8 @@ headers---for that, @option{-Wunknown-pragmas} must also be used.
for most targets, it is made up of code and thus requires the stack
to be made executable in order for the program to work properly.
+ This warning is enabled by default in Gentoo.
+
@item -Wfloat-equal
@opindex Wfloat-equal
@opindex Wno-float-equal
libgfortran does not respect --disable-werror
https://bugs.gentoo.org/433435
http://gcc.gnu.org/PR54724
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -5764,7 +5764,7 @@ fi
# Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
if test "x$GCC" = "xyes"; then
- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
+ AM_FCFLAGS="-I . -Wall -fimplicit-none -fno-repack-arrays -fno-underscoring"
## We like to use C99 routines when available. This makes sure that
## __STDC_VERSION__ is set such that libc includes make them available.
AM_CFLAGS="-std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings"
2012-01-24 Magnus Granberg <zorry@gentoo.org>
* gcc/common.opt Add -nopie
--- a/gcc/common.opt 2011-11-23 19:51:17.000000000 +0100
+++ b//gcc/common.opt 2012-01-24 16:56:24.302224357 +0100
@@ -2280,6 +2280,9 @@ Driver
nodefaultlibs
Driver
+nopie
+Driver
+
nostartfiles
Driver
libgomp does not respect --disable-werror
https://bugs.gentoo.org/229059
http://gcc.gnu.org/PR38436
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -4282,7 +4282,7 @@ save_CFLAGS="$CFLAGS"
# Add -Wall -Werror if we are using GCC.
if test "x$GCC" = "xyes"; then
- XCFLAGS="$XCFLAGS -Wall -Werror"
+ XCFLAGS="$XCFLAGS -Wall"
fi
# Find other programs we need.
2014-04-23 Magnus Granberg <zorry@gentoo.org>
* gcc/config/gnu-user.h If ENABLE_CRTBEGINP, -static and -pie use crtbegineP.o.
* gcc/config/rs6000/sysv4.h If ENABLE_CRTBEGINP, -static and -pie use crtbegineP.o.
--- a/gcc/config/gnu-user.h 2014-01-02 23:23:26.000000000 +0100
+++ b/gcc/config/gnu-user.h 2014-04-23 00:55:06.390265454 +0200
@@ -40,7 +40,15 @@ see the files COPYING3 and COPYING.RUNTI
provides part of the support for getting C++ file-scope static
object constructed before entering `main'. */
-#if defined HAVE_LD_PIE
+#if defined (HAVE_LD_PIE) && defined (ENABLE_CRTBEGINP)
+#define GNU_USER_TARGET_STARTFILE_SPEC \
+ "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+ crti.o%s %{static:%{pie:crtbeginP.o%s;:crtbeginT.o%s}; \
+ shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
+ %{fvtable-verify=none:%s; \
+ fvtable-verify=preinit:vtv_start_preinit.o%s; \
+ fvtable-verify=std:vtv_start.o%s}"
+#elif defined (HAVE_LD_PIE) && ! defined (ENABLE_CRTBEGINP)
#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} \
--- a/gcc/config/rs6000/sysv4.h 2009-04-10 01:23:07.000000000 +0200
+++ b/gcc/config/rs6000/sysv4.h 2009-09-08 04:41:50.000000000 +0200
@@ -883,7 +883,12 @@
%{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
%{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
-#ifdef HAVE_LD_PIE
+#if defined (HAVE_LD_PIE) && defined (ENABLE_CRTBEGINP)
+#define STARTFILE_LINUX_SPEC "\
+%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+%{mnewlib:ecrti.o%s;:crti.o%s} \
+%{static:%{pie:crtbeginP.o%s;:crtbeginT.o%s}} %{!static:%{shared|pie:crtbeginS.o%s;:crtbegin.o%s}}"
+#elif defined (HAVE_LD_PIE) && ! defined (ENABLE_CRTBEGINP)
#define STARTFILE_LINUX_SPEC "\
%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
%{mnewlib:ecrti.o%s;:crti.o%s} \
2014-04-24 Magnus Granberg <zorry@gentoo.org>
* gcc/doc/invoke.texi Add NOTES about -fstack-protector-all, -pie and
-fPIE/-fpie when --enable-esp is enable, this options is on by default.
--- a/gcc/doc/invoke.texi 2009-04-01 09:18:47.000000000 +0200
+++ b/gcc/doc/invoke.texi 2009-06-18 14:08:38.000000000 +0200
@@ -9233,6 +9245,11 @@ If a guard check fails, an error message
@opindex fstack-protector-all
Like @option{-fstack-protector} except that all functions are protected.
+NOTE: NOTE: When --enable-esp this option is enabled by default
+for C, C++, ObjC, ObjC++, if neither @option{-fno-stack-protector},
+@option{-nostdlib}, @option{-ffreestanding}, @option{-fstack-protector},
+@option{-fstack-protector-strong}or @option{-fstack-protector-all}are found.
+
@item -fstack-protector-strong
@opindex fstack-protector-strong
Like @option{-fstack-protector} but includes additional functions to
@@ -7960,6 +7965,12 @@
that were used to generate code (@option{-fpie}, @option{-fPIE},
or model suboptions) when you specify this option.
+NOTE: When --enable-esp this option is enabled by default
+for C, C++, ObjC, ObjC++, if neither @option{-fno-pie} or @option{-fno-PIE}
+or @option{-fno-pic} or @option{-fno-PIC} or @option{-nostdlib} or
+@option{-nostartfiles} or @option{-shared} or @option{-pg} or @option{-p}
+are found.
+
@item -rdynamic
@opindex rdynamic
Pass the flag @option{-export-dynamic} to the ELF linker, on targets
@@ -15889,6 +15910,11 @@
@code{__pie__} and @code{__PIE__}. The macros have the value 1
for @option{-fpie} and 2 for @option{-fPIE}.
+NOTE: When --enable-esp this option is enabled by default
+for C, C++, ObjC, ObjC++, if neither @option{-fno-pie} or @option{-fno-PIE}
+or @option{-fno-pic} or @option{-fno-PIC} or @option{-nostdlib} or
+@option{-nostartfiles} or @option{-shared} are found.
+
@item -fno-jump-tables
@opindex fno-jump-tables
Do not use jump tables for switch statements even where it would be
2013-03-24 Magnus Granberg <zorry@gentoo.org>
* gcc/config/i386/gnu-user-common.h (DRIVER_SELF_SPECS): Add ESP_DRIVER_SELF_SPEC.
* gcc/config/i386/gnu-user.h (SUBTARGET_EXTRA_SPECS): Add ESP_EXTRA_SPECS.
* gcc/config/i386/i386.h (SUBTARGET_EXTRA_SPECS): Add ESP_EXTRA_SPECS.
--- a/gcc/config/i386/gnu-user-common.h 2013-01-10 21:38:27.000000000 +0100
+++ b/gcc/config/i386/gnu-user-common.h 2013-02-14 00:51:44.689637605 +0100
@@ -70,3 +70,7 @@ along with GCC; see the file COPYING3.
/* Static stack checking is supported by means of probes. */
#define STACK_CHECK_STATIC_BUILTIN 1
+
+#ifdef ENABLE_ESP
+#define DRIVER_SELF_SPECS ESP_DRIVER_SELF_SPEC
+#endif
--- a/gcc/config/i386/gnu-user.h 2011-05-05 14:32:50.000000000 +0200
+++ b/gcc/config/i386/gnu-user.h 2012-07-09 14:28:38.726289455 +0200
@@ -93,9 +93,16 @@ along with GCC; see the file COPYING3.
"--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
#undef SUBTARGET_EXTRA_SPECS
+#ifdef ENABLE_ESP
#define SUBTARGET_EXTRA_SPECS \
{ "link_emulation", GNU_USER_LINK_EMULATION },\
- { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+ { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }, \
+ ESP_EXTRA_SPECS
+#else
+#define SUBTARGET_EXTRA_SPECS \
+ { "link_emulation", GNU_USER_LINK_EMULATION },\
+ { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+#endif
#undef LINK_SPEC
#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
--- a/gcc/config/i386/i386.h 2011-11-24 23:11:12.000000000 +0100
+++ b/gcc/config/i386/i386.h 2012-07-09 14:21:24.575276517 +0200
@@ -617,13 +617,16 @@ enum target_cpu_default
Do not define this macro if it does not need to do anything. */
#ifndef SUBTARGET_EXTRA_SPECS
+#ifdef ENABLE_ESP
+#define SUBTARGET_EXTRA_SPECS ESP_EXTRA_SPECS
+#else
#define SUBTARGET_EXTRA_SPECS
#endif
+#endif
#define EXTRA_SPECS \
{ "cc1_cpu", CC1_CPU_SPEC }, \
SUBTARGET_EXTRA_SPECS
-
/* Set the value of FLT_EVAL_METHOD in float.h. When using only the
FPU, assume that the fpcw is set to extended precision; when using
2013-06-03 Magnus Granberg <zorry@gentoo.org>
* gcc/config/arm/arm.h (DRIVER_SELF_SPECS): Add ESP_DRIVER_SELF_SPEC.
* gcc/config/arm/elf.h (SUBSUBTARGET_EXTRA_SPECS): Add ESP_EXTRA_SPECS.
--- a/gcc/config/arm/arm.h 2013-01-15 17:17:28.000000000 +0100
+++ b/gcc/config/arm/arm.h 2013-02-18 22:45:18.327284928 +0100
@@ -2326,6 +2326,11 @@ extern const char *host_detect_local_cpu
# define MCPU_MTUNE_NATIVE_SPECS ""
#endif
-#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
-
+#ifdef ENABLE_ESP
+# define DRIVER_SELF_SPECS \
+ MCPU_MTUNE_NATIVE_SPECS, \
+ ESP_DRIVER_SELF_SPEC
+#else
+# define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
+#endif
#endif /* ! GCC_ARM_H */
--- a/gcc/config/arm/elf.h 2013-01-10 21:38:27.000000000 +0100
+++ b/gcc/config/arm/elf.h 2013-05-19 02:15:49.595855825 +0200
@@ -49,7 +49,11 @@
#endif
#undef SUBSUBTARGET_EXTRA_SPECS
+#ifdef ENABLE_ESP
+#define SUBSUBTARGET_EXTRA_SPECS ESP_EXTRA_SPECS
+#else
#define SUBSUBTARGET_EXTRA_SPECS
+#endif
#ifndef ASM_SPEC
#define ASM_SPEC "\
2014-05-12 Magnus Granberg <zorry@gentoo.org>
* gcc/esp.h New file to support --enable-esp
Version 20140512.1
--- a/gcc/config/esp.h 2010-04-09 16:14:00.000000000 +0200
+++ b/gcc/config/esp.h 2012-06-23 01:00:31.248348491 +0200
@@ -0,0 +1,127 @@
+/* License terms see GNU GENERAL PUBLIC LICENSE Version 3.
+ * Version 20140512.1
+ * Magnus Granberg (Zorry) <zorry@gentoo.org> */
+#ifndef GCC_ESP_H
+#define GCC_ESP_H
+
+/* This file will add -fstack-protector-all, -fstack-check, -fPIE, -pie and -z now
+ as default if the defines and the spec allow it.
+ Added a hack for gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass
+ to support older hardened GCC patches and we don't need to change the code on gcc-specs-* and _filter-hardened.
+ This will add some unsupported upstream commands options as -nopie and -nonow.
+ -D__KERNEL__ is added so we don't have -fPIE, -pie and -fstack-protector-all and -fstack-check when building kernels.
+ ESP_CC1_SPEC is added to CC1_SPEC.
+ ESP_CC1_STRICT_OVERFLOW_SPEC is added so we don't disable the strict-overflow check.
+ ESP_LINK_PIE_CHECK_SPEC check for -pie, -p, -pg, -profile and -static.
+ ENABLE_CRTBEGINP add support for crtbeginP.o, build -static with -fPIE or -fpie.
+*/
+#ifdef ENABLE_ESP
+
+ /* Hack to support gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass */
+ #define ESP_CC1_SPEC " %(esp_cc1_ssp) %(esp_cc1_pie) %(esp_cc1_strict_overflow)"
+ #if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP )
+ #define ESP_CC1_SSP_SPEC "%{!fno-stack-protector: %{!fno-stack-protector-all: %{!fno-stack-check: }}}"
+ #else
+ #define ESP_CC1_SSP_SPEC ""
+ #endif
+ #if defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP )
+ #define ESP_CC1_PIE_SPEC "%{!nopie: }"
+ #else
+ #define ESP_CC1_PIE_SPEC ""
+ #endif
+ #define ESP_CC1_STRICT_OVERFLOW_SPEC "%{!fstrict-overflow:%{!fno-strict-overflow: -fno-strict-overflow}}"
+
+ /* ESP_LINK_SPEC is added to LINK_PIE_SPEC if esp is enable
+ -z now will be added if we don't have -vanilla spec. We do a -pie incompatible check
+ Don't remove the specs in the end */
+ #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_pie_check) "
+ #define ESP_LINK_NOW_SPEC "%{!nonow:-z now}"
+
+ /* We use ESP_DRIVER_SELF_SPEC to add pie and ssp command-line options. */
+ #define ESP_DRIVER_SELF_SPEC "%{D__KERNEL__:;:%{!nopie:%(esp_options_pie) \
+ %(esp_link_pie)} %(esp_options_ssp) }"
+
+ /* This will add -fstack-protector-all if we don't have -nostdlib -nodefaultlibs -fno-stack-protector -fstack-protector
+ -fstack-protector-all and we have EFAULT_SSP or EFAULT_PIE_SSP defined. */
+ #if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP )
+ #define ESP_OPTIONS_SSP_SPEC \
+ "%{nostdlib|ffreestanding|fno-stack-protector|fstack-protector| \
+ fstack-protector-all|fstack-protector-strong:;:-fstack-protector-all} \
+ %{fstack-check|fstack-check=*:;: -fstack-check}"
+ #else
+ #define ESP_OPTIONS_SSP_SPEC ""
+ #endif
+
+ /* If EFAULT_PIE or EFAULT_PIE_SSP is defined we will add -fPIE -pie */
+ #if defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP )
+
+ /* This will add -fPIE if we don't have -pie -fpic -fPIC -fpie -fPIE -fno-pic -fno-PIC -fno-pie -fno-PIE -shared -static
+ -nostdlib -nostartfiles. */
+ /* With ENABLE_CRTBEGINP we don't need to check for -static */
+ #ifdef ENABLE_CRTBEGINP
+ #define ESP_OPTIONS_PIE_SPEC \
+ "%{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: \
+ %{!shared: %{!nostdlib: %{!nostartfiles:-fPIE}} } }}}} }}}} }"
+ #else
+ #define ESP_OPTIONS_PIE_SPEC \
+ "%{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: \
+ %{!shared: %{!static: %{!nostdlib: %{!nostartfiles:-fPIE}} } }}}} }}}} }}"
+ #endif
+
+ /* This will add -pie if we don't have -pie -A -fno-pic -fno-PIC -fno-pie -fno-PIE -shared -static -r -nostdlib
+ -nostartfiles */
+ /* With ENABLE_CRTBEGINP we don't need to check for -static
+ and we add -pie only to get the start and endfiles. -pie will not go to the linker. */
+ #ifdef ENABLE_CRTBEGINP
+ #define ESP_LINK_PIE_SPEC \
+ "%{!pie:%{!A:%{!fno-pie:%{!fno-PIE:%{!fno-pic:%{!fno-PIC:%{!shared:%{!r: \
+ %{!nostdlib:%{!nostartfiles:-pie}}}}}}}}}}"
+ #else
+ #define ESP_LINK_PIE_SPEC \
+ "%{!pie:%{!A:%{!fno-pie:%{!fno-PIE:%{!fno-pic:%{!fno-PIC:%{!shared:%{!static:%{!r: \
+ %{!nostdlib:%{!nostartfiles:-pie}}}}}}}}}}}"
+ #endif
+
+ /* This will check if -pie is set when (-static) -pg -p -profile. If set it will make gcc print out
+ "-pie and (static)|pg|p|profile are incompatible when linking" */
+ /* With ENABLE_CRTBEGINP we don't need to check for -static */
+ #ifdef ENABLE_CRTBEGINP
+ #define ESP_LINK_PIE_CHECK_SPEC \
+ "%{pie:%{pg|p|profile:%e-pie and -pg|p|profile are incompatible when linking}}"
+ #else
+ #define ESP_LINK_PIE_CHECK_SPEC \
+ "%{pie:%{static|pg|p|profile:%e-pie and -static|pg|p|profile are incompatible when linking}}"
+ #endif
+
+ /* We don't pass -pie to the linker when -static. */
+ #ifdef ENABLE_CRTBEGINP
+ #define LINK_PIE_SPEC "%{!static:%{pie:-pie}} %(esp_link)"
+ #else
+ #define LINK_PIE_SPEC "%{pie:-pie} %(esp_link)"
+ #endif
+
+ #else
+ #define ESP_OPTIONS_PIE_SPEC ""
+ #define ESP_LINK_PIE_CHECK_SPEC ""
+ #define ESP_LINK_PIE_SPEC ""
+ #define LINK_PIE_SPEC "%{pie:-pie} %(esp_link)"
+ #endif
+
+ /* We add extra spec name's to the EXTRA_SPECS list */
+ #define ESP_EXTRA_SPECS \
+ { "esp_cc1", ESP_CC1_SPEC }, \
+ { "esp_cc1_pie", ESP_CC1_PIE_SPEC }, \
+ { "esp_cc1_ssp", ESP_CC1_SSP_SPEC }, \
+ { "esp_cc1_strict_overflow", ESP_CC1_STRICT_OVERFLOW_SPEC }, \
+ { "esp_link", ESP_LINK_SPEC }, \
+ { "esp_link_now", ESP_LINK_NOW_SPEC }, \
+ { "esp_link_pie", ESP_LINK_PIE_SPEC }, \
+ { "esp_link_pie_check", ESP_LINK_PIE_CHECK_SPEC }, \
+ { "esp_driver_self", ESP_DRIVER_SELF_SPEC }, \
+ { "esp_options_pie", ESP_OPTIONS_PIE_SPEC }, \
+ { "esp_options_ssp", ESP_OPTIONS_SSP_SPEC }
+
+ static const char *cc1_spec = CC1_SPEC ESP_CC1_SPEC;
+
+#endif
+#endif /* End GCC_ESP_H */
Apply Alpine Linux specific differences to Gentoo ESP configuration:
- default PIE and SSP by default without additional CFLAGS (to clean up APKBUILD)
- do not enable -fstack-check by default (caused failures in programs that setup
small stack in musl)
- enable -z relro by default
- enable -fstack-protector-strong instead of -fstack-protector-all by default
--- gcc-4.9.2/gcc/config/esp.h 2014-12-10 15:54:19.925060848 +0000
+++ gcc-4.9.2/gcc/config/esp.h 2014-12-10 15:59:16.793850060 +0000
@@ -4,7 +4,7 @@
#ifndef GCC_ESP_H
#define GCC_ESP_H
-/* This file will add -fstack-protector-all, -fstack-check, -fPIE, -pie and -z now
+/* This file will add -fstack-protector-strong, -fPIE, -pie, -z relro and -z now
as default if the defines and the spec allow it.
Added a hack for gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass
to support older hardened GCC patches and we don't need to change the code on gcc-specs-* and _filter-hardened.
@@ -16,11 +16,14 @@
ENABLE_CRTBEGINP add support for crtbeginP.o, build -static with -fPIE or -fpie.
*/
#ifdef ENABLE_ESP
+
+ /* Enable by default on Alpine */
+ #define EFAULT_PIE_SSP
/* Hack to support gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass */
#define ESP_CC1_SPEC " %(esp_cc1_ssp) %(esp_cc1_pie) %(esp_cc1_strict_overflow)"
#if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP )
- #define ESP_CC1_SSP_SPEC "%{!fno-stack-protector: %{!fno-stack-protector-all: %{!fno-stack-check: }}}"
+ #define ESP_CC1_SSP_SPEC "%{!fno-stack-protector: %{!fno-stack-protector-all: }}"
#else
#define ESP_CC1_SSP_SPEC ""
#endif
@@ -34,20 +37,20 @@
/* ESP_LINK_SPEC is added to LINK_PIE_SPEC if esp is enable
-z now will be added if we don't have -vanilla spec. We do a -pie incompatible check
Don't remove the specs in the end */
- #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_pie_check) "
+ #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_relro) %(esp_link_pie_check) "
#define ESP_LINK_NOW_SPEC "%{!nonow:-z now}"
+ #define ESP_LINK_RELRO_SPEC "%{!norelro:-z relro}"
/* We use ESP_DRIVER_SELF_SPEC to add pie and ssp command-line options. */
#define ESP_DRIVER_SELF_SPEC "%{D__KERNEL__:;:%{!nopie:%(esp_options_pie) \
%(esp_link_pie)} %(esp_options_ssp) }"
- /* This will add -fstack-protector-all if we don't have -nostdlib -nodefaultlibs -fno-stack-protector -fstack-protector
+ /* This will add -fstack-protector-strong if we don't have -nostdlib -nodefaultlibs -fno-stack-protector -fstack-protector
-fstack-protector-all and we have EFAULT_SSP or EFAULT_PIE_SSP defined. */
#if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP )
#define ESP_OPTIONS_SSP_SPEC \
"%{nostdlib|ffreestanding|fno-stack-protector|fstack-protector| \
- fstack-protector-all|fstack-protector-strong:;:-fstack-protector-all} \
- %{fstack-check|fstack-check=*:;: -fstack-check}"
+ fstack-protector-all|fstack-protector-strong:;:-fstack-protector-strong}"
#else
#define ESP_OPTIONS_SSP_SPEC ""
#endif
@@ -115,6 +118,7 @@
{ "esp_cc1_strict_overflow", ESP_CC1_STRICT_OVERFLOW_SPEC }, \
{ "esp_link", ESP_LINK_SPEC }, \
{ "esp_link_now", ESP_LINK_NOW_SPEC }, \
+ { "esp_link_relro", ESP_LINK_RELRO_SPEC }, \
{ "esp_link_pie", ESP_LINK_PIE_SPEC }, \
{ "esp_link_pie_check", ESP_LINK_PIE_CHECK_SPEC }, \
{ "esp_driver_self", ESP_DRIVER_SELF_SPEC }, \
libitm checks for AVX support in the assembler and adds -mavx to x86_avx.cc
which defines the needed typedefs. User CFLAGS can override -mavx however,
so also use the fallback typedef if __AVX__ isn't defined.
https://bugs.gentoo.org/417271
http://gcc.gnu.org/PR53113
--- a/libitm/config/x86/x86_avx.cc
+++ b/libitm/config/x86/x86_avx.cc
@@ -29,7 +29,7 @@
extern "C" {
-#ifndef HAVE_AS_AVX
+#if !defined (HAVE_AS_AVX) || !defined(__AVX__)
// If we don't have an AVX capable assembler, we didn't set -mavx on the
// command-line either, which means that libitm.h defined neither this type
// nor the functions in this file. Define the type and unconditionally
@@ -40,7 +40,7 @@ typedef float _ITM_TYPE_M256 __attribute__((vector_size(32), may_alias));
// Re-define the memcpy implementations so that we can frob the
// interface to deal with possibly missing AVX instruction set support.
-#ifdef HAVE_AS_AVX
+#if defined(HAVE_AS_AVX) && defined(__AVX__)
#define RETURN(X) return X
#define STORE(X,Y) X = Y
#define OUTPUT(T) _ITM_TYPE_##T
2008-07-25 Magnus Granberg <zorry@ume.nu>
* include/libiberty.h (asprintf): Don't declare if defined as a macro
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -609,8 +609,11 @@ extern int pwait (int, int *, int);
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
+/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
+#ifndef asprintf
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
+#endif
#if !HAVE_DECL_VASPRINTF
/* Like vsprintf but provides a pointer to malloc'd storage, which
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -246,6 +246,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
$(RANLIB) $(TARGETLIB); \
+ cp $(TARGETLIB) ../ ; \
cd ..; \
else true; fi
From 160397ef3c3331099af028f1b8d3e085b07d88ad Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 29 Mar 2013 08:59:00 +0400
Subject: [PATCH 16/35] gcc: poison-system-directories
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Inappropriate [distribution: codesourcery]
---
gcc/Makefile.in | 2 +-
gcc/common.opt | 4 ++++
gcc/config.in | 6 ++++++
gcc/configure | 20 ++++++++++++++++++--
gcc/configure.ac | 10 ++++++++++
gcc/doc/invoke.texi | 9 +++++++++
gcc/gcc.c | 2 ++
gcc/incpath.c | 19 +++++++++++++++++++
8 files changed, 69 insertions(+), 3 deletions(-)
Index: gcc-4.9-20140316/gcc/common.opt
===================================================================
--- gcc-4.9-20140316.orig/gcc/common.opt
+++ gcc-4.9-20140316/gcc/common.opt
@@ -603,6 +603,10 @@ Wpedantic
Common Var(pedantic) Warning
Issue warnings needed for strict compliance to the standard
+Wpoison-system-directories
+Common Var(flag_poison_system_directories) Init(1) Warning
+Warn for -I and -L options using system directories if cross compiling
+
Wshadow
Common Var(warn_shadow) Warning
Warn when one local variable shadows another
Index: gcc-4.9-20140316/gcc/config.in
===================================================================
--- gcc-4.9-20140316.orig/gcc/config.in
+++ gcc-4.9-20140316/gcc/config.in
@@ -138,6 +138,12 @@
#endif
+/* Define to warn for use of native system header directories */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
+#endif
+
+
/* Define if you want all operations on RTL (the basic data structure of the
optimizer and back end) to be checked for dynamic type safety at runtime.
This is quite expensive. */
Index: gcc-4.9-20140316/gcc/configure
===================================================================
--- gcc-4.9-20140316.orig/gcc/configure
+++ gcc-4.9-20140316/gcc/configure
@@ -928,6 +928,7 @@ with_system_zlib
enable_maintainer_mode
enable_link_mutex
enable_version_specific_runtime_libs
+enable_poison_system_directories
enable_plugin
enable_host_shared
enable_libquadmath_support
@@ -1648,6 +1649,8 @@ Optional Features:
--enable-version-specific-runtime-libs
specify that runtime libraries should be installed
in a compiler-specific directory
+ --enable-poison-system-directories
+ warn for use of native system header directories
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
--disable-libquadmath-support
@@ -27702,6 +27705,19 @@ if test "${enable_version_specific_runti
fi
+# Check whether --enable-poison-system-directories was given.
+if test "${enable_poison_system_directories+set}" = set; then :
+ enableval=$enable_poison_system_directories;
+else
+ enable_poison_system_directories=no
+fi
+
+if test "x${enable_poison_system_directories}" = "xyes"; then
+
+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
+
+fi
+
# Substitute configuration variables
Index: gcc-4.9-20140316/gcc/configure.ac
===================================================================
--- gcc-4.9-20140316.orig/gcc/configure.ac
+++ gcc-4.9-20140316/gcc/configure.ac
@@ -5366,6 +5366,16 @@ AC_ARG_ENABLE(version-specific-runtime-l
[specify that runtime libraries should be
installed in a compiler-specific directory])])
+AC_ARG_ENABLE([poison-system-directories],
+ AS_HELP_STRING([--enable-poison-system-directories],
+ [warn for use of native system header directories]),,
+ [enable_poison_system_directories=no])
+if test "x${enable_poison_system_directories}" = "xyes"; then
+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
+ [1],
+ [Define to warn for use of native system header directories])
+fi
+
# Substitute configuration variables
AC_SUBST(subdirs)
AC_SUBST(srcdir)
Index: gcc-4.9-20140316/gcc/doc/invoke.texi
===================================================================
--- gcc-4.9-20140316.orig/gcc/doc/invoke.texi
+++ gcc-4.9-20140316/gcc/doc/invoke.texi
@@ -260,6 +260,7 @@ Objective-C and Objective-C++ Dialects}.
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
-Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
-Wpointer-arith -Wno-pointer-to-int-cast @gol
+-Wno-poison-system-directories @gol
-Wredundant-decls -Wno-return-local-addr @gol
-Wreturn-type -Wsequence-point -Wshadow @gol
-Wsign-compare -Wsign-conversion -Wfloat-conversion @gol
@@ -4230,6 +4231,14 @@ headers---for that, @option{-Wunknown-pr
for most targets, it is made up of code and thus requires the stack
to be made executable in order for the program to work properly.
+@item -Wno-poison-system-directories
+@opindex Wno-poison-system-directories
+Do not warn for @option{-I} or @option{-L} options using system
+directories such as @file{/usr/include} when cross compiling. This
+option is intended for use in chroot environments when such
+directories contain the correct headers and libraries for the target
+system rather than the host.
+
@item -Wfloat-equal
@opindex Wfloat-equal
@opindex Wno-float-equal
Index: gcc-4.9-20140316/gcc/gcc.c
===================================================================
--- gcc-4.9-20140316.orig/gcc/gcc.c
+++ gcc-4.9-20140316/gcc/gcc.c
@@ -764,6 +764,8 @@ proper position among the other output f
"%{fuse-ld=*:-fuse-ld=%*}\
%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \
+ %{Wno-poison-system-directories:--no-poison-system-directories}\
+ %{Werror=poison-system-directories:--error-poison-system-directories}\
%{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
%{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
%{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
Index: gcc-4.9-20140316/gcc/incpath.c
===================================================================
--- gcc-4.9-20140316.orig/gcc/incpath.c
+++ gcc-4.9-20140316/gcc/incpath.c
@@ -28,6 +28,7 @@
#include "intl.h"
#include "incpath.h"
#include "cppdefault.h"
+#include "diagnostic-core.h"
/* Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes. */
@@ -382,6 +383,24 @@ merge_include_chains (const char *sysroo
}
fprintf (stderr, _("End of search list.\n"));
}
+
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
+ if (flag_poison_system_directories)
+ {
+ struct cpp_dir *p;
+
+ for (p = heads[QUOTE]; p; p = p->next)
+ {
+ if ((!strncmp (p->name, "/usr/include", 12))
+ || (!strncmp (p->name, "/usr/local/include", 18))
+ || (!strncmp (p->name, "/usr/X11R6/include", 18)))
+ warning (OPT_Wpoison_system_directories,
+ "include location \"%s\" is unsafe for "
+ "cross-compilation",
+ p->name);
+ }
+ }
+#endif
}
/* Use given -I paths for #include "..." but not #include <...>, and
This diff is collapsed.