From 8c6b93e0bd91da8538f064c4c0fcf09d17a6584a Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 19 May 2021 13:45:24 +0200 Subject: [PATCH] build(core): account for ARM unwinding info in memory layout Currently the 8-byte section is inserted under semi-random name like .ARM.exidx.text._ZN50_$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$4into17h79ccbc4bdfe3f200E. This makes it hard to include it in _codelen that is later baked into firmware header. This change adds new section because including it in .flash causes linker error due to mixing "ordered" and "unordered" sections. By renaming .exidx to /DISCARD/ we'd drop this info, there may also exist compiler flag to do that. --- core/embed/firmware/memory_1.ld | 9 +++++++-- core/embed/firmware/memory_1_min.ld | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/embed/firmware/memory_1.ld b/core/embed/firmware/memory_1.ld index abd745fd9..b4bb47f01 100644 --- a/core/embed/firmware/memory_1.ld +++ b/core/embed/firmware/memory_1.ld @@ -26,8 +26,7 @@ sram_end = ORIGIN(SRAM) + LENGTH(SRAM); _ram_start = sram_start; _ram_end = sram_end; -/* .ARM.exidx.text.__aeabi_ui2f is probably not needed as long as we are using panic = "abort" */ -_codelen = SIZEOF(.flash) + SIZEOF(.data) + SIZEOF(.ARM.exidx) + SIZEOF(.ARM.exidx.text.__aeabi_ui2f); +_codelen = SIZEOF(.flash) + SIZEOF(.data) + SIZEOF(.exidx); _flash_start = ORIGIN(FLASH); _flash_end = ORIGIN(FLASH) + LENGTH(FLASH); _heap_start = ADDR(.heap); @@ -47,6 +46,12 @@ SECTIONS { . = ALIGN(512); } >FLASH AT>FLASH + /* exception handling info generated by llvm which should consist of 8 bytes of "cantunwind" */ + .exidx : ALIGN(4) { + *(.ARM.exidx*); + . = ALIGN(4); + } >FLASH AT>FLASH + .data : ALIGN(4) { *(.data*); . = ALIGN(512); diff --git a/core/embed/firmware/memory_1_min.ld b/core/embed/firmware/memory_1_min.ld index 0a8ec38ac..b4bb47f01 100644 --- a/core/embed/firmware/memory_1_min.ld +++ b/core/embed/firmware/memory_1_min.ld @@ -26,8 +26,7 @@ sram_end = ORIGIN(SRAM) + LENGTH(SRAM); _ram_start = sram_start; _ram_end = sram_end; -/* .ARM.exidx.text.__aeabi_ui2f is probably not needed as long as we are using panic = "abort" */ -_codelen = SIZEOF(.flash) + SIZEOF(.data) + SIZEOF(.ARM.exidx.text.__aeabi_ui2f); +_codelen = SIZEOF(.flash) + SIZEOF(.data) + SIZEOF(.exidx); _flash_start = ORIGIN(FLASH); _flash_end = ORIGIN(FLASH) + LENGTH(FLASH); _heap_start = ADDR(.heap); @@ -47,6 +46,12 @@ SECTIONS { . = ALIGN(512); } >FLASH AT>FLASH + /* exception handling info generated by llvm which should consist of 8 bytes of "cantunwind" */ + .exidx : ALIGN(4) { + *(.ARM.exidx*); + . = ALIGN(4); + } >FLASH AT>FLASH + .data : ALIGN(4) { *(.data*); . = ALIGN(512);