Alessandro Angelino / target-mcu-k64f

Fork of target-mcu-k64f by Morpheus

Committer:
Alessandro Angelino
Date:
Mon Apr 04 13:49:58 2016 +0100
Revision:
2:55d6ee55cf2a
Parent:
1:a2f6f231d859
Child:
3:45d1072eb12f
Add uVisor-specific sections to linker script

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:c5e2f793b59a 1 /*
screamer 0:c5e2f793b59a 2 * K64F ARM GCC linker script file
screamer 0:c5e2f793b59a 3 */
screamer 0:c5e2f793b59a 4
screamer 0:c5e2f793b59a 5 MEMORY
screamer 0:c5e2f793b59a 6 {
screamer 0:c5e2f793b59a 7 VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400
screamer 0:c5e2f793b59a 8 FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010
screamer 0:c5e2f793b59a 9 FLASH (rx) : ORIGIN = 0x00000410, LENGTH = 0x00100000 - 0x00000410
Alessandro Angelino 1:a2f6f231d859 10 RAM (rwx) : ORIGIN = 0x1FFF0200, LENGTH = 0x00040000 - 0x00000200
screamer 0:c5e2f793b59a 11 }
screamer 0:c5e2f793b59a 12
screamer 0:c5e2f793b59a 13 /* Linker script to place sections and symbol values. Should be used together
screamer 0:c5e2f793b59a 14 * with other linker script that defines memory regions FLASH and RAM.
screamer 0:c5e2f793b59a 15 * It references following symbols, which must be defined in code:
screamer 0:c5e2f793b59a 16 * _reset_init : Entry of reset handler
screamer 0:c5e2f793b59a 17 *
screamer 0:c5e2f793b59a 18 * It defines following symbols, which code can use without definition:
screamer 0:c5e2f793b59a 19 * __exidx_start
screamer 0:c5e2f793b59a 20 * __exidx_end
screamer 0:c5e2f793b59a 21 * __etext
screamer 0:c5e2f793b59a 22 * __data_start__
screamer 0:c5e2f793b59a 23 * __preinit_array_start
screamer 0:c5e2f793b59a 24 * __preinit_array_end
screamer 0:c5e2f793b59a 25 * __init_array_start
screamer 0:c5e2f793b59a 26 * __init_array_end
screamer 0:c5e2f793b59a 27 * __fini_array_start
screamer 0:c5e2f793b59a 28 * __fini_array_end
screamer 0:c5e2f793b59a 29 * __data_end__
screamer 0:c5e2f793b59a 30 * __bss_start__
screamer 0:c5e2f793b59a 31 * __bss_end__
screamer 0:c5e2f793b59a 32 * __end__
screamer 0:c5e2f793b59a 33 * end
screamer 0:c5e2f793b59a 34 * __HeapLimit
screamer 0:c5e2f793b59a 35 * __StackLimit
screamer 0:c5e2f793b59a 36 * __StackTop
screamer 0:c5e2f793b59a 37 * __stack
screamer 0:c5e2f793b59a 38 */
screamer 0:c5e2f793b59a 39 ENTRY(Reset_Handler)
screamer 0:c5e2f793b59a 40
screamer 0:c5e2f793b59a 41 SECTIONS
screamer 0:c5e2f793b59a 42 {
screamer 0:c5e2f793b59a 43 .isr_vector :
screamer 0:c5e2f793b59a 44 {
screamer 0:c5e2f793b59a 45 __vector_table = .;
screamer 0:c5e2f793b59a 46 KEEP(*(.vector_table))
screamer 0:c5e2f793b59a 47 *(.text.Reset_Handler)
screamer 0:c5e2f793b59a 48 *(.text.System_Init)
screamer 0:c5e2f793b59a 49 . = ALIGN(4);
screamer 0:c5e2f793b59a 50 } > VECTORS
screamer 0:c5e2f793b59a 51
screamer 0:c5e2f793b59a 52 .flash_protect :
screamer 0:c5e2f793b59a 53 {
screamer 0:c5e2f793b59a 54 KEEP(*(.kinetis_flash_config_field))
screamer 0:c5e2f793b59a 55 . = ALIGN(4);
screamer 0:c5e2f793b59a 56 } > FLASH_PROTECTION
screamer 0:c5e2f793b59a 57
Alessandro Angelino 2:55d6ee55cf2a 58 /* Ensure that the uVisor .bss is the first section in the public SRAM. */
Alessandro Angelino 2:55d6ee55cf2a 59 .uvisor.bss (NOLOAD):
Alessandro Angelino 2:55d6ee55cf2a 60 {
Alessandro Angelino 2:55d6ee55cf2a 61 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 62 __uvisor_bss_start = .;
Alessandro Angelino 2:55d6ee55cf2a 63
Alessandro Angelino 2:55d6ee55cf2a 64 /* uVisor main .bss (protected) */
Alessandro Angelino 2:55d6ee55cf2a 65 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 66 __uvisor_bss_main_start = .;
Alessandro Angelino 2:55d6ee55cf2a 67 KEEP(*(.keep.uvisor.bss.main))
Alessandro Angelino 2:55d6ee55cf2a 68 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 69 __uvisor_bss_main_end = .;
Alessandro Angelino 2:55d6ee55cf2a 70
Alessandro Angelino 2:55d6ee55cf2a 71 /* Secure boxes .bss (protected) */
Alessandro Angelino 2:55d6ee55cf2a 72 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 73 __uvisor_bss_boxes_start = .;
Alessandro Angelino 2:55d6ee55cf2a 74 KEEP(*(.keep.uvisor.bss.boxes))
Alessandro Angelino 2:55d6ee55cf2a 75 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 76 __uvisor_bss_boxes_end = .;
Alessandro Angelino 2:55d6ee55cf2a 77
Alessandro Angelino 2:55d6ee55cf2a 78 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 79 __uvisor_bss_end = .;
Alessandro Angelino 2:55d6ee55cf2a 80 } > RAM
Alessandro Angelino 2:55d6ee55cf2a 81
screamer 0:c5e2f793b59a 82 .text :
screamer 0:c5e2f793b59a 83 {
Alessandro Angelino 2:55d6ee55cf2a 84 /* uVisor code and data */
Alessandro Angelino 2:55d6ee55cf2a 85 /* Note: This is the location of the uVisor binary in flash. Make sure
Alessandro Angelino 2:55d6ee55cf2a 86 * this position correspond to the FLASH_OFFSET set in the uVisor
Alessandro Angelino 2:55d6ee55cf2a 87 * configuration. */
Alessandro Angelino 2:55d6ee55cf2a 88 . = ALIGN(4);
Alessandro Angelino 2:55d6ee55cf2a 89 __uvisor_main_start = .;
Alessandro Angelino 2:55d6ee55cf2a 90 *(.uvisor.main)
Alessandro Angelino 2:55d6ee55cf2a 91 __uvisor_main_end = .;
Alessandro Angelino 2:55d6ee55cf2a 92
screamer 0:c5e2f793b59a 93 *(.text*)
screamer 0:c5e2f793b59a 94
screamer 0:c5e2f793b59a 95 KEEP(*(.init))
screamer 0:c5e2f793b59a 96 KEEP(*(.fini))
screamer 0:c5e2f793b59a 97
screamer 0:c5e2f793b59a 98 /* .ctors */
screamer 0:c5e2f793b59a 99 *crtbegin.o(.ctors)
screamer 0:c5e2f793b59a 100 *crtbegin?.o(.ctors)
screamer 0:c5e2f793b59a 101 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
screamer 0:c5e2f793b59a 102 *(SORT(.ctors.*))
screamer 0:c5e2f793b59a 103 *(.ctors)
screamer 0:c5e2f793b59a 104
screamer 0:c5e2f793b59a 105 /* .dtors */
screamer 0:c5e2f793b59a 106 *crtbegin.o(.dtors)
screamer 0:c5e2f793b59a 107 *crtbegin?.o(.dtors)
screamer 0:c5e2f793b59a 108 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
screamer 0:c5e2f793b59a 109 *(SORT(.dtors.*))
screamer 0:c5e2f793b59a 110 *(.dtors)
screamer 0:c5e2f793b59a 111
screamer 0:c5e2f793b59a 112 *(.rodata*)
screamer 0:c5e2f793b59a 113
screamer 0:c5e2f793b59a 114 KEEP(*(.eh_frame*))
screamer 0:c5e2f793b59a 115 } > FLASH
screamer 0:c5e2f793b59a 116
screamer 0:c5e2f793b59a 117 .ARM.extab :
screamer 0:c5e2f793b59a 118 {
screamer 0:c5e2f793b59a 119 *(.ARM.extab* .gnu.linkonce.armextab.*)
screamer 0:c5e2f793b59a 120 } > FLASH
screamer 0:c5e2f793b59a 121
screamer 0:c5e2f793b59a 122 __exidx_start = .;
screamer 0:c5e2f793b59a 123 .ARM.exidx :
screamer 0:c5e2f793b59a 124 {
screamer 0:c5e2f793b59a 125 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
screamer 0:c5e2f793b59a 126 } > FLASH
screamer 0:c5e2f793b59a 127 __exidx_end = .;
screamer 0:c5e2f793b59a 128
Alessandro Angelino 2:55d6ee55cf2a 129 .data :
Alessandro Angelino 2:55d6ee55cf2a 130 {
Alessandro Angelino 2:55d6ee55cf2a 131 PROVIDE( __etext = LOADADDR(.data) );
screamer 0:c5e2f793b59a 132
screamer 0:c5e2f793b59a 133 __data_start__ = .;
screamer 0:c5e2f793b59a 134 *(vtable)
screamer 0:c5e2f793b59a 135 *(.data*)
screamer 0:c5e2f793b59a 136
screamer 0:c5e2f793b59a 137 . = ALIGN(4);
screamer 0:c5e2f793b59a 138 /* preinit data */
screamer 0:c5e2f793b59a 139 PROVIDE_HIDDEN (__preinit_array_start = .);
screamer 0:c5e2f793b59a 140 KEEP(*(.preinit_array))
screamer 0:c5e2f793b59a 141 PROVIDE_HIDDEN (__preinit_array_end = .);
screamer 0:c5e2f793b59a 142
screamer 0:c5e2f793b59a 143 . = ALIGN(4);
screamer 0:c5e2f793b59a 144 /* init data */
screamer 0:c5e2f793b59a 145 PROVIDE_HIDDEN (__init_array_start = .);
screamer 0:c5e2f793b59a 146 KEEP(*(SORT(.init_array.*)))
screamer 0:c5e2f793b59a 147 KEEP(*(.init_array))
screamer 0:c5e2f793b59a 148 PROVIDE_HIDDEN (__init_array_end = .);
screamer 0:c5e2f793b59a 149
screamer 0:c5e2f793b59a 150
screamer 0:c5e2f793b59a 151 . = ALIGN(4);
screamer 0:c5e2f793b59a 152 /* finit data */
screamer 0:c5e2f793b59a 153 PROVIDE_HIDDEN (__fini_array_start = .);
screamer 0:c5e2f793b59a 154 KEEP(*(SORT(.fini_array.*)))
screamer 0:c5e2f793b59a 155 KEEP(*(.fini_array))
screamer 0:c5e2f793b59a 156 PROVIDE_HIDDEN (__fini_array_end = .);
screamer 0:c5e2f793b59a 157
screamer 0:c5e2f793b59a 158 . = ALIGN(4);
screamer 0:c5e2f793b59a 159 /* All data end */
screamer 0:c5e2f793b59a 160 __data_end__ = .;
screamer 0:c5e2f793b59a 161
Alessandro Angelino 2:55d6ee55cf2a 162 } > RAM AT>FLASH
Alessandro Angelino 2:55d6ee55cf2a 163
Alessandro Angelino 2:55d6ee55cf2a 164 /* uVisor configuration data */
Alessandro Angelino 2:55d6ee55cf2a 165 .uvisor.secure :
Alessandro Angelino 2:55d6ee55cf2a 166 {
Alessandro Angelino 2:55d6ee55cf2a 167 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 168 __uvisor_secure_start = .;
Alessandro Angelino 2:55d6ee55cf2a 169
Alessandro Angelino 2:55d6ee55cf2a 170 /* Secure boxes configuration tables (protected) */
Alessandro Angelino 2:55d6ee55cf2a 171 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 172 __uvisor_cfgtbl_start = .;
Alessandro Angelino 2:55d6ee55cf2a 173 KEEP(*(.keep.uvisor.cfgtbl))
Alessandro Angelino 2:55d6ee55cf2a 174 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 175 __uvisor_cfgtbl_end = .;
Alessandro Angelino 2:55d6ee55cf2a 176
Alessandro Angelino 2:55d6ee55cf2a 177 /* Pointers to the secure boxes configuration tables (protected) */
Alessandro Angelino 2:55d6ee55cf2a 178 /* Note: Do not add any further alignment here, as we use this pointer
Alessandro Angelino 2:55d6ee55cf2a 179 * table to enumerate boxes. */
Alessandro Angelino 2:55d6ee55cf2a 180 __uvisor_cfgtbl_ptr_start = .;
Alessandro Angelino 2:55d6ee55cf2a 181 KEEP(*(.keep.uvisor.cfgtbl_ptr_first))
Alessandro Angelino 2:55d6ee55cf2a 182 KEEP(*(.keep.uvisor.cfgtbl_ptr))
Alessandro Angelino 2:55d6ee55cf2a 183 __uvisor_cfgtbl_ptr_end = .;
Alessandro Angelino 2:55d6ee55cf2a 184
Alessandro Angelino 2:55d6ee55cf2a 185 . = ALIGN(32);
Alessandro Angelino 2:55d6ee55cf2a 186 __uvisor_secure_end = .;
Alessandro Angelino 2:55d6ee55cf2a 187 } >FLASH
screamer 0:c5e2f793b59a 188
screamer 0:c5e2f793b59a 189 .bss :
screamer 0:c5e2f793b59a 190 {
screamer 0:c5e2f793b59a 191 __bss_start__ = .;
screamer 0:c5e2f793b59a 192 *(.bss*)
screamer 0:c5e2f793b59a 193 *(COMMON)
screamer 0:c5e2f793b59a 194 __bss_end__ = .;
screamer 0:c5e2f793b59a 195 } > RAM
screamer 0:c5e2f793b59a 196
screamer 0:c5e2f793b59a 197 .heap :
screamer 0:c5e2f793b59a 198 {
screamer 0:c5e2f793b59a 199 __end__ = .;
screamer 0:c5e2f793b59a 200 end = __end__;
screamer 0:c5e2f793b59a 201 *(.heap*)
screamer 0:c5e2f793b59a 202 __HeapLimit = .;
screamer 0:c5e2f793b59a 203 } > RAM
screamer 0:c5e2f793b59a 204
screamer 0:c5e2f793b59a 205 /* .stack_dummy section doesn't contains any symbols. It is only
screamer 0:c5e2f793b59a 206 * used for linker to calculate size of stack sections, and assign
screamer 0:c5e2f793b59a 207 * values to stack symbols later */
screamer 0:c5e2f793b59a 208 .stack_dummy :
screamer 0:c5e2f793b59a 209 {
screamer 0:c5e2f793b59a 210 *(.stack)
screamer 0:c5e2f793b59a 211 } > RAM
screamer 0:c5e2f793b59a 212
screamer 0:c5e2f793b59a 213 /* Set stack top to end of RAM, and stack limit move down by
screamer 0:c5e2f793b59a 214 * size of stack_dummy section */
screamer 0:c5e2f793b59a 215 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
screamer 0:c5e2f793b59a 216 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
screamer 0:c5e2f793b59a 217 PROVIDE(__stack = __StackTop);
screamer 0:c5e2f793b59a 218
screamer 0:c5e2f793b59a 219 /* Check if data + heap + stack exceeds RAM limit */
screamer 0:c5e2f793b59a 220 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
Alessandro Angelino 2:55d6ee55cf2a 221
Alessandro Angelino 2:55d6ee55cf2a 222 /* Provide physical memory boundaries for uVisor. */
Alessandro Angelino 2:55d6ee55cf2a 223 __uvisor_flash_start = ORIGIN(VECTORS);
Alessandro Angelino 2:55d6ee55cf2a 224 __uvisor_flash_offset = ORIGIN(FLASH);
Alessandro Angelino 2:55d6ee55cf2a 225 __uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
Alessandro Angelino 2:55d6ee55cf2a 226 __uvisor_sram_start = ORIGIN(RAM) - 0x200;
Alessandro Angelino 2:55d6ee55cf2a 227 __uvisor_sram_offset = ORIGIN(RAM);
Alessandro Angelino 2:55d6ee55cf2a 228 __uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM);
screamer 0:c5e2f793b59a 229 }
screamer 0:c5e2f793b59a 230