|
| 1 | +/***************************************************************************//** |
| 2 | + * GCC Linker script for Silicon Labs devices |
| 3 | + ******************************************************************************* |
| 4 | + * # License |
| 5 | + * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b> |
| 6 | + ******************************************************************************* |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: Zlib |
| 9 | + * |
| 10 | + * The licensor of this software is Silicon Laboratories Inc. |
| 11 | + * |
| 12 | + * This software is provided 'as-is', without any express or implied |
| 13 | + * warranty. In no event will the authors be held liable for any damages |
| 14 | + * arising from the use of this software. |
| 15 | + * |
| 16 | + * Permission is granted to anyone to use this software for any purpose, |
| 17 | + * including commercial applications, and to alter it and redistribute it |
| 18 | + * freely, subject to the following restrictions: |
| 19 | + * |
| 20 | + * 1. The origin of this software must not be misrepresented; you must not |
| 21 | + * claim that you wrote the original software. If you use this software |
| 22 | + * in a product, an acknowledgment in the product documentation would be |
| 23 | + * appreciated but is not required. |
| 24 | + * 2. Altered source versions must be plainly marked as such, and must not be |
| 25 | + * misrepresented as being the original software. |
| 26 | + * 3. This notice may not be removed or altered from any source distribution. |
| 27 | + * |
| 28 | + ******************************************************************************/ |
| 29 | + |
| 30 | + MEMORY |
| 31 | + { |
| 32 | + FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 0x318000 |
| 33 | + RAM (rwx) : ORIGIN = 0x20000004, LENGTH = 0x7fffc |
| 34 | + BOOTLOADER_RESET_REGION (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4 |
| 35 | + } |
| 36 | + |
| 37 | +ENTRY(Reset_Handler) |
| 38 | + |
| 39 | +SECTIONS |
| 40 | +{ |
| 41 | + |
| 42 | + .vectors : |
| 43 | + { |
| 44 | + linker_vectors_begin = .; |
| 45 | + KEEP(*(.vectors)) |
| 46 | + linker_vectors_end = .; |
| 47 | + |
| 48 | + __Vectors_End = .; |
| 49 | + __Vectors_Size = __Vectors_End - __Vectors; |
| 50 | + __lma_ramfuncs_start__ = .; |
| 51 | + } > FLASH |
| 52 | + .bootloader_reset_section (NOLOAD): |
| 53 | + { |
| 54 | + __ResetReasonStart__ = .; |
| 55 | + . = . + 4; |
| 56 | + . = ALIGN(4); |
| 57 | + __ResetReasonEnd__ = .; |
| 58 | + } > BOOTLOADER_RESET_REGION |
| 59 | + |
| 60 | + .stack (NOLOAD): |
| 61 | + { |
| 62 | + . = ALIGN(8); |
| 63 | + __StackLimit = .; |
| 64 | + KEEP(*(.stack*)) |
| 65 | + . = ALIGN(4); |
| 66 | + __StackTop = .; |
| 67 | + PROVIDE(__stack = __StackTop); |
| 68 | + } > RAM |
| 69 | + |
| 70 | + .bss : |
| 71 | + { |
| 72 | + . = ALIGN(4); |
| 73 | + __bss_start__ = .; |
| 74 | + *(SORT_BY_ALIGNMENT(.bss*)) |
| 75 | + *(COMMON) |
| 76 | + . = ALIGN(32); |
| 77 | + __bss_end__ = .; |
| 78 | + } > RAM |
| 79 | + |
| 80 | + |
| 81 | + .noinit (NOLOAD): |
| 82 | + { |
| 83 | + *(.noinit*); |
| 84 | + . = ALIGN(32); |
| 85 | + } > RAM |
| 86 | + |
| 87 | + |
| 88 | + text_application_ram : |
| 89 | + { |
| 90 | + . = ALIGN(32); |
| 91 | + __vma_ramfuncs_start__ = .; |
| 92 | + __text_application_ram_start__ = .; |
| 93 | + |
| 94 | + *(text_application_ram) |
| 95 | + |
| 96 | + . = ALIGN(32); |
| 97 | + __vma_ramfuncs_end__ = .; |
| 98 | + __text_application_ram_end__ = .; |
| 99 | + } > RAM AT > FLASH |
| 100 | + |
| 101 | + .rodata : |
| 102 | + { |
| 103 | + __lma_ramfuncs_end__ = .; |
| 104 | + __rodata_start__ = .; |
| 105 | + __rodata_end__ = .; |
| 106 | + } > FLASH |
| 107 | + |
| 108 | + .text : |
| 109 | + { |
| 110 | + linker_code_begin = .; |
| 111 | + *(SORT_BY_ALIGNMENT(.text*)) |
| 112 | + *(SORT_BY_ALIGNMENT(text_*)) |
| 113 | + . = ALIGN(32); |
| 114 | + linker_code_end = .; |
| 115 | + |
| 116 | + KEEP(*(.init)) |
| 117 | + KEEP(*(.fini)) |
| 118 | + |
| 119 | + /* .ctors */ |
| 120 | + *crtbegin.o(.ctors) |
| 121 | + *crtbegin?.o(.ctors) |
| 122 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
| 123 | + *(SORT(.ctors.*)) |
| 124 | + *(.ctors) |
| 125 | + |
| 126 | + /* .dtors */ |
| 127 | + *crtbegin.o(.dtors) |
| 128 | + *crtbegin?.o(.dtors) |
| 129 | + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
| 130 | + *(SORT(.dtors.*)) |
| 131 | + *(.dtors) |
| 132 | + |
| 133 | + *(.rodata*) |
| 134 | + *(.eh_frame*) |
| 135 | + } > FLASH |
| 136 | + |
| 137 | + .ARM.extab : |
| 138 | + { |
| 139 | + *(.ARM.extab* .gnu.linkonce.armextab.*) |
| 140 | + } > FLASH |
| 141 | + |
| 142 | + __exidx_start = .; |
| 143 | + .ARM.exidx : |
| 144 | + { |
| 145 | + *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
| 146 | + } > FLASH |
| 147 | + __exidx_end = .; |
| 148 | + |
| 149 | + .copy.table : |
| 150 | + { |
| 151 | + . = ALIGN(4); |
| 152 | + __copy_table_start__ = .; |
| 153 | + |
| 154 | + LONG (__etext) |
| 155 | + LONG (__data_start__) |
| 156 | + LONG ((__data_end__ - __data_start__) / 4) |
| 157 | + |
| 158 | + /* Add each additional data section here */ |
| 159 | + /* |
| 160 | + LONG (__etext2) |
| 161 | + LONG (__data2_start__) |
| 162 | + LONG ((__data2_end__ - __data2_start__) / 4) |
| 163 | + */ |
| 164 | + |
| 165 | + __copy_table_end__ = .; |
| 166 | + } > FLASH |
| 167 | + |
| 168 | + .zero.table : |
| 169 | + { |
| 170 | + . = ALIGN(4); |
| 171 | + __zero_table_start__ = .; |
| 172 | + /* Add each additional bss section here */ |
| 173 | + /* |
| 174 | + LONG (__bss2_start__) |
| 175 | + LONG ((__bss2_end__ - __bss2_start__) / 4) |
| 176 | + */ |
| 177 | + |
| 178 | + __zero_table_end__ = .; |
| 179 | + __etext = .; |
| 180 | + } > FLASH |
| 181 | + |
| 182 | + .data : |
| 183 | + { |
| 184 | + . = ALIGN(4); |
| 185 | + __data_start__ = .; |
| 186 | + *(vtable) |
| 187 | + *(SORT_BY_ALIGNMENT(.data*)) |
| 188 | + . = ALIGN(4); |
| 189 | + |
| 190 | + . = ALIGN(4); |
| 191 | + /* preinit data */ |
| 192 | + PROVIDE_HIDDEN (__preinit_array_start = .); |
| 193 | + KEEP(*(.preinit_array)) |
| 194 | + PROVIDE_HIDDEN (__preinit_array_end = .); |
| 195 | + |
| 196 | + . = ALIGN(4); |
| 197 | + /* init data */ |
| 198 | + PROVIDE_HIDDEN (__init_array_start = .); |
| 199 | + KEEP(*(SORT(.init_array.*))) |
| 200 | + KEEP(*(.init_array)) |
| 201 | + PROVIDE_HIDDEN (__init_array_end = .); |
| 202 | + |
| 203 | + . = ALIGN(4); |
| 204 | + /* finit data */ |
| 205 | + PROVIDE_HIDDEN (__fini_array_start = .); |
| 206 | + KEEP(*(SORT(.fini_array.*))) |
| 207 | + KEEP(*(.fini_array)) |
| 208 | + PROVIDE_HIDDEN (__fini_array_end = .); |
| 209 | + |
| 210 | + . = ALIGN(4); |
| 211 | + /* All data end */ |
| 212 | + __data_end__ = .; |
| 213 | + |
| 214 | + } > RAM AT > FLASH |
| 215 | + |
| 216 | + |
| 217 | +/* Calculate heap size based on RAM limits. */ |
| 218 | +heap_limit = ORIGIN(RAM) + LENGTH(RAM); /* End of RAM */ |
| 219 | +heap_size = heap_limit - __HeapBase; |
| 220 | + .memory_manager_heap (NOLOAD): |
| 221 | + { |
| 222 | + . = ALIGN(8); |
| 223 | + __HeapBase = .; |
| 224 | + . += heap_size; |
| 225 | + __end__ = .; |
| 226 | + end = __end__; |
| 227 | + _end = __end__; |
| 228 | + KEEP(*(.memory_manager_heap*)) |
| 229 | + __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); |
| 230 | + } > RAM |
| 231 | + |
| 232 | + __heap_size = __HeapLimit - __HeapBase; |
| 233 | + __ram_end__ = 0x20000004 + 0x7fffc; |
| 234 | + __main_flash_end__ = 0x8006000 + 0x318000; |
| 235 | + |
| 236 | + /* This is where we handle flash storage blocks. We use dummy sections for finding the configured |
| 237 | + * block sizes and then "place" them at the end of flash when the size is known. */ |
| 238 | + .internal_storage (DSECT) : { |
| 239 | + KEEP(*(.internal_storage*)) |
| 240 | + } > FLASH |
| 241 | + |
| 242 | + |
| 243 | + .nvm (DSECT) : { |
| 244 | + KEEP(*(.simee*)) |
| 245 | + } > FLASH |
| 246 | + |
| 247 | + __ramfuncs_start__ = __vma_ramfuncs_start__; |
| 248 | + __ramfuncs_end__ = __vma_ramfuncs_end__; |
| 249 | + |
| 250 | + linker_nvm_end = __main_flash_end__; |
| 251 | + linker_nvm_begin = linker_nvm_end - SIZEOF(.nvm); |
| 252 | + linker_storage_end = linker_nvm_begin; |
| 253 | + __nvm3Base = linker_nvm_begin; |
| 254 | + |
| 255 | + linker_storage_begin = linker_storage_end - SIZEOF(.internal_storage); |
| 256 | + ASSERT((linker_storage_begin >= (__etext + SIZEOF(.data))), "FLASH memory overflowed !") |
| 257 | + |
| 258 | + |
| 259 | + app_flash_end = 0x8006000 + 0x318000; |
| 260 | + ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= app_flash_end, "NVM3 is excessing the flash size !") |
| 261 | +} |
0 commit comments