diff --git a/core/embed/lib/error_handling.c b/core/embed/lib/error_handling.c index 266df4f59..1f2231760 100644 --- a/core/embed/lib/error_handling.c +++ b/core/embed/lib/error_handling.c @@ -38,6 +38,14 @@ #define COLOR_FATAL_ERROR COLOR_BLACK #endif +uint32_t __stack_chk_guard = 0; + +// Calls to this function are inserted by the compiler +// when stack protection is enabled. +void __attribute__((noreturn, used)) __stack_chk_fail(void) { + error_shutdown("(SS)"); +} + void __attribute__((noreturn)) error_shutdown_ex(const char *title, const char *message, const char *footer) { if (title == NULL) { diff --git a/core/embed/trezorhal/stm32f4/common.c b/core/embed/trezorhal/stm32f4/common.c index 327344525..339de0638 100644 --- a/core/embed/trezorhal/stm32f4/common.c +++ b/core/embed/trezorhal/stm32f4/common.c @@ -36,12 +36,6 @@ #include "backlight_pwm.h" #endif -uint32_t __stack_chk_guard = 0; - -void __attribute__((noreturn)) __stack_chk_fail(void) { - error_shutdown("(SS)"); -} - // reference RM0090 section 35.12.1 Figure 413 #define USB_OTG_HS_DATA_FIFO_RAM (USB_OTG_HS_PERIPH_BASE + 0x20000U) #define USB_OTG_HS_DATA_FIFO_SIZE (4096U) diff --git a/core/embed/trezorhal/stm32u5/common.c b/core/embed/trezorhal/stm32u5/common.c index b6e189b0b..abf3d943f 100644 --- a/core/embed/trezorhal/stm32u5/common.c +++ b/core/embed/trezorhal/stm32u5/common.c @@ -32,12 +32,6 @@ #include "stm32u5xx_ll_utils.h" -uint32_t __stack_chk_guard = 0; - -void __attribute__((noreturn)) __stack_chk_fail(void) { - error_shutdown("(SS)"); -} - void invalidate_firmware(void) { // on stm32u5, we need to disable the instruction cache before erasing the // firmware - otherwise, the write check will fail