aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2010-09-27 19:48:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-09-27 19:48:20 +0000
commit7458026b018e6635b9d1bae9ec3b9f4738c3d94a (patch)
tree69a38455d6a1f5425700674e4dc6483284eed579 /gcc/gcc.c
parent177b48f93077a03a72cee7ab5897996e2ea47cdc (diff)
downloadgcc-7458026b018e6635b9d1bae9ec3b9f4738c3d94a.zip
gcc-7458026b018e6635b9d1bae9ec3b9f4738c3d94a.tar.gz
gcc-7458026b018e6635b9d1bae9ec3b9f4738c3d94a.tar.bz2
common.opt (fsplit-stack): New option.
gcc/: * common.opt (fsplit-stack): New option. * opts.c (decode_options): Set flag_split_stack to final value. * target.def (supports_split_stack): New hook. * gcc.c (STACK_SPLIT_SPEC): Define. (LINK_COMMAND_SPEC): Use STACK_SPLIT_SPEC. * doc/invoke.texi (Option Summary): Mention -fsplit-stack. (Code Gen Options): Document -fsplit-stack. * doc/extend.texi (Function Attributes): Mention no_split_stack. (Function Attributes): Document no_split_stack. * doc/tm.texi.in (Stack Smashing Protection): Add @hook TARGET_SUPPORTS_SPLIT_STACK. * doc/tm.texi: Rebuild. * function.c (thread_prologue_and_epilogue_insns): If flag_split_stack, add split stack prologue. * explow.c (allocate_dynamic_stack_space): Support -fsplit-stack. * varasm.c (saw_no_split_stack): New static variable. (assemble_start_function): Set saw_no_split_stack if the function has the no_split_stack attribute. (file_end_indicate_split_stack): New function. * output.h (file_end_indicate_split_stack): Declare. * libgcc-std.ver (GCC_4.6.0): Add -fsplit-stack support variables and function. * doc/libgcc.texi (Miscellaneous routines): Document -fsplit-stack routines. * config/i386/i386.c (ix86_option_override_internal): Don't set expand_builtin_va_start to NULL if -fsplit-stack. (ix86_function_regparm): Reduce local regparm by 1 for 32-bit -fsplit-stack. (ix86_va_start): If -fsplit-stack, get overflow pointer from scratch register set by prologue. (ix86_code_end): If -fsplit-stack, call file_end_indicate_split_stack. (ix86_supports_split_stack): New static function. (SPLIT_STACK_AVAILABLE): Define. (split_stack_prologue_scratch_regno): New static function. (split_stack_fn): New static variable. (ix86_expand_split_stack_prologue): New function. (ix86_live_on_entry): New static function. (ix86_legitimate_address_p): Handle UNSPEC_STACK_CHECK. (output_pic_addr_const): Likewise. (i386_asm_output_addr_const_extra): Likewise. (ix86_expand_call): Change return type to rtx. Return the new call instruction. (TARGET_SUPPORTS_SPLIT_STACK): Define. (TARGET_EXTRA_LIVE_ON_ENTRY): Define. * config/i386/i386.md (UNSPEC_STACK_CHECK): Define. (split_stack_prologue, split_stack_return): New insns. (split_stack_space_check): New insn. * config/i386/i386.h (struct machine_function): Add split_stack_varargs_pointer field. * config/i386/linux.h (TARGET_CAN_SPLIT_STACK): Define. (TARGET_THREAD_SPLIT_STACK_OFFSET): Define. * config/i386/linux64.h (TARGET_CAN_SPLIT_STACK): Define. (TARGET_THREAD_SPLIT_STACK_OFFSET): Define. * config/i386/i386-protos.h (ix86_expand_split_stack_prologue): Declare. (ix86_expand_call): Update declaration. gcc/c-family/: * c-common.c (c_common_attribute_table): Add no_split_stack. (handle_no_split_stack_attribute): New static function. gcc/testsuite/: * lib/target-supports.exp (check_effective_target_split_stack): New procedure. * gcc.dg/split-1.c: New test. * gcc.dg/split-2.c: New test. * gcc.dg/split-3.c: New test. * gcc.dg/split-4.c: New test. libgcc/: * generic-morestack.h: New file. * generic-morestack.c: New file. * generic-morestack-thread.c: New file. * config/i386/morestack.S: New file. * config/t-stack: New file. * config/i386/t-stack-i386: New file. * config.host (i[34567]86-*-linux* and friends): Add t-stack and i386/t-stack-i386 to tmake_file. From-SVN: r164661
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 2614faf..cd201f5 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -545,6 +545,16 @@ proper position among the other output files. */
#define MFLIB_SPEC "%{fmudflap|fmudflapth: -export-dynamic}"
#endif
+/* When using -fsplit-stack we need to wrap pthread_create, in order
+ to initialize the stack guard. We always use wrapping, rather than
+ shared library ordering, and we keep the wrapper function in
+ libgcc. This is not yet a real spec, though it could become one;
+ it is currently just stuffed into LINK_SPEC. FIXME: This wrapping
+ only works with GNU ld and gold. FIXME: This is incompatible with
+ -fmudflap when linking statically, which wants to do its own
+ wrapping. */
+#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
+
/* config.h can define LIBGCC_SPEC to override how and when libgcc.a is
included. */
#ifndef LIBGCC_SPEC
@@ -657,7 +667,8 @@ proper position among the other output files. */
"%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
%{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
- %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
+ %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
+ %(mflib) " STACK_SPLIT_SPEC "\
%{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"