summaryrefslogtreecommitdiff
path: root/share/doc/gccint/Stack-Checking.html
diff options
context:
space:
mode:
Diffstat (limited to 'share/doc/gccint/Stack-Checking.html')
-rw-r--r--share/doc/gccint/Stack-Checking.html205
1 files changed, 205 insertions, 0 deletions
diff --git a/share/doc/gccint/Stack-Checking.html b/share/doc/gccint/Stack-Checking.html
new file mode 100644
index 0000000..1ce4943
--- /dev/null
+++ b/share/doc/gccint/Stack-Checking.html
@@ -0,0 +1,205 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- Copyright (C) 1988-2023 Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with the
+Invariant Sections being "Funding Free Software", the Front-Cover
+Texts being (a) (see below), and with the Back-Cover Texts being (b)
+(see below). A copy of the license is included in the section entitled
+"GNU Free Documentation License".
+
+(a) The FSF's Front-Cover Text is:
+
+A GNU Manual
+
+(b) The FSF's Back-Cover Text is:
+
+You have freedom to copy and modify this GNU Manual, like GNU
+ software. Copies published by the Free Software Foundation raise
+ funds for GNU development. -->
+<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
+<head>
+<title>GNU Compiler Collection (GCC) Internals: Stack Checking</title>
+
+<meta name="description" content="GNU Compiler Collection (GCC) Internals: Stack Checking">
+<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Stack Checking">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="makeinfo">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="index.html#Top" rel="start" title="Top">
+<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
+<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
+<link href="Stack-and-Calling.html#Stack-and-Calling" rel="up" title="Stack and Calling">
+<link href="Frame-Registers.html#Frame-Registers" rel="next" title="Frame Registers">
+<link href="Exception-Handling.html#Exception-Handling" rel="previous" title="Exception Handling">
+<style type="text/css">
+<!--
+a.summary-letter {text-decoration: none}
+blockquote.smallquotation {font-size: smaller}
+div.display {margin-left: 3.2em}
+div.example {margin-left: 3.2em}
+div.indentedblock {margin-left: 3.2em}
+div.lisp {margin-left: 3.2em}
+div.smalldisplay {margin-left: 3.2em}
+div.smallexample {margin-left: 3.2em}
+div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
+div.smalllisp {margin-left: 3.2em}
+kbd {font-style:oblique}
+pre.display {font-family: inherit}
+pre.format {font-family: inherit}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+pre.smalldisplay {font-family: inherit; font-size: smaller}
+pre.smallexample {font-size: smaller}
+pre.smallformat {font-family: inherit; font-size: smaller}
+pre.smalllisp {font-size: smaller}
+span.nocodebreak {white-space:nowrap}
+span.nolinebreak {white-space:nowrap}
+span.roman {font-family:serif; font-weight:normal}
+span.sansserif {font-family:sans-serif; font-weight:normal}
+ul.no-bullet {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+<a name="Stack-Checking"></a>
+<div class="header">
+<p>
+Next: <a href="Frame-Registers.html#Frame-Registers" accesskey="n" rel="next">Frame Registers</a>, Previous: <a href="Exception-Handling.html#Exception-Handling" accesskey="p" rel="previous">Exception Handling</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
+</div>
+<hr>
+<a name="Specifying-How-Stack-Checking-is-Done"></a>
+<h4 class="subsection">18.9.3 Specifying How Stack Checking is Done</h4>
+
+<p>GCC will check that stack references are within the boundaries of the
+stack, if the option <samp>-fstack-check</samp> is specified, in one of
+three ways:
+</p>
+<ol>
+<li> If the value of the <code>STACK_CHECK_BUILTIN</code> macro is nonzero, GCC
+will assume that you have arranged for full stack checking to be done
+at appropriate places in the configuration files. GCC will not do
+other special processing.
+
+</li><li> If <code>STACK_CHECK_BUILTIN</code> is zero and the value of the
+<code>STACK_CHECK_STATIC_BUILTIN</code> macro is nonzero, GCC will assume
+that you have arranged for static stack checking (checking of the
+static stack frame of functions) to be done at appropriate places
+in the configuration files. GCC will only emit code to do dynamic
+stack checking (checking on dynamic stack allocations) using the third
+approach below.
+
+</li><li> If neither of the above are true, GCC will generate code to periodically
+&ldquo;probe&rdquo; the stack pointer using the values of the macros defined below.
+</li></ol>
+
+<p>If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
+GCC will change its allocation strategy for large objects if the option
+<samp>-fstack-check</samp> is specified: they will always be allocated
+dynamically if their size exceeds <code>STACK_CHECK_MAX_VAR_SIZE</code> bytes.
+</p>
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fBUILTIN"></a>Macro: <strong>STACK_CHECK_BUILTIN</strong></dt>
+<dd><p>A nonzero value if stack checking is done by the configuration files in a
+machine-dependent manner. You should define this macro if stack checking
+is required by the ABI of your machine or if you would like to do stack
+checking in some more efficient way than the generic approach. The default
+value of this macro is zero.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fSTATIC_005fBUILTIN"></a>Macro: <strong>STACK_CHECK_STATIC_BUILTIN</strong></dt>
+<dd><p>A nonzero value if static stack checking is done by the configuration files
+in a machine-dependent manner. You should define this macro if you would
+like to do static stack checking in some more efficient way than the generic
+approach. The default value of this macro is zero.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fPROBE_005fINTERVAL_005fEXP"></a>Macro: <strong>STACK_CHECK_PROBE_INTERVAL_EXP</strong></dt>
+<dd><p>An integer specifying the interval at which GCC must generate stack probe
+instructions, defined as 2 raised to this integer. You will normally
+define this macro so that the interval be no larger than the size of
+the &ldquo;guard pages&rdquo; at the end of a stack area. The default value
+of 12 (4096-byte interval) is suitable for most systems.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fMOVING_005fSP"></a>Macro: <strong>STACK_CHECK_MOVING_SP</strong></dt>
+<dd><p>An integer which is nonzero if GCC should move the stack pointer page by page
+when doing probes. This can be necessary on systems where the stack pointer
+contains the bottom address of the memory area accessible to the executing
+thread at any point in time. In this situation an alternate signal stack
+is required in order to be able to recover from a stack overflow. The
+default value of this macro is zero.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fPROTECT"></a>Macro: <strong>STACK_CHECK_PROTECT</strong></dt>
+<dd><p>The number of bytes of stack needed to recover from a stack overflow, for
+languages where such a recovery is supported. The default value of 4KB/8KB
+with the <code>setjmp</code>/<code>longjmp</code>-based exception handling mechanism and
+8KB/12KB with other exception handling mechanisms should be adequate for most
+architectures and operating systems.
+</p></dd></dl>
+
+<p>The following macros are relevant only if neither STACK_CHECK_BUILTIN
+nor STACK_CHECK_STATIC_BUILTIN is defined; you can omit them altogether
+in the opposite case.
+</p>
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fMAX_005fFRAME_005fSIZE"></a>Macro: <strong>STACK_CHECK_MAX_FRAME_SIZE</strong></dt>
+<dd><p>The maximum size of a stack frame, in bytes. GCC will generate probe
+instructions in non-leaf functions to ensure at least this many bytes of
+stack are available. If a stack frame is larger than this size, stack
+checking will not be reliable and GCC will issue a warning. The
+default is chosen so that GCC only generates one instruction on most
+systems. You should normally not change the default value of this macro.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fFIXED_005fFRAME_005fSIZE"></a>Macro: <strong>STACK_CHECK_FIXED_FRAME_SIZE</strong></dt>
+<dd><p>GCC uses this value to generate the above warning message. It
+represents the amount of fixed frame used by a function, not including
+space for any callee-saved registers, temporaries and user variables.
+You need only specify an upper bound for this amount and will normally
+use the default of four words.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-STACK_005fCHECK_005fMAX_005fVAR_005fSIZE"></a>Macro: <strong>STACK_CHECK_MAX_VAR_SIZE</strong></dt>
+<dd><p>The maximum size, in bytes, of an object that GCC will place in the
+fixed area of the stack frame when the user specifies
+<samp>-fstack-check</samp>.
+GCC computed the default from the values of the above macros and you will
+normally not need to override that default.
+</p></dd></dl>
+
+<dl>
+<dt><a name="index-TARGET_005fSTACK_005fCLASH_005fPROTECTION_005fALLOCA_005fPROBE_005fRANGE"></a>Target Hook: <em>HOST_WIDE_INT</em> <strong>TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE</strong> <em>(void)</em></dt>
+<dd><p>Some targets have an ABI defined interval for which no probing needs to be done.
+When a probe does need to be done this same interval is used as the probe distance
+up when doing stack clash protection for alloca.
+On such targets this value can be set to override the default probing up interval.
+Define this variable to return nonzero if such a probe range is required or zero otherwise.
+Defining this hook also requires your functions which make use of alloca to have at least 8 byes
+of outgoing arguments. If this is not the case the stack will be corrupted.
+You need not define this macro if it would always have the value zero.
+</p></dd></dl>
+
+<hr>
+<div class="header">
+<p>
+Next: <a href="Frame-Registers.html#Frame-Registers" accesskey="n" rel="next">Frame Registers</a>, Previous: <a href="Exception-Handling.html#Exception-Handling" accesskey="p" rel="previous">Exception Handling</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
+</div>
+
+
+
+</body>
+</html>