aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
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/doc
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/doc')
-rw-r--r--gcc/doc/extend.texi11
-rw-r--r--gcc/doc/invoke.texi21
-rw-r--r--gcc/doc/libgcc.texi40
-rw-r--r--gcc/doc/tm.texi4
-rw-r--r--gcc/doc/tm.texi.in2
5 files changed, 76 insertions, 2 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 7073c90..877dec2 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1926,7 +1926,8 @@ attributes are currently defined for functions on all targets:
@code{returns_twice}, @code{noinline}, @code{noclone},
@code{always_inline}, @code{flatten}, @code{pure}, @code{const},
@code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
-@code{no_instrument_function}, @code{section}, @code{constructor},
+@code{no_instrument_function}, @code{no_split_stack},
+@code{section}, @code{constructor},
@code{destructor}, @code{used}, @code{unused}, @code{deprecated},
@code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
@code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
@@ -2856,6 +2857,14 @@ If @option{-finstrument-functions} is given, profiling function calls will
be generated at entry and exit of most user-compiled functions.
Functions with this attribute will not be so instrumented.
+@item no_split_stack
+@cindex @code{no_split_stack} function attribute
+@opindex fsplit-stack
+If @option{-fsplit-stack} is given, functions will have a small
+prologue which decides whether to split the stack. Functions with the
+@code{no_split_stack} attribute will not have that prologue, and thus
+may run with only a small amount of stack space available.
+
@item noinline
@cindex @code{noinline} function attribute
This function attribute prevents a function from being considered for
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index ee62b1b..bb17a0e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -927,7 +927,7 @@ See S/390 and zSeries Options.
-fshort-double -fshort-wchar @gol
-fverbose-asm -fpack-struct[=@var{n}] -fstack-check @gol
-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
--fno-stack-limit @gol
+-fno-stack-limit -fsplit-stack @gol
-fleading-underscore -ftls-model=@var{model} @gol
-ftrapv -fwrapv -fbounds-check @gol
-fvisibility}
@@ -17857,6 +17857,25 @@ and grows downwards, you can use the flags
@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
of 128KB@. Note that this may only work with the GNU linker.
+@item -fsplit-stack
+@opindex fsplit-stack
+Generate code to automatically split the stack before it overflows.
+The resulting program has a discontiguous stack which can only
+overflow if the program is unable to allocate any more memory. This
+is most useful when running threaded programs, as it is no longer
+necessary to calculate a good stack size to use for each thread. This
+is currently only implemented for the i386 and x86_64 backends running
+GNU/Linux.
+
+When code compiled with @option{-fsplit-stack} calls code compiled
+without @option{-fsplit-stack}, there may not be much stack space
+available for the latter code to run. If compiling all code,
+including library code, with @option{-fsplit-stack} is not an option,
+then the linker can fix up these calls so that the code compiled
+without @option{-fsplit-stack} always has a large stack. Support for
+this is implemented in the gold linker in GNU binutils release 2.21
+and later.
+
@item -fleading-underscore
@opindex fleading-underscore
This option and its counterpart, @option{-fno-leading-underscore}, forcibly
diff --git a/gcc/doc/libgcc.texi b/gcc/doc/libgcc.texi
index 8ead53d..5be6c30 100644
--- a/gcc/doc/libgcc.texi
+++ b/gcc/doc/libgcc.texi
@@ -2262,3 +2262,43 @@ document me!
@deftypefn {Runtime Function} void __clear_cache (char *@var{beg}, char *@var{end})
This function clears the instruction cache between @var{beg} and @var{end}.
@end deftypefn
+
+@subsection Split stack functions and variables
+@deftypefn {Runtime Function} {void *} __splitstack_find (void *@var{segment_arg}, @
+void *@var{sp}, size_t @var{len}, void **@var{next_segment}, @
+void **@var{next_sp}, void **@var{initial_sp})
+When using @option{-fsplit-stack}, this call may be used to iterate
+over the stack segments. It may be called like this:
+@smallexample
+ void *next_segment = NULL;
+ void *next_sp = NULL;
+ void *initial_sp = NULL;
+ void *stack;
+ size_t stack_size;
+ while ((stack = __splitstack_find (next_segment, next_sp,
+ &stack_size, &next_segment,
+ &next_sp, &initial_sp))
+ != NULL)
+ @{
+ /* Stack segment starts at stack and is
+ stack_size bytes long. */
+ @}
+@end smallexample
+
+There is no way to iterate over the stack segments of a different
+thread. However, what is permitted is for one thread to call this
+with the @var{segment_arg} and @var{sp} arguments NULL, to pass
+@var{next_segment}, @var{next_sp}, and @var{initial_sp} to a different
+thread, and then to suspend one way or another. A different thread
+may run the subsequent @code{__splitstack_find} iterations. Of
+course, this will only work if the first thread is suspended while the
+second thread is calling @code{__splitstack_find}. If not, the second
+thread could be looking at the stack while it is changing, and
+anything could happen.
+@end deftypefn
+
+@defvar __morestack_segments
+@defvarx __morestack_current_segment
+@defvarx __morestack_initial_sp
+Internal variables used by the @option{-fsplit-stack} implementation.
+@end defvar
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index a5356eb..3737314 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4960,6 +4960,10 @@ The default version of this hook invokes a function called
normally defined in @file{libgcc2.c}.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_SUPPORTS_SPLIT_STACK (bool)
+Whether this target supports splitting the stack. This is called after options have been parsed, so the target may reject splitting the stack in some configurations. The default version of this hook returns false. If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value
+@end deftypefn
+
@node Varargs
@section Implementing the Varargs Macros
@cindex varargs implementation
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 2fcd979..ea3087f 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -4960,6 +4960,8 @@ The default version of this hook invokes a function called
normally defined in @file{libgcc2.c}.
@end deftypefn
+@hook TARGET_SUPPORTS_SPLIT_STACK
+
@node Varargs
@section Implementing the Varargs Macros
@cindex varargs implementation