Skip to content

Commit

Permalink
projmgr: Fix linker script templates for Armv8-M TrustZone
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Jul 14, 2023
1 parent 6164c95 commit 31ef1c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
29 changes: 13 additions & 16 deletions tools/projmgr/templates/ac6_linker_script.sct
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
Stack seal size definition
*----------------------------------------------------------------------------*/
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#define __STACKSEAL_SIZE ( 8 )
#define __STACKSEAL_SIZE 8
#else
#define __STACKSEAL_SIZE ( 0 )
#define __STACKSEAL_SIZE 0
#endif

/*----------------------------------------------------------------------------
Expand All @@ -31,26 +31,23 @@

LR_ROM0 __ROM0_BASE __ROM0_SIZE {

#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
ER_CMSE_VENEER __ROM0_BASE+__ROM0_SIZE -__ROM0_SIZE {
*(Veneer$$CMSE)
ER_ROM0 __ROM0_BASE __ROM0_SIZE {
*.o (RESET, +First)
*(InRoot$$Sections)
*(+RO +XO)
}
#define ER_CMSE_VENEER_SIZE AlignExpr(ImageLength(ER_CMSE_VENEER), 8)
#else
#define ER_CMSE_VENEER_SIZE 0
#endif

ER_ROM0 __ROM0_BASE (__ROM0_SIZE - ER_CMSE_VENEER_SIZE) {
*.o (RESET, +First)
*(InRoot$$Sections)
*(+RO +XO)
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
ER_CMSE_VENEER AlignExpr(+0, 32) (__ROM0_SIZE - AlignExpr(ImageLength(ER_ROM0), 32)) {
*(Veneer$$CMSE)
}
#endif

RW_NOINIT __RAM0_BASE UNINIT (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE) {
RW_NOINIT __RAM0_BASE UNINIT (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE) {
*(.bss.noinit)
}

RW_RAM0 AlignExpr(+0, 8) (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) {
RW_RAM0 AlignExpr(+0, 8) (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) {
*(+RW +ZI)
}

Expand All @@ -63,7 +60,7 @@ LR_ROM0 __ROM0_BASE __ROM0_SIZE {
}

#if __STACKSEAL_SIZE > 0
STACKSEAL +0 EMPTY 8 { ; Reserve empty region for stack seal immediately after stack
STACKSEAL +0 EMPTY __STACKSEAL_SIZE { ; Reserve empty region for stack seal immediately after stack
}
#endif

Expand Down
10 changes: 9 additions & 1 deletion tools/projmgr/templates/clang_linker_script.ld
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ SECTIONS

} >ROM0 AT>ROM0 :text

#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
.veneers :
{
. = ALIGN(32);
KEEP(*(.gnu.sgstubs))
} > ROM0 AT>ROM0 :text
#endif

.toc : {
*(.toc .toc.*)
} >ROM0 AT>ROM0 :text
Expand Down Expand Up @@ -277,7 +285,7 @@ SECTIONS
} >RAM0 :ram

#if __STACKSEAL_SIZE > 0
PROVIDE(__stack_seal = __stack)
PROVIDE(__stack_seal = __stack);
.stackseal (__stack) (NOLOAD) :
{
. += __STACKSEAL_SIZE;
Expand Down

0 comments on commit 31ef1c4

Please sign in to comment.