Go to the first, previous, next, last section, table of contents.


Specifying How Stack Checking is Done

GNU CC will check that stack references are within the boundaries of the stack, if the `-fstack-check' is specified, in one of three ways:

  1. If the value of the STACK_CHECK_BUILTIN macro is nonzero, GNU CC will assume that you have arranged for stack checking to be done at appropriate places in the configuration files, e.g., in FUNCTION_PROLOGUE. GNU CC will do not other special processing.
  2. If STACK_CHECK_BUILTIN is zero and you defined a named pattern called check_stack in your `md' file, GNU CC will call that pattern with one argument which is the address to compare the stack value against. You must arrange for this pattern to report an error if the stack pointer is out of range.
  3. If neither of the above are true, GNU CC will generate code to periodically "probe" the stack pointer using the values of the macros defined below.

Normally, you will use the default values of these macros, so GNU CC will use the third approach.

STACK_CHECK_BUILTIN
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 require by the ABI of your machine or if you would like to have to stack checking in some more efficient way than GNU CC's portable approach. The default value of this macro is zero.
STACK_CHECK_PROBE_INTERVAL
An integer representing the interval at which GNU CC must generate stack probe instructions. You will normally define this macro to be no larger than the size of the "guard pages" at the end of a stack area. The default value of 4096 is suitable for most systems.
STACK_CHECK_PROBE_LOAD
A integer which is nonzero if GNU CC should perform the stack probe as a load instruction and zero if GNU CC should use a store instruction. The default is zero, which is the most efficient choice on most systems.
STACK_CHECK_PROTECT
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 75 words should be adequate for most machines.
STACK_CHECK_MAX_FRAME_SIZE
The maximum size of a stack frame, in bytes. GNU CC 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 GNU CC will issue a warning. The default is chosen so that GNU CC only generates one instruction on most systems. You should normally not change the default value of this macro.
STACK_CHECK_FIXED_FRAME_SIZE
GNU CC 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.
STACK_CHECK_MAX_VAR_SIZE
The maximum size, in bytes, of an object that GNU CC will place in the fixed area of the stack frame when the user specifies `-fstack-check'. GNU CC computed the default from the values of the above macros and you will normally not need to override that default.


Go to the first, previous, next, last section, table of contents.