Add compile flags to disable the red zone optimization

This commit is contained in:
Ruize Tang
2024-11-21 19:14:52 +08:00
committed by Tate, Hongliang Tian
parent 81898362b6
commit 5f35189a51

View File

@ -213,6 +213,11 @@ fn build_kernel_elf(
// This is to let rustc know that "cfg(ktest)" is our well-known configuration.
// See the [Rust Blog](https://blog.rust-lang.org/2024/05/06/check-cfg.html) for details.
"--check-cfg cfg(ktest)",
// The red zone is a small area below the stack pointer for optimization, primarily in
// user-space applications. This optimization can be problematic in the kernel, as the CPU
// or exception handlers may overwrite kernel data in the red zone. Therefore, we disable
// this optimization.
"-C no-redzone=y",
]);
if matches!(arch, Arch::X86_64) {