uVisor: Update K64F and EFM32GG linker scripts

This commit improves consistency between different platforms' linker
scripts. In particular, we use "__UVISOR_SRAM_START" instead of
"__UVISOR_BSS_START" as the uVisor BSS sections might be outside of the
SRAM (for example, when using a tightly-coupled memory).
pull/3397/head
Alessandro Angelino 2016-11-30 15:57:29 +00:00
parent 3a53a5adc8
commit 89641bc7e0
2 changed files with 45 additions and 38 deletions

View File

@ -93,9 +93,9 @@ SECTIONS
/* The program code and other data goes into internal flash */ /* The program code and other data goes into internal flash */
/* Note: The uVisor expects this section at a fixed location, as specified by /* Note: The uVisor expects this section at a fixed location, as specified by
* the porting process configuration parameter: FLASH_OFFSET. */ * the porting process configuration parameter: FLASH_OFFSET. */
__UVISOR_TEXT_OFFSET = 0x410; __UVISOR_FLASH_OFFSET = 0x410;
__UVISOR_TEXT_START = ORIGIN(m_interrupts) + __UVISOR_TEXT_OFFSET; __UVISOR_FLASH_START = ORIGIN(m_interrupts) + __UVISOR_FLASH_OFFSET;
.text __UVISOR_TEXT_START : .text __UVISOR_FLASH_START :
{ {
/* uVisor code and data */ /* uVisor code and data */
. = ALIGN(4); . = ALIGN(4);
@ -197,27 +197,26 @@ SECTIONS
__interrupts_ram_end__ = .; /* Define a global symbol at data end */ __interrupts_ram_end__ = .; /* Define a global symbol at data end */
} > m_data } > m_data
/* Ensure that the uVisor BSS section is put first after the relocated /* uVisor own memory and private box memories
* interrupt table in SRAM. */ /* If uVisor shares the SRAM with the OS/app, ensure that this section is
/* Note: The uVisor expects this section at a fixed location, as specified by * the first one after the VTOR relocation section. */
* the porting process configuration parameter: SRAM_OFFSET. */ /* Note: The uVisor expects this section at a fixed location, as specified
by the porting process configuration parameter: SRAM_OFFSET. */
__UVISOR_SRAM_OFFSET = 0x400; __UVISOR_SRAM_OFFSET = 0x400;
__UVISOR_BSS_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET; __UVISOR_SRAM_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET;
ASSERT(__interrupts_ram_end__ <= __UVISOR_BSS_START, .uvisor.bss __UVISOR_SRAM_START (NOLOAD):
"The ISR relocation region overlaps with the uVisor BSS section.")
.uvisor.bss __UVISOR_BSS_START (NOLOAD):
{ {
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_start = .; __uvisor_bss_start = .;
/* protected uvisor main bss */ /* Protected uVisor own BSS section */
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_main_start = .; __uvisor_bss_main_start = .;
KEEP(*(.keep.uvisor.bss.main)) KEEP(*(.keep.uvisor.bss.main))
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_main_end = .; __uvisor_bss_main_end = .;
/* protected uvisor secure boxes bss */ /* Protected uVisor boxes' static memories */
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_boxes_start = .; __uvisor_bss_boxes_start = .;
KEEP(*(.keep.uvisor.bss.boxes)) KEEP(*(.keep.uvisor.bss.boxes))
@ -228,7 +227,10 @@ SECTIONS
__uvisor_bss_end = .; __uvisor_bss_end = .;
} > m_data } > m_data
/* Heap space for the page allocator */ /* Heap space for the page allocator
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
* the first one after the uVisor BSS section. Otherwise, ensure it is the
* first one after the VTOR relocation section. */
.page_heap (NOLOAD) : .page_heap (NOLOAD) :
{ {
. = ALIGN(32); . = ALIGN(32);
@ -305,6 +307,7 @@ SECTIONS
} > m_data_2 } > m_data_2
USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800; USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;
/* Uninitialized data section */ /* Uninitialized data section */
.bss : .bss :
{ {
@ -354,11 +357,13 @@ SECTIONS
.ARM.attributes 0 : { *(.ARM.attributes) } .ARM.attributes 0 : { *(.ARM.attributes) }
ASSERT(__StackLimit >= __HeapLimit, "region m_data_2 overflowed with stack and heap") ASSERT(__StackLimit >= __HeapLimit, "Region m_data_2 overflowed with stack and heap")
/* Provide the physical memory boundaries for uVisor. */ /* Provide the physical memory boundaries for uVisor. */
__uvisor_flash_start = ORIGIN(m_interrupts); __uvisor_flash_start = ORIGIN(m_interrupts);
__uvisor_flash_end = ORIGIN(m_text) + LENGTH(m_text); __uvisor_flash_end = ORIGIN(m_text) + LENGTH(m_text);
__uvisor_sram_start = ORIGIN(m_data); __uvisor_sram_start = ORIGIN(m_data);
__uvisor_sram_end = ORIGIN(m_data_2) + LENGTH(m_data_2); __uvisor_sram_end = ORIGIN(m_data_2) + LENGTH(m_data_2);
__uvisor_public_sram_start = __uvisor_sram_start;
__uvisor_public_sram_end = __uvisor_sram_end;
} }

View File

