1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 19:08:12 +00:00

startup: setup the stack protector for the stage before main function (#46)

This commit is contained in:
mcudev 2017-10-14 06:25:13 -04:00 committed by Pavol Rusnak
parent 4c9e2d45a5
commit 70594a9bfe
6 changed files with 15 additions and 3 deletions

View File

@ -122,7 +122,6 @@ static const uint8_t * const BOARDLOADER_KEYS[] = {
int main(void)
{
__stack_chk_guard = rng_get();
#if PRODUCTION
flash_set_option_bytes();

View File

@ -47,6 +47,11 @@ reset_handler:
ldr r2, =data_size // size in bytes
bl memcpy
// setup the stack protector (see build script "-fstack-protector-all") with an unpredictable value
bl rng_get
ldr r1, = __stack_chk_guard
str r0, [r1]
// enter the application code
bl main

View File

@ -183,7 +183,6 @@ void check_bootloader_version(void)
int main(void)
{
__stack_chk_guard = rng_get();
#if PRODUCTION
check_bootloader_version();

View File

@ -22,6 +22,11 @@ reset_handler:
ldr r2, =data_size // size in bytes
bl memcpy
// setup the stack protector (see build script "-fstack-protector-all") with an unpredictable value
bl rng_get
ldr r1, = __stack_chk_guard
str r0, [r1]
// re-enable exceptions
// according to "ARM Cortex-M Programming Guide to Memory Barrier Instructions" Application Note 321, section 4.7:
// "If it is not necessary to ensure that a pended interrupt is recognized immediately before

View File

@ -23,7 +23,6 @@
int main(void)
{
__stack_chk_guard = rng_get();
periph_init();

View File

@ -22,6 +22,11 @@ reset_handler:
ldr r2, =data_size // size in bytes
bl memcpy
// setup the stack protector (see build script "-fstack-protector-all") with an unpredictable value
bl rng_get
ldr r1, = __stack_chk_guard
str r0, [r1]
// re-enable exceptions
// according to "ARM Cortex-M Programming Guide to Memory Barrier Instructions" Application Note 321, section 4.7:
// "If it is not necessary to ensure that a pended interrupt is recognized immediately before