Red zone (computing)
In computing, the red zone is a fixed-size area in a function's stack frame below (for a push-down stack) the current stack pointer that is reserved and safe to use. It is most commonly used in leaf functions (functions that don't call other functions) for allocating additional stack memory, without moving the stack pointer, which saves an instruction.
Whether a red zone is present depends on the calling convention. 64 bit systems that use System V AMD64 ABI (including Linux and macOS) and OpenRISC use a red zone. Microsoft Windows does not use a red zone.
The red zone is safe from modification by interrupt/exception/signal handlers.
The x86-64 ABI used by System V mandates a 128-byte red zone,[1][2] which begins directly under the current value of the stack pointer. The OpenRISC toolchain assumes a 128-byte red zone.[3]
Notes and references
- Michael Matz; Jan Hubička; Andreas Jaeger; et al., eds. (2018-01-28). "System V Application Binary Interface: AMD64 Architecture Processor Supplement (With LP64 and ILP32 Programming Models) Version 1.0" (PDF). 1.0.
- "i386 and x86-64 Options - Using the GNU Compiler Collection (GCC)". Retrieved 2011-04-10.
- "OpenCores Wiki - OpenRISC GNU toolchain". Retrieved 2014-05-28.