kernel: add stack canary to libc partition
User mode needs to be able to read this value in
compiler generated function prologues/epilogues.
Special handling in init.c for arches that use
_data_copy. This happens before _Cstart() gets
called. We need to make sure that the compiler
stack canary checks in _data_copy itself do not
fail.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
diff --git a/kernel/compiler_stack_protect.c b/kernel/compiler_stack_protect.c
index b7d12bb..5f20ad2 100644
--- a/kernel/compiler_stack_protect.c
+++ b/kernel/compiler_stack_protect.c
@@ -22,6 +22,7 @@
#include <toolchain.h>
#include <linker/sections.h>
#include <kernel.h>
+#include <app_memory/app_memdomain.h>
/**
*
@@ -45,7 +46,11 @@
* Symbol referenced by GCC compiler generated code for canary value.
* The canary value gets initialized in _Cstart().
*/
-void __noinit *__stack_chk_guard;
+#ifdef CONFIG_APP_SHARED_MEM
+K_APP_DMEM(z_libc_partition) uintptr_t __stack_chk_guard;
+#else
+__noinit uintptr_t __stack_chk_guard;
+#endif
/**
*