From f0f44cdb69c16842cec5c8b0716edeff214eebf6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 16 Apr 2025 22:03:48 -0600 Subject: [PATCH] kboot: Save the upper limit of the call stack. The location of argc argument is a fine limit for the extent of the stack traceback. We could save the location of return address for the call to _start_c, but we'd have to move that into MD assembler. While not hard, it wouldn't improve the traces we can get. And the math to find it is architecture dependent (though the same for both arm64 and amd64). Sponsored by: Netflix Reviewed by: kevans, andrew, jhibbits Differential Revision: https://reviews.freebsd.org/D49858 --- stand/kboot/libkboot/crt1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stand/kboot/libkboot/crt1.c b/stand/kboot/libkboot/crt1.c index 2fbe00262da..67ddacccfd2 100644 --- a/stand/kboot/libkboot/crt1.c +++ b/stand/kboot/libkboot/crt1.c @@ -57,6 +57,8 @@ extern int main(int, const char **, char **); #include "start_arch.h" +void *stack_upper_limit; + void _start_c(long *p) { @@ -64,6 +66,7 @@ _start_c(long *p) const char **argv; char **envp; + stack_upper_limit = p; /* Save the upper limit of call stack */ argc = p[0]; argv = (const char **)(p + 1); envp = (char **)argv + argc + 1;