diff options
author | Pascal Stumpf <pascal@cvs.openbsd.org> | 2012-08-28 18:59:29 +0000 |
---|---|---|
committer | Pascal Stumpf <pascal@cvs.openbsd.org> | 2012-08-28 18:59:29 +0000 |
commit | fcbf5c8c7ee754fbc5c55c8791761a8563c6e1fd (patch) | |
tree | 1c65ab49096d8f0f94034349938e0daccbe78542 /gnu/gcc | |
parent | ca3f64c0c488a8aed59da1cc7ab59b24dff6f283 (diff) |
Add support for PIE-by-default in both ld and gcc. This is a completely
different approach than the one taken in kurt@'s original diff, but deemed
better after discussion and diff exchange with kettenis@ and matthew@.
Lots of feedback by kettenis@ and matthew@, prodding and encouragement by
deraadt@.
ok kettenis@ matthew@
Diffstat (limited to 'gnu/gcc')
-rw-r--r-- | gnu/gcc/gcc/common.opt | 2 | ||||
-rw-r--r-- | gnu/gcc/gcc/defaults.h | 4 | ||||
-rw-r--r-- | gnu/gcc/gcc/gcc.c | 2 | ||||
-rw-r--r-- | gnu/gcc/gcc/opts.c | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/gnu/gcc/gcc/common.opt b/gnu/gcc/gcc/common.opt index 8eb5883768e..66499639fc2 100644 --- a/gnu/gcc/gcc/common.opt +++ b/gnu/gcc/gcc/common.opt @@ -677,7 +677,7 @@ Common Report Var(flag_pic,2) Generate position-independent code if possible (large mode) fPIE -Common Report Var(flag_pie,2) +Common Report Var(flag_pie,2) Init(PIE_DEFAULT) Generate position-independent code for executables if possible (large mode) fpic diff --git a/gnu/gcc/gcc/defaults.h b/gnu/gcc/gcc/defaults.h index 6af5f17bd7d..d7d65e85b85 100644 --- a/gnu/gcc/gcc/defaults.h +++ b/gnu/gcc/gcc/defaults.h @@ -900,4 +900,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #define HARD_REGNO_NREGS_WITH_PADDING(REGNO, MODE) -1 #endif +#ifndef PIE_DEFAULT +#define PIE_DEFAULT 0 +#endif + #endif /* ! GCC_DEFAULTS_H */ diff --git a/gnu/gcc/gcc/gcc.c b/gnu/gcc/gcc/gcc.c index 0b5ee4b15d8..07ed21ebae3 100644 --- a/gnu/gcc/gcc/gcc.c +++ b/gnu/gcc/gcc/gcc.c @@ -684,7 +684,7 @@ proper position among the other output files. */ #ifndef LINK_PIE_SPEC #ifdef HAVE_LD_PIE -#define LINK_PIE_SPEC "%{pie:-pie} " +#define LINK_PIE_SPEC "%{pie:-pie} %{p|pg|nopie:-nopie} " #else #define LINK_PIE_SPEC "%{pie:} " #endif diff --git a/gnu/gcc/gcc/opts.c b/gnu/gcc/gcc/opts.c index c8e32cfb4e1..f84546120f8 100644 --- a/gnu/gcc/gcc/opts.c +++ b/gnu/gcc/gcc/opts.c @@ -570,6 +570,8 @@ decode_options (unsigned int argc, const char **argv) handle_options (argc, argv, lang_mask); + if (flag_pic || profile_flag) + flag_pie = 0; if (flag_pie) flag_pic = flag_pie; if (flag_pic && !flag_pie) |