1 /******************************************************************************
3 * @brief GNU Linker Script for Cortex-M based device
5 * @date 16. December 2020
6 ******************************************************************************/
8 * Copyright (c) 2009-2020 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
26 *-------- <<< Use Configuration Wizard in Context Menu >>> -------------------
29 /*---------------------- Flash Configuration ----------------------------------
30 <h> Flash Configuration
31 <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
32 <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
34 -----------------------------------------------------------------------------*/
35 __ROM_BASE = 0x00000000;
36 __ROM_SIZE = 0x00200000;
38 /*--------------------- Embedded RAM Configuration ----------------------------
40 <o0> RAM Base Address <0x0-0xFFFFFFFF:8>
41 <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
43 -----------------------------------------------------------------------------*/
44 __RAM_BASE = 0x20000000;
45 __RAM_SIZE = 0x00200000;
47 /*--------------------- Stack / Heap Configuration ----------------------------
48 <h> Stack / Heap Configuration
49 <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
50 <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
52 -----------------------------------------------------------------------------*/
53 __STACK_SIZE = 0x00000400;
54 __HEAP_SIZE = 0x00000C00;
57 *-------------------- <<< end of configuration section >>> -------------------
60 /* ARMv8-M stack sealing:
61 to use ARMv8-M stack sealing set __STACKSEAL_SIZE to 8 otherwise keep 0
68 FLASH (rx) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE
69 RAM (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE
72 /* Linker script to place sections and symbol values. Should be used together
73 * with other linker script that defines memory regions FLASH and RAM.
74 * It references following symbols, which must be defined in code:
75 * Reset_Handler : Entry of reset handler
77 * It defines following symbols, which code can use without definition:
80 * __copy_table_start__
82 * __zero_table_start__
86 * __preinit_array_start
101 * __StackSeal (only if ARMv8-M stack sealing is used)
118 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
125 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
136 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
137 * must be set, either with the command line option ‘--section-start’ or in a linker script,
138 * to indicate where to place these veneers in memory.
148 *(.ARM.extab* .gnu.linkonce.armextab.*)
154 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
161 __copy_table_start__ = .;
164 LONG (__data_start__)
165 LONG ((__data_end__ - __data_start__) / 4)
167 /* Add each additional data section here */
170 LONG (__data2_start__)
171 LONG ((__data2_end__ - __data2_start__) / 4)
173 __copy_table_end__ = .;
179 __zero_table_start__ = .;
180 /* Add each additional bss section here */
182 LONG (__bss2_start__)
183 LONG ((__bss2_end__ - __bss2_start__) / 4)
185 __zero_table_end__ = .;
189 * Location counter can end up 2byte aligned with narrow Thumb code but
190 * __etext is assumed by startup code to be the LMA of a section in RAM
191 * which must be 4byte aligned
204 PROVIDE_HIDDEN (__preinit_array_start = .);
205 KEEP(*(.preinit_array))
206 PROVIDE_HIDDEN (__preinit_array_end = .);
210 PROVIDE_HIDDEN (__init_array_start = .);
211 KEEP(*(SORT(.init_array.*)))
213 PROVIDE_HIDDEN (__init_array_end = .);
217 PROVIDE_HIDDEN (__fini_array_start = .);
218 KEEP(*(SORT(.fini_array.*)))
220 PROVIDE_HIDDEN (__fini_array_end = .);
230 * Secondary data section, optional
232 * Remember to add each additional data section
233 * to the .copy.table above to asure proper
234 * initialization during startup.
237 __etext2 = ALIGN (4);
239 .data2 : AT (__etext2)
263 * Secondary bss section, optional
265 * Remember to add each additional bss section
266 * to the .zero.table above to asure proper
267 * initialization during startup.
291 .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE - __STACKSEAL_SIZE) (COPY) :
295 . = . + __STACK_SIZE;
299 PROVIDE(__stack = __StackTop);
301 /* ARMv8-M stack sealing:
302 to use ARMv8-M stack sealing uncomment '.stackseal' section
305 .stackseal (ORIGIN(RAM) + LENGTH(RAM) - __STACKSEAL_SIZE) (COPY) :
314 /* Check if data + heap + stack exceeds RAM limit */
315 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")