aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2019-08-02 06:50:04 +0000
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2019-08-02 06:50:04 +0000
commit4c213e5eb22269da1a92b53c01a91e8f36439a0e (patch)
tree40a8030578f1abbb33633c3783e26cdb6c94e4a3
parentf70889bee012047998ec9fd0942eca9f99120c67 (diff)
parentee3e7cd720887077ad27f48f4c8e681926c16587 (diff)
downloadtf-a-tests-4c213e5eb22269da1a92b53c01a91e8f36439a0e.tar.gz
Merge "ld: Separate code and RO data sections"
-rw-r--r--fwu/ns_bl1u/ns_bl1u.ld.S19
-rw-r--r--fwu/ns_bl2u/ns_bl2u.ld.S17
-rw-r--r--plat/arm/fvp/include/platform_def.h4
-rw-r--r--plat/arm/juno/include/platform_def.h4
-rw-r--r--plat/common/plat_common.c50
-rw-r--r--tftf/framework/tftf.ld.S15
-rw-r--r--tftf/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c8
7 files changed, 73 insertions, 44 deletions
diff --git a/fwu/ns_bl1u/ns_bl1u.ld.S b/fwu/ns_bl1u/ns_bl1u.ld.S
index 2ca5292c5..52d80deab 100644
--- a/fwu/ns_bl1u/ns_bl1u.ld.S
+++ b/fwu/ns_bl1u/ns_bl1u.ld.S
@@ -12,22 +12,29 @@ OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
ENTRY(ns_bl1u_entrypoint)
MEMORY {
- ROM (rx): ORIGIN = NS_BL1U_RO_BASE, LENGTH = NS_BL1U_RO_LIMIT - NS_BL1U_RO_BASE
+ ROM (rx): ORIGIN = NS_BL1U_BASE, LENGTH = NS_BL1U_RO_LIMIT - NS_BL1U_BASE
RAM (rwx): ORIGIN = NS_BL1U_RW_BASE, LENGTH = NS_BL1U_RW_LIMIT - NS_BL1U_RW_BASE
}
SECTIONS
{
- . = NS_BL1U_RO_BASE;
+ . = NS_BL1U_BASE;
ASSERT(. == ALIGN(PAGE_SIZE),
- "NS_BL1U_RO_BASE address is not aligned on a page boundary.")
+ "NS_BL1U_BASE address is not aligned on a page boundary.")
- ro . : {
- __RO_START__ = .;
+ .text . : {
+ __TEXT_START__ = .;
*ns_bl1u_entrypoint.o(.text*)
*(.text*)
+ . = ALIGN(PAGE_SIZE);
+ __TEXT_END__ = .;
+ } >ROM
+
+ .rodata . : {
+ __RODATA_START__ = .;
*(.rodata*)
- __RO_END__ = .;
+ . = ALIGN(PAGE_SIZE);
+ __RODATA_END__ = .;
} >ROM
/*
diff --git a/fwu/ns_bl2u/ns_bl2u.ld.S b/fwu/ns_bl2u/ns_bl2u.ld.S
index 48af3036b..a6c6d2e88 100644
--- a/fwu/ns_bl2u/ns_bl2u.ld.S
+++ b/fwu/ns_bl2u/ns_bl2u.ld.S
@@ -21,20 +21,25 @@ SECTIONS
ASSERT(. == ALIGN(PAGE_SIZE),
"NS_BL2U_BASE address is not aligned on a page boundary.")
- ro . : {
- __RO_START__ = .;
+ .text . : {
+ __TEXT_START__ = .;
*ns_bl2u_entrypoint.o(.text*)
*(.text*)
- *(.rodata*)
*(.vectors)
- __RO_END_UNALIGNED__ = .;
+ . = ALIGN(PAGE_SIZE);
+ __TEXT_END__ = .;
+ } >RAM
+
+ .rodata . : {
+ __RODATA_START__ = .;
+ *(.rodata*)
/*
* Memory page(s) mapped to this section will be marked as
- * read-only, executable. No RW data from the next section must
+ * read-only, non-executable. No RW data from the next section must
* creep in. Ensure the rest of the current memory page is unused.
*/
. = ALIGN(PAGE_SIZE);
- __RO_END__ = .;
+ __RODATA_END__ = .;
} >RAM
.data . : {
diff --git a/plat/arm/fvp/include/platform_def.h b/plat/arm/fvp/include/platform_def.h
index 31b012a4e..4f64079f1 100644
--- a/plat/arm/fvp/include/platform_def.h
+++ b/plat/arm/fvp/include/platform_def.h
@@ -70,8 +70,8 @@
* NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
* need 2 sets of addresses.
******************************************************************************/
-#define NS_BL1U_RO_BASE (0x08000000 + 0x03EB8000)
-#define NS_BL1U_RO_LIMIT (NS_BL1U_RO_BASE + 0xC000)
+#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
+#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
/*******************************************************************************
* Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
diff --git a/plat/arm/juno/include/platform_def.h b/plat/arm/juno/include/platform_def.h
index 682866c79..4be864595 100644
--- a/plat/arm/juno/include/platform_def.h
+++ b/plat/arm/juno/include/platform_def.h
@@ -81,8 +81,8 @@
* NS_BL1U RW data is relocated from NS-ROM to NS-RAM at runtime so we
* need 2 sets of addresses.
******************************************************************************/
-#define NS_BL1U_RO_BASE (0x08000000 + 0x03EB8000)
-#define NS_BL1U_RO_LIMIT (NS_BL1U_RO_BASE + 0xC000)
+#define NS_BL1U_BASE (0x08000000 + 0x03EB8000)
+#define NS_BL1U_RO_LIMIT (NS_BL1U_BASE + 0xC000)
/*******************************************************************************
* Put NS_BL1U RW at the top of the Non-Trusted SRAM. NS_BL1U_RW_BASE is
diff --git a/plat/common/plat_common.c b/plat/common/plat_common.c
index c5f4592c7..4cfbebbf3 100644
--- a/plat/common/plat_common.c
+++ b/plat/common/plat_common.c
@@ -27,32 +27,40 @@
#if IMAGE_TFTF
-#define IMAGE_RO_BASE TFTF_BASE
-IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END);
+#define IMAGE_TEXT_BASE TFTF_BASE
+IMPORT_SYM(uintptr_t, __TEXT_END__, IMAGE_TEXT_END);
-#define IMAGE_RW_BASE IMAGE_RO_END
-IMPORT_SYM(uintptr_t, __TFTF_END__, IMAGE_RW_END);
+#define IMAGE_RODATA_BASE IMAGE_TEXT_END
+IMPORT_SYM(uintptr_t, __RODATA_END__, IMAGE_RODATA_END);
-IMPORT_SYM(uintptr_t, __COHERENT_RAM_START__, COHERENT_RAM_START);
-IMPORT_SYM(uintptr_t, __COHERENT_RAM_END__, COHERENT_RAM_END);
+#define IMAGE_RW_BASE IMAGE_RODATA_END
+IMPORT_SYM(uintptr_t, __TFTF_END__, IMAGE_RW_END);
+
+IMPORT_SYM(uintptr_t, __COHERENT_RAM_START__, COHERENT_RAM_START);
+IMPORT_SYM(uintptr_t, __COHERENT_RAM_END__, COHERENT_RAM_END);
#elif IMAGE_NS_BL1U
-IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END_UNALIGNED);
-#define IMAGE_RO_BASE NS_BL1U_RO_BASE
-#define IMAGE_RO_END round_up(IMAGE_RO_END_UNALIGNED, PAGE_SIZE)
+#define IMAGE_TEXT_BASE NS_BL1U_BASE
+IMPORT_SYM(uintptr_t, __TEXT_END__, IMAGE_TEXT_END);
+
+#define IMAGE_RODATA_BASE IMAGE_TEXT_END
+IMPORT_SYM(uintptr_t, __RODATA_END__, IMAGE_RODATA_END);
-#define IMAGE_RW_BASE NS_BL1U_RW_BASE
-IMPORT_SYM(uintptr_t, __NS_BL1U_RAM_END__, IMAGE_RW_END);
+#define IMAGE_RW_BASE NS_BL1U_RW_BASE
+IMPORT_SYM(uintptr_t, __NS_BL1U_RAM_END__, IMAGE_RW_END);
#elif IMAGE_NS_BL2U
-#define IMAGE_RO_BASE NS_BL2U_BASE
-IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END);
+#define IMAGE_TEXT_BASE NS_BL2U_BASE
+IMPORT_SYM(uintptr_t, __TEXT_END__, IMAGE_TEXT_END);
-#define IMAGE_RW_BASE IMAGE_RO_END
-IMPORT_SYM(uintptr_t, __NS_BL2U_END__, IMAGE_RW_END_UNALIGNED);
-#define IMAGE_RW_END round_up(IMAGE_RW_END_UNALIGNED, PAGE_SIZE)
+#define IMAGE_RODATA_BASE IMAGE_TEXT_END
+IMPORT_SYM(uintptr_t, __RODATA_END__, IMAGE_RODATA_END);
+
+#define IMAGE_RW_BASE IMAGE_RODATA_END
+IMPORT_SYM(uintptr_t, __NS_BL2U_END__, IMAGE_RW_END_UNALIGNED);
+#define IMAGE_RW_END round_up(IMAGE_RW_END_UNALIGNED, PAGE_SIZE)
#endif
@@ -78,9 +86,13 @@ void tftf_platform_watchdog_reset(void)
void tftf_plat_configure_mmu(void)
{
- /* RO data + Code */
- mmap_add_region(IMAGE_RO_BASE, IMAGE_RO_BASE,
- IMAGE_RO_END - IMAGE_RO_BASE, MT_CODE);
+ /* Code */
+ mmap_add_region(IMAGE_TEXT_BASE, IMAGE_TEXT_BASE,
+ IMAGE_TEXT_END - IMAGE_TEXT_BASE, MT_CODE);
+
+ /* RO data */
+ mmap_add_region(IMAGE_RODATA_BASE, IMAGE_RODATA_BASE,
+ IMAGE_RODATA_END - IMAGE_RODATA_BASE, MT_RO_DATA);
/* Data + BSS */
mmap_add_region(IMAGE_RW_BASE, IMAGE_RW_BASE,
diff --git a/tftf/framework/tftf.ld.S b/tftf/framework/tftf.ld.S
index 9432a7484..364753fe9 100644
--- a/tftf/framework/tftf.ld.S
+++ b/tftf/framework/tftf.ld.S
@@ -21,20 +21,25 @@ SECTIONS
. = TFTF_BASE;
__TFTF_BASE__ = .;
- ro . : {
- __RO_START__ = .;
+ .text . : {
+ __TEXT_START__ = .;
*entrypoint.o(.text*)
*(.text*)
- *(.rodata*)
*(.vectors)
- __RO_END_UNALIGNED__ = .;
+ . = NEXT(PAGE_SIZE);
+ __TEXT_END__ = .;
+ } >RAM
+
+ .rodata . : {
+ __RODATA_START__ = .;
+ *(.rodata*)
/*
* Memory page(s) mapped to this section will be marked as
* read-only, executable. No RW data from the next section must
* creep in. Ensure the rest of the current memory page is unused.
*/
. = NEXT(PAGE_SIZE);
- __RO_END__ = .;
+ __RODATA_END__ = .;
} >RAM
.data : {
diff --git a/tftf/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c b/tftf/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c
index afb352b4d..748c81767 100644
--- a/tftf/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c
+++ b/tftf/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c
@@ -47,10 +47,10 @@ static volatile unsigned int sgi_handled[PLATFORM_CORE_COUNT];
static sgi_data_t sgi_data;
static volatile int cpu_ref_count;
-extern unsigned long __RO_START__;
-#define TFTF_RO_START (unsigned long)(&__RO_START__)
-extern unsigned long __RO_END__;
-#define TFTF_RO_END (unsigned long)(&__RO_END__)
+extern unsigned long __TEXT_START__;
+#define TFTF_RO_START (unsigned long)(&__TEXT_START__)
+extern unsigned long __RODATA_END__;
+#define TFTF_RO_END (unsigned long)(&__RODATA_END__)
static int suspend_wakeup_handler(void *data)
{