[PATCH] Makefile: Enable warnings for excessive stack usage
Samuel Holland
samuel.holland at sifive.com
Wed Oct 14 04:36:38 PDT 2026
The default OpenSBI per-hart stack size is 4096 bytes
(SBI_PLATFORM_DEFAULT_HART_STACK_SIZE - SBI_SCRATCH_SIZE). Warn for any
function which uses over 25% of the stack, as this increases the risk
of a stack overflow. Currently only four functions have stack frames
larger than 10% of the default stack size when compiled with either gcc
or clang: fdt_parse_aplic_node(), fdt_reserved_memory_fixup(),
sbi_misaligned_v_ld_emulator(), and sbi_misaligned_v_st_emulator().
Signed-off-by: Samuel Holland <samuel.holland at sifive.com>
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index 90bf7d5d..12e2a837 100644
--- a/Makefile
+++ b/Makefile
@@ -385,6 +385,7 @@ GENFLAGS += $(platform-genflags-y)
GENFLAGS += $(firmware-genflags-y)
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections
+CFLAGS += -Wframe-larger-than=1024
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
CFLAGS += -std=gnu11
--
2.52.0
base-commit: 6ad246a1494807ee91e36ffcf60e4c30bb309d45
branch: up/stack-size
More information about the opensbi
mailing list