tools/nolibc: arm: add stackprotector support
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 17 Apr 2023 16:01:34 +0000 (18:01 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 9 Jun 2023 18:46:08 +0000 (11:46 -0700)
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/arch-arm.h
tools/testing/selftests/nolibc/Makefile

index 2eab1aef321bf1d0f031efd3aab6e7746c2ad6d1..202e64f537dca112cedc7c3fdad36afaee4bb7d9 100644 (file)
@@ -199,10 +199,15 @@ struct sys_stat_struct {
 char **environ __attribute__((weak));
 const unsigned long *_auxv __attribute__((weak));
 
+#define __ARCH_SUPPORTS_STACK_PROTECTOR
+
 /* startup code */
-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
+               "bl __stack_chk_init\n"       /* initialize stack protector                          */
+#endif
                "pop {%r0}\n"                 /* argc was in the stack                               */
                "mov %r1, %sp\n"              /* argv = sp                                           */
 
index fa0075479a26bef5a6641819fd114339f1121674..7585035cbb0db5e9651a7c518393fa93000fb447 100644 (file)
@@ -83,6 +83,7 @@ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR)
 CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR)
 CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR)
 CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR)
+CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR)
 CFLAGS_s390 = -m64
 CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \
                $(call cc-option,-fno-stack-protector) \