toolchain: add macro FUNC_NO_STACK_PROTECTOR
This provides a macro to disable stack protector for a function,
by specifying a function attribute. This is useful for boot
and early init code where we know for sure stack pointer and/or
stack content are being manipulated manually.
@@ -625,5 +625,16 @@ do { \
#define __noasan /**/
#endif
+/**
+ * @brief Function attribute to disable stack protector.
+ *
+ * @note Only supported for GCC >= 11.0.0 or Clang >= 7.
+ */
+#if (TOOLCHAIN_GCC_VERSION >= 110000) || (TOOLCHAIN_CLANG_VERSION >= 70000)
+#define FUNC_NO_STACK_PROTECTOR __attribute__((no_stack_protector))
+#else
+#define FUNC_NO_STACK_PROTECTOR
+#endif
+
#endif /* !_LINKER */
#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_ */
