Skip to content

Commit

Permalink
build(core): account for ARM unwinding info in memory layout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mmilata committed May 21, 2021
1 parent 20fe855 commit 8c6b93e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions core/embed/firmware/memory_1.ld
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions core/embed/firmware/memory_1_min.ld
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 8c6b93e

Please sign in to comment.