Next: Frame Registers, Previous: Exception Handling, Up: Stack and Calling
GCC将检查栈引用是否位于栈的边界里,如果指定了-fstack-check, 使用三种方式的之一:
STACK_CHECK_BUILTIN
宏的值为非0,
则GCC将假设你已经安排了在配置文件的合适的地方进行栈检查,例如,
在TARGET_ASM_FUNCTION_PROLOGUE中。GCC将不再做其它特殊的处理。
STACK_CHECK_BUILTIN
is zero and the value of the
STACK_CHECK_STATIC_BUILTIN
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.
If neither STACK_CHECK_BUILTIN nor STACK_CHECK_STATIC_BUILTIN is defined,
GCC will change its allocation strategy for large objects if the option
-fstack-check is specified: they will always be allocated
dynamically if their size exceeds STACK_CHECK_MAX_VAR_SIZE
bytes.
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. 一个非0值,如果栈检查按照机器相关的方式通过配置文件来完成。 你应该定义该宏,如果栈检查被你的机器的ABI要求, 或者你想让栈检查使用比GCC可移植方式更有效的方法。该宏的缺省值为0。
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.
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 “guard pages” at the end of a stack area. The default value of 12 (4096-byte interval) is suitable for most systems.
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.
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 with the
setjmp
/longjmp
-based exception handling mechanism and 8192 bytes with other exception handling mechanisms should be adequate for most machines.
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.
一个栈帧的最大大小,以字节为单位。 GCC将生成探测指令在非叶子函数来确保栈中至少这么多大小的字节是可用的。 如果一个栈帧大于该大小,则栈检查将不可靠并且GCC将产生一个警告。缺省值被选择, 使得GCC只生成一条指令,在大多数系统上。你通常不应该修改该宏的缺省值。