]> Git Repo - linux.git/commitdiff
tools/nolibc: i386: add stackprotector support
authorThomas Weißschuh <[email protected]>
Sat, 25 Mar 2023 15:45:15 +0000 (16:45 +0100)
committerPaul E. McKenney <[email protected]>
Mon, 27 Mar 2023 23:26:10 +0000 (16:26 -0700)
Enable the new stackprotector support for i386.

Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
tools/include/nolibc/arch-i386.h
tools/testing/selftests/nolibc/Makefile

index e8d0cf545bf145db427191a75ac67fc599e6158c..2d98d78fd3f3a6459d7372dc51c65d1147b471ef 100644 (file)
@@ -181,6 +181,8 @@ struct sys_stat_struct {
 char **environ __attribute__((weak));
 const unsigned long *_auxv __attribute__((weak));
 
+#define __ARCH_SUPPORTS_STACK_PROTECTOR
+
 /* startup code */
 /*
  * i386 System V ABI mandates:
@@ -188,9 +190,12 @@ const unsigned long *_auxv __attribute__((weak));
  * 2) The deepest stack frame should be set to zero
  *
  */
-void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
+void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
 {
        __asm__ volatile (
+#ifdef NOLIBC_STACKPROTECTOR
+               "call __stack_chk_init\n"   // initialize stack protector
+#endif
                "pop %eax\n"                // argc   (first arg, %eax)
                "mov %esp, %ebx\n"          // argv[] (second arg, %ebx)
                "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
index e516e53775d4452b9513d557784d24b4d763d625..ab99786c1e94286505b2af8d8407637d95fb3a0e 100644 (file)
@@ -79,6 +79,7 @@ endif
 CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \
                        $(call cc-option,-mstack-protector-guard=global) \
                        $(call cc-option,-fstack-protector-all)
+CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR)
 CFLAGS_s390 = -m64
 CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables \
                $(call cc-option,-fno-stack-protector) \
This page took 0.089075 seconds and 4 git commands to generate.