Pass -mno-red-zone to gcc to be compatible with the UEFI ABI

gcc by default outputs code using the SysV AMD64 ABI.  We need to pass
-mno-red-zone to ensure compatibility with the Microsoft ABI, which is
what UEFI uses.

Matthew Garrett explains,

    "The red zone is part of the AMD64 System V ABI and consists of
    128 bytes at the bottom of the stack frame. This region is
    guaranteed to be left untouched by any interrupt or signal
    handlers, so it's available for functions to use as scratch
    space. UEFI uses the Microsoft AMD64 ABI rather than the System V
    one, and the Microsoft ABI doesn't define a red zone. UEFI
    executables built on Linux tend to use System V because that means
    we can link in static libraries built for Linux, rather than
    needing an entirely separate toolchain and libraries to build UEFI
    executables. The problem arises when we run one of these
    executables and there's a UEFI interrupt handler still
    running. Take an interrupt, Microsoft ABI interrupt handler gets
    called and the red zone gets overwritten."

Signed-off-by: Steve Langasek <>
Cc: Matthew Garrett <>
Signed-off-by: Matt Fleming <>
1 file changed