@ -56,13 +56,12 @@ __vector_size = 0xDC;
*/ */
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
/* Note: The uVisor expects the text section at a fixed location, as specified
by the porting process configuration parameter: FLASH_OFFSET. */
__UVISOR_TEXT_OFFSET = 0x100;
__UVISOR_TEXT_START = ORIGIN(FLASH) + __UVISOR_TEXT_OFFSET;
SECTIONS SECTIONS
{ {
/* Note: The uVisor expects the text section at a fixed location, as specified
by the porting process configuration parameter: FLASH_OFFSET. */
__UVISOR_FLASH_OFFSET = 0x100;
__UVISOR_FLASH_START = ORIGIN(FLASH) + __UVISOR_FLASH_OFFSET;
.text : .text :
{ {
KEEP(*(.vectors)) KEEP(*(.vectors))
@ -71,7 +70,7 @@ SECTIONS
__end__ = .; __end__ = .;
/* uVisor code and data */ /* uVisor code and data */
. = __UVISOR_TEXT_OFFSET; . = __UVISOR_FLASH_OFFSET;
. = ALIGN(4); . = ALIGN(4);
__uvisor_main_start = .; __uvisor_main_start = .;
*(.uvisor.main) *(.uvisor.main)
@ -147,24 +146,26 @@ SECTIONS
} > FLASH } > FLASH
*/ */
/* Ensure that the uVisor BSS section is put first in SRAM. */ /* uVisor own memory and private box memories
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
* the first one after the VTOR relocation section. */
/* Note: The uVisor expects this section at a fixed location, as specified /* Note: The uVisor expects this section at a fixed location, as specified
by the porting process configuration parameter: SRAM_OFFSET. */ by the porting process configuration parameter: SRAM_OFFSET. */
__UVISOR_SRAM_OFFSET = 0x0; __UVISOR_SRAM_OFFSET = 0x0;
__UVISOR_BSS_START = ORIGIN(RAM) + __UVISOR_SRAM_OFFSET; __UVISOR_SRAM_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET;
.uvisor.bss __UVISOR_BSS_START (NOLOAD): .uvisor.bss __UVISOR_SRAM_START (NOLOAD):
{ {
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_start = .; __uvisor_bss_start = .;
/* uVisor main BSS section */ /* Protected uVisor own BSS section */
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_main_start = .; __uvisor_bss_main_start = .;
KEEP(*(.keep.uvisor.bss.main)) KEEP(*(.keep.uvisor.bss.main))
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_main_end = .; __uvisor_bss_main_end = .;
/* Secure boxes BSS section */ /* Protected uVisor boxes' static memories */
. = ALIGN(32); . = ALIGN(32);
__uvisor_bss_boxes_start = .; __uvisor_bss_boxes_start = .;
KEEP(*(.keep.uvisor.bss.boxes)) KEEP(*(.keep.uvisor.bss.boxes))
@ -175,15 +176,16 @@ SECTIONS
__uvisor_bss_end = .; __uvisor_bss_end = .;
} > RAM } > RAM
/* Heap space for the page allocator */ /* Heap space for the page allocator
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
* the first one after the uVisor BSS section. Otherwise, ensure it is the
* first one after the VTOR relocation section. */
.page_heap (NOLOAD) : .page_heap (NOLOAD) :
{ {
. = ALIGN(32); . = ALIGN(32);
__uvisor_page_start = .; __uvisor_page_start = .;
KEEP(*(.keep.uvisor.page_heap)) KEEP(*(.keep.uvisor.page_heap))
. = ALIGN( (1 << LOG2CEIL(LENGTH(RAM))) / 8); . = ALIGN( (1 << LOG2CEIL(LENGTH(RAM))) / 8);
__uvisor_page_end = .; __uvisor_page_end = .;
} > RAM } > RAM
@ -284,10 +286,6 @@ SECTIONS
__bss_end__ = .; __bss_end__ = .;
} > RAM } > RAM
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__stack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
.heap (NOLOAD): .heap (NOLOAD):
{ {
__uvisor_heap_start = .; __uvisor_heap_start = .;
@ -296,17 +294,21 @@ SECTIONS
end = __end__; end = __end__;
_end = __end__; _end = __end__;
. += HEAP_SIZE; . += HEAP_SIZE;
__HeapLimit = .;
__uvisor_heap_end = .;
} > RAM } > RAM
__HeapLimit = __StackLimit; __StackTop = ORIGIN(RAM) + LENGTH(RAM);
__uvisor_heap_end = __StackLimit; __stack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
ASSERT(__StackLimit >= __HeapLimit, "Region RAM overflowed with stack and heap")
/* Provide physical memory boundaries for uVisor. */ /* Provide physical memory boundaries for uVisor. */
__uvisor_flash_start = ORIGIN(FLASH); __uvisor_flash_start = ORIGIN(FLASH);
__uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH); __uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
__uvisor_sram_start = ORIGIN(RAM); __uvisor_sram_start = ORIGIN(RAM);
__uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM); __uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM);
__uvisor_public_sram_start = __uvisor_sram_start;
/* Check if FLASH usage exceeds FLASH size. */ __uvisor_public_sram_end = __uvisor_sram_end;
ASSERT(LENGTH(FLASH) >= __uvisor_secure_end, "FLASH memory overflowed!")
} }