]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Fix stack-protector for powerpc
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 15 Nov 2023 18:36:36 +0000 (19:36 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 29 Nov 2023 14:32:15 +0000 (09:32 -0500)
On powerpc, stack protector expects a function called
__stack_chk_fail_local() instead of __stack_chk_fail()

And some versions of GCC for powerpc default to TLS canary
instead of global canary, so always force GCC to use global
canary with -mstack-protector-guard=global

Cc: Joel Peshkin <joel.peshkin@broadcom.com>
Fixes: 4e9bce12432 ("Add support for stack-protector")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Makefile
common/stackprot.c

index ffeb722c10721daf7dd5a79d1f6da3504a8e9ebc..1b347f4dfd836c3ce07abd7fb1e19fe875dcbf44 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -750,6 +750,7 @@ endif
 
 ifeq ($(CONFIG_STACKPROTECTOR),y)
 KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong)
+KBUILD_CFLAGS += $(call cc-option,-mstack-protector-guard=global)
 CFLAGS_EFI += $(call cc-option,-fno-stack-protector)
 else
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
index d5b70616655a6d274a7c814f0fcd940b9292f8c9..6495951a773c5bf71c7d06576034024049692911 100644 (file)
@@ -18,3 +18,8 @@ void __stack_chk_fail(void)
        panic("Stack smashing detected in function:\n%p relocated from %p",
              ra, ra - gd->reloc_off);
 }
+
+void __stack_chk_fail_local(void)
+{
+       __stack_chk_fail();
+}