GNU Compiler Collection (GCC) Internals: Stack Smashing Protection

Previous: Tail Calls, Up: Stack and Calling [Contents][Index]

#### 17.10.14 Stack smashing protection

Target Hook: tree TARGET_STACK_PROTECT_GUARD (void)

  This hook returns a `DECL` node for the external variable to use for the stack protection guard. This variable is initialized by the runtime to some random value and is used to initialize the guard value that is placed at the top of the local stack frame. The type of this variable must be `ptr_type_node`.

  The default version of this hook creates a variable called ‘`__stack_chk_guard`’, which is normally defined in `libgcc2.c`.

Target Hook: tree TARGET_STACK_PROTECT_FAIL (void)

  This hook returns a `CALL_EXPR` that alerts the runtime that the stack protect guard variable has been modified. This expression should involve a call to a `noreturn` function.

  The default version of this hook invokes a function called ‘`__stack_chk_fail`’, taking no arguments. This function is normally defined in `libgcc2.c`.

Common Target Hook: bool TARGET_SUPPORTS_SPLIT_STACK (bool report, struct gcc_options *opts)

  Whether this target supports splitting the stack when the options described in opts have been passed. 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 report is true, this function may issue a warning or error; if report is false, it must simply return a value