[PATCH 2/2] tools/nolibc: Don't use stack protector before setting it up

From: Daniel Palmer

Date: Sat Apr 25 2026 - 07:13:32 EST


The stack protector is configured in _start_c() so we shouldn't
use it before then.

Add __nolibc_no_stack_protector to _start_c() to avoid the compiler
generating stack protector code for _start_c() and thus using it
before its configured.

Signed-off-by: Daniel Palmer <daniel@xxxxxxxxx>
---
tools/include/nolibc/crt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h
index d8ce91fd2e3b..0fe0a066d15a 100644
--- a/tools/include/nolibc/crt.h
+++ b/tools/include/nolibc/crt.h
@@ -47,7 +47,7 @@ char *__nolibc_program_invocation_short_name(char *long_name)
#endif /* NOLIBC_IGNORE_ERRNO */

void _start_c(long *sp);
-__attribute__((weak,used)) __nolibc_no_sanitize_undefined
+__attribute__((weak, used)) __nolibc_no_sanitize_undefined __nolibc_no_stack_protector
void _start_c(long *sp)
{
long argc;
--
2.53.0