aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinyu Zhang <xinyu.zhang@arm.com>2021-06-04 15:17:26 +0800
committerKen Liu <ken.liu@arm.com>2021-06-18 10:43:11 +0200
commit5b095db8d1385818576a40fed66487ff9879b6a2 (patch)
tree9418d204219ddcef34d432e64e16e9136b94b249
parent3dee3651186b540d3d49568a2b3cfea819858554 (diff)
downloadtrusted-firmware-m-5b095db8d1385818576a40fed66487ff9879b6a2.tar.gz
Platform: Only put TF-M code to ER_TFM_CODE
The ER_TFM_CODE should only pick the real TF-M code, rather than anything that does not match any pattern. Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com> Change-Id: I13f8dba385c14fed06a4910d48859a25a0b5bd6f
-rw-r--r--platform/ext/common/armclang/tfm_common_s.sct25
-rw-r--r--platform/ext/common/armclang/tfm_isolation_l3.sct.template23
-rw-r--r--platform/ext/common/gcc/tfm_common_s.ld78
-rw-r--r--platform/ext/common/gcc/tfm_isolation_l3.ld.template31
-rw-r--r--toolchain_ARMCLANG.cmake2
5 files changed, 71 insertions, 88 deletions
diff --git a/platform/ext/common/armclang/tfm_common_s.sct b/platform/ext/common/armclang/tfm_common_s.sct
index c7d66b4b00..14f5ec1a0e 100644
--- a/platform/ext/common/armclang/tfm_common_s.sct
+++ b/platform/ext/common/armclang/tfm_common_s.sct
@@ -21,17 +21,14 @@ LR_CODE S_CODE_START S_CODE_SIZE {
/**** This initial section contains common code for secure binary */
ER_TFM_CODE S_CODE_START {
*.o (RESET +First)
- * (+RO)
+ *libplatform_s* (.text*, .rodata*)
+ *libtfm_spm* (+RO)
}
/**** Unprivileged Secure code start here */
TFM_UNPRIV_CODE +0 ALIGN 32 {
*(SFN)
- *armlib*
- *libtfm_sprt.a (+RO)
- *psa_client.* (+RO)
- *psa_service.* (+RO)
- *psa_lifecycle.* (+RO)
+ * (+RO)
}
/**** Section for holding partition RO load data */
@@ -48,8 +45,9 @@ LR_CODE S_CODE_START S_CODE_SIZE {
}
TFM_PSA_ROT_LINKER +0 ALIGN 32 {
- *tfm_psa_rot_partition* (+RO)
- *.o(TFM_*_PSA-ROT_ATTR_FN)
+ *tfm_psa_rot_partition* (+RO-CODE, +RO-DATA)
+ *libplatform_s* (TFM_*_PSA-ROT_ATTR_FN)
+ *.o (TFM_*_PSA-ROT_ATTR_FN)
}
/*
@@ -68,8 +66,9 @@ LR_CODE S_CODE_START S_CODE_SIZE {
}
TFM_APP_ROT_LINKER +0 ALIGN 32 {
- *tfm_app_rot_partition* (+RO)
- *.o(TFM_*_APP-ROT_ATTR_FN)
+ *tfm_app_rot_partition* (+RO-CODE, +RO-DATA)
+ *libplatform_s* (TFM_*_APP-ROT_ATTR_FN)
+ *.o (TFM_*_APP-ROT_ATTR_FN)
}
/*
@@ -82,9 +81,9 @@ LR_CODE S_CODE_START S_CODE_SIZE {
#if defined(S_CODE_SRAM_ALIAS_BASE)
/* eFlash driver code that gets copied from Flash to SRAM */
ER_CODE_SRAM S_CODE_SRAM_ALIAS_BASE ALIGN 4 {
- Driver_GFC100_EFlash.o (+RO)
- gfc100_eflash_drv.o (+RO)
- musca_b1_eflash_drv.o (+RO)
+ Driver_GFC100_EFlash.o (.text, .text.*, .rodata, .rodata.*)
+ gfc100_eflash_drv.o (.text, .text.*, .rodata, .rodata.*)
+ musca_b1_eflash_drv.o (.text, .text.*, .rodata, .rodata.*)
}
#endif
diff --git a/platform/ext/common/armclang/tfm_isolation_l3.sct.template b/platform/ext/common/armclang/tfm_isolation_l3.sct.template
index dcb67ae645..287c5a9b71 100644
--- a/platform/ext/common/armclang/tfm_isolation_l3.sct.template
+++ b/platform/ext/common/armclang/tfm_isolation_l3.sct.template
@@ -37,7 +37,8 @@ LR_CODE S_CODE_START {
/**** This initial section contains mainly the SPM code and RO-data */
ER_TFM_CODE +0 ALIGN 32 {
*.o (RESET +First)
- * (+RO)
+ *libtfm_spm* (+RO)
+ *libplatform_s* (+RO)
}
/**** Section for holding partition RO load data */
@@ -54,12 +55,12 @@ LR_CODE S_CODE_START {
ER_{{partition.manifest.name}}_RO +0 ALIGN 32 {
{% if partition.attr.linker_pattern.library_list %}
{% for pattern in partition.attr.linker_pattern.library_list %}
- {{pattern}} (+RO)
+ {{pattern}} (+RO-CODE, +RO-DATA)
{% endfor %}
{% endif %}
{% if partition.attr.linker_pattern.object_list %}
{% for pattern in partition.attr.linker_pattern.object_list %}
- {{pattern}} (+RO)
+ {{pattern}} (+RO-CODE, +RO-DATA)
{% endfor %}
{% endif %}
*({{partition.manifest.name}}_PSA-ROT_ATTR_FN)
@@ -81,12 +82,12 @@ LR_CODE S_CODE_START {
ER_{{partition.manifest.name}}_RO +0 ALIGN 32 {
{% if partition.attr.linker_pattern.library_list %}
{% for pattern in partition.attr.linker_pattern.library_list %}
- {{pattern}} (+RO)
+ {{pattern}} (+RO-CODE, +RO-DATA)
{% endfor %}
{% endif %}
{% if partition.attr.linker_pattern.object_list %}
{% for pattern in partition.attr.linker_pattern.object_list %}
- {{pattern}} (+RO)
+ {{pattern}} (+RO-CODE, +RO-DATA)
{% endfor %}
{% endif %}
*({{partition.manifest.name}}_APP-ROT_ATTR_FN)
@@ -102,11 +103,7 @@ LR_CODE S_CODE_START {
/**** Unprivileged Secure code + RO-data starts here */
TFM_UNPRIV_CODE +0 ALIGN 32 {
*(SFN)
- *armlib* (+RO)
- *libtfm_sprt.a (+RO)
- *psa_client.* (+RO)
- *psa_service.* (+RO)
- *psa_lifecycle.* (+RO)
+ * (+RO)
}
PT_RO_END +0 ALIGN 32 EMPTY 0x0 {
@@ -231,9 +228,9 @@ LR_CODE S_CODE_START {
#if defined(S_CODE_SRAM_ALIAS_BASE)
/* eFlash driver code that gets copied from Flash to SRAM */
ER_EFLASH_DRIVER_RO S_CODE_SRAM_ALIAS_BASE ALIGN 32 {
- Driver_GFC100_EFlash.o (+RO)
- gfc100_eflash_drv.o (+RO)
- musca_b1_eflash_drv.o (+RO)
+ Driver_GFC100_EFlash.o (+RO-CODE, +RO-DATA)
+ gfc100_eflash_drv.o (+RO-CODE, +RO-DATA)
+ musca_b1_eflash_drv.o (+RO-CODE, +RO-DATA)
}
#endif
}
diff --git a/platform/ext/common/gcc/tfm_common_s.ld b/platform/ext/common/gcc/tfm_common_s.ld
index 5cdb16cd37..f295abcfd0 100644
--- a/platform/ext/common/gcc/tfm_common_s.ld
+++ b/platform/ext/common/gcc/tfm_common_s.ld
@@ -119,28 +119,6 @@ SECTIONS
__zero_table_end__ = .;
} > FLASH
- .TFM_UNPRIV_CODE : ALIGN(32)
- {
- *libc_nano*:*(.text*)
- *libc_nano*:*(.rodata*)
- *(SFN)
- *libgcc*:*(.text*)
- *libgcc*:*(.rodata*)
- *libtfm_sprt*:*(.text*)
- *libtfm_sprt*:*(.rodata*)
- *psa_client.*(.text*) /* NXP */
- *psa_client.*(.rodata*)
- *psa_service.*(.text*) /* NXP */
- *psa_service.*(.rodata*)
- *psa_lifecycle.*(.text*) /* NXP */
- *psa_lifecycle.*(.rodata*)
- *tfm_log_raw.*(.text*) /* NXP */
- *tfm_log_raw.*(.rodata*)
- . = ALIGN(32);
- } > FLASH
- Image$$TFM_UNPRIV_CODE$$RO$$Base = ADDR(.TFM_UNPRIV_CODE);
- Image$$TFM_UNPRIV_CODE$$RO$$Limit = ADDR(.TFM_UNPRIV_CODE) + SIZEOF(.TFM_UNPRIV_CODE);
-
/**** Section for holding partition RO load data */
.TFM_SP_LOAD_LIST : ALIGN(4)
{
@@ -222,29 +200,11 @@ SECTIONS
.ER_TFM_CODE : ALIGN(4)
{
- *(.text*)
-
- KEEP(*(.init))
- KEEP(*(.fini))
-
-
- /* .ctors */
- *crtbegin.o(.ctors)
- *crtbegin?.o(.ctors)
- *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
- *(SORT(.ctors.*))
- *(.ctors)
+ *libplatform_s*:*(.text*)
+ *libtfm_spm*:*(.text*)
- /* .dtors */
- *crtbegin.o(.dtors)
- *crtbegin?.o(.dtors)
- *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
- *(SORT(.dtors.*))
- *(.dtors)
-
- *(.rodata*)
-
- KEEP(*(.eh_frame*))
+ *libplatform_s*:*(.rodata*)
+ *libtfm_spm*:*(.rodata*)
} > FLASH
/**** Base address of secure data area */
@@ -480,6 +440,36 @@ SECTIONS
/**** PSA RoT DATA end here */
Image$$TFM_PSA_RW_STACK_END$$Base = .;
+ .TFM_UNPRIV_CODE : ALIGN(32)
+ {
+ *(SFN)
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ . = ALIGN(32);
+ } > FLASH
+ Image$$TFM_UNPRIV_CODE$$RO$$Base = ADDR(.TFM_UNPRIV_CODE);
+ Image$$TFM_UNPRIV_CODE$$RO$$Limit = ADDR(.TFM_UNPRIV_CODE) + SIZEOF(.TFM_UNPRIV_CODE);
+
#ifdef RAM_VECTORS_SUPPORT
.ramVectors (NOLOAD) : ALIGN(256)
{
diff --git a/platform/ext/common/gcc/tfm_isolation_l3.ld.template b/platform/ext/common/gcc/tfm_isolation_l3.ld.template
index 4384256817..d781c07fb5 100644
--- a/platform/ext/common/gcc/tfm_isolation_l3.ld.template
+++ b/platform/ext/common/gcc/tfm_isolation_l3.ld.template
@@ -176,33 +176,24 @@ SECTIONS
{% endfor %}
/**** APPLICATION RoT RO CODE + data ends here */
- /**** Unprivileged Secure code starts here */
- .ER_UNPRIV_CODE : ALIGN(32)
+ .ER_TFM_CODE : ALIGN(4)
{
- *(SFN)
- *armlib*:*(.text*)
- *armlib*:*(.rodata*)
- *libtfm_sprt*:*(.text*)
- *libtfm_sprt*:*(.rodata*)
- *psa_client.*(.text*) /* NXP */
- *psa_client.*(.rodata*)
- *psa_service.*(.text*) /* NXP */
- *psa_service.*(.rodata*)
- *psa_lifecycle.*(.text*) /* NXP */
- *psa_lifecycle.*(.rodata*)
- . = ALIGN(32);
+ *libplatform_s*:*(.text*)
+ *libtfm_spm*:*(.text*)
+
+ *libplatform_s*:*(.rodata*)
+ *libtfm_spm*:*(.rodata*)
} > FLASH
- Image$$TFM_UNPRIV_CODE$$RO$$Base = ADDR(.ER_UNPRIV_CODE);
- Image$$TFM_UNPRIV_CODE$$RO$$Limit = ADDR(.ER_UNPRIV_CODE) + SIZEOF(.ER_UNPRIV_CODE);
- .ER_TFM_CODE : ALIGN(4)
+ /**** Unprivileged Secure code starts here */
+ .ER_UNPRIV_CODE : ALIGN(32)
{
+ *(SFN)
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
-
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
@@ -220,7 +211,11 @@ SECTIONS
*(.rodata*)
KEEP(*(.eh_frame*))
+
+ . = ALIGN(32);
} > FLASH
+ Image$$TFM_UNPRIV_CODE$$RO$$Base = ADDR(.ER_UNPRIV_CODE);
+ Image$$TFM_UNPRIV_CODE$$RO$$Limit = ADDR(.ER_UNPRIV_CODE) + SIZEOF(.ER_UNPRIV_CODE);
/* Position tag */
. = ALIGN(32);
diff --git a/toolchain_ARMCLANG.cmake b/toolchain_ARMCLANG.cmake
index 43bf595a41..97e1b4f639 100644
--- a/toolchain_ARMCLANG.cmake
+++ b/toolchain_ARMCLANG.cmake
@@ -69,6 +69,8 @@ macro(tfm_toolchain_reset_linker_flags)
--diag_suppress=6314
# Duplicate input files
--diag_suppress=6304
+ # Pattern only matches removed unused sections.
+ --diag_suppress=6329
$<$<NOT:$<BOOL:${TFM_SYSTEM_FP}>>:--fpu=softvfp>
)
endmacro()