1 /******************************************************************************
3 * @brief GNU Linker Script for Cortex-M based device
6 ******************************************************************************/
8 * Copyright (c) 2009-2023 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 = 0x00040000;
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 = 0x00020000;
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__
84 * __etext (deprecated)
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__ = .;
163 LONG (LOADADDR(.data))
165 LONG (SIZEOF(.data) / 4)
167 /* Add each additional data section here */
169 LONG (LOADADDR(.data2))
171 LONG (SIZEOF(.data2) / 4)
173 __copy_table_end__ = .;
179 __zero_table_start__ = .;
181 /* .bss initialization to zero is already done during C Run-Time Startup.
183 LONG (SIZEOF(.bss) / 4)
186 /* Add each additional bss section here */
189 LONG (SIZEOF(.bss2) / 4)
191 __zero_table_end__ = .;
195 * This __etext variable is kept for backward compatibility with older,
196 * ASM based startup files.
198 PROVIDE(__etext = LOADADDR(.data));
209 PROVIDE_HIDDEN (__preinit_array_start = .);
210 KEEP(*(.preinit_array))
211 PROVIDE_HIDDEN (__preinit_array_end = .);
215 PROVIDE_HIDDEN (__init_array_start = .);
216 KEEP(*(SORT(.init_array.*)))
218 PROVIDE_HIDDEN (__init_array_end = .);
222 PROVIDE_HIDDEN (__fini_array_start = .);
223 KEEP(*(SORT(.fini_array.*)))
225 PROVIDE_HIDDEN (__fini_array_end = .);
235 * Secondary data section, optional
237 * Remember to add each additional data section
238 * to the .copy.table above to assure proper
239 * initialization during startup.
266 * Secondary bss section, optional
268 * Remember to add each additional bss section
269 * to the .zero.table above to assure proper
270 * initialization during startup.
294 .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE - __STACKSEAL_SIZE) (NOLOAD) :
298 . = . + __STACK_SIZE;
302 PROVIDE(__stack = __StackTop);
304 /* ARMv8-M stack sealing:
305 to use ARMv8-M stack sealing uncomment '.stackseal' section
308 .stackseal (ORIGIN(RAM) + LENGTH(RAM) - __STACKSEAL_SIZE) (NOLOAD) :
317 /* Check if data + heap + stack exceeds RAM limit */
318 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")