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.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2022-12-15 15:52:37 -08:00 committed by Anas Nashif
parent 74b94b4dff
commit 52f570b200

View file

@ -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_ */