From ec980179bc120159874b5f2360c7400eec243d59 Mon Sep 17 00:00:00 2001 From: Alessandro Angelino Date: Wed, 6 Apr 2016 16:16:04 +0100 Subject: [PATCH] Add uVisor-specific sections to linker script --- .../TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld | 74 ++++++++++++++++++- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/hal/targets/cmsis/TARGET_Freescale/TARGET_MCU_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld b/hal/targets/cmsis/TARGET_Freescale/TARGET_MCU_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld index 95e92bb921..453ea6f284 100644 --- a/hal/targets/cmsis/TARGET_Freescale/TARGET_MCU_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld +++ b/hal/targets/cmsis/TARGET_Freescale/TARGET_MCU_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld @@ -55,8 +55,41 @@ SECTIONS . = ALIGN(4); } > FLASH_PROTECTION + /* Ensure that the uVisor .bss is the first section in the public SRAM. */ + .uvisor.bss (NOLOAD): + { + . = ALIGN(32); + __uvisor_bss_start = .; + + /* uVisor main .bss (protected) */ + . = ALIGN(32); + __uvisor_bss_main_start = .; + KEEP(*(.keep.uvisor.bss.main)) + . = ALIGN(32); + __uvisor_bss_main_end = .; + + /* Secure boxes .bss (protected) */ + . = ALIGN(32); + __uvisor_bss_boxes_start = .; + KEEP(*(.keep.uvisor.bss.boxes)) + . = ALIGN(32); + __uvisor_bss_boxes_end = .; + + . = ALIGN(32); + __uvisor_bss_end = .; + } > RAM + .text : { + /* uVisor code and data */ + /* Note: This is the location of the uVisor binary in flash. Make sure + * this position correspond to the FLASH_OFFSET set in the uVisor + * configuration. */ + . = ALIGN(4); + __uvisor_main_start = .; + *(.uvisor.main) + __uvisor_main_end = .; + *(.text*) KEEP(*(.init)) @@ -93,10 +126,10 @@ SECTIONS } > FLASH __exidx_end = .; - __etext = .; - - .data : AT (__etext) + .data : { + PROVIDE( __etext = LOADADDR(.data) ); + __data_start__ = .; *(vtable) *(.data*) @@ -126,7 +159,32 @@ SECTIONS /* All data end */ __data_end__ = .; - } > RAM + } > RAM AT>FLASH + + /* uVisor configuration data */ + .uvisor.secure : + { + . = ALIGN(32); + __uvisor_secure_start = .; + + /* Secure boxes configuration tables (protected) */ + . = ALIGN(32); + __uvisor_cfgtbl_start = .; + KEEP(*(.keep.uvisor.cfgtbl)) + . = ALIGN(32); + __uvisor_cfgtbl_end = .; + + /* Pointers to the secure boxes configuration tables (protected) */ + /* Note: Do not add any further alignment here, as we use this pointer + * table to enumerate boxes. */ + __uvisor_cfgtbl_ptr_start = .; + KEEP(*(.keep.uvisor.cfgtbl_ptr_first)) + KEEP(*(.keep.uvisor.cfgtbl_ptr)) + __uvisor_cfgtbl_ptr_end = .; + + . = ALIGN(32); + __uvisor_secure_end = .; + } >FLASH .bss : { @@ -160,5 +218,13 @@ SECTIONS /* Check if data + heap + stack exceeds RAM limit */ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") + + /* Provide physical memory boundaries for uVisor. */ + __uvisor_flash_start = ORIGIN(VECTORS); + __uvisor_flash_offset = ORIGIN(FLASH); + __uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH); + __uvisor_sram_start = ORIGIN(RAM) - 0x200; + __uvisor_sram_offset = ORIGIN(RAM); + __uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM); }