diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader index 1efe8e105..d09b1a4ef 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -102,6 +102,7 @@ env.Replace( '-fsingle-precision-constant -fdata-sections -ffunction-sections ' '-ffreestanding ' '-fstack-protector-all ' + '-flto=2 ' + env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD, CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS='-T embed/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common -Wl,--print-memory-usage', diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index 94a322261..360faf5aa 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -146,6 +146,7 @@ env.Replace( '-fsingle-precision-constant -fdata-sections -ffunction-sections ' '-ffreestanding ' '-fstack-protector-all ' + '-flto=2 ' + env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD, CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS='-T embed/bootloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader/bootloader.map -Wl,--warn-common -Wl,--print-memory-usage', diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 23d4959e7..23a05b698 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -434,6 +434,7 @@ env.Replace( '-fsingle-precision-constant -fdata-sections -ffunction-sections ' '-ffreestanding ' '-fstack-protector-all ' + '-flto=2 ' + env.get('ENV')["CPU_CCFLAGS"] + CCFLAGS_MOD, CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB', LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}%s.ld -Wl,--gc-sections -Wl,--print-memory-usage -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common' % LD_VARIANT, diff --git a/core/embed/trezorhal/stm32f4/common.c b/core/embed/trezorhal/stm32f4/common.c index 79ff1645c..58bc1f28c 100644 --- a/core/embed/trezorhal/stm32f4/common.c +++ b/core/embed/trezorhal/stm32f4/common.c @@ -188,7 +188,7 @@ void clear_otg_hs_memory(void) { uint32_t __stack_chk_guard = 0; -void __attribute__((noreturn)) __stack_chk_fail(void) { +void __attribute__((noreturn, used)) __stack_chk_fail(void) { error_shutdown("INTERNAL ERROR", "(SS)"); }