1;/*
2; * Copyright (c) 2021-2024 Arm Limited. All rights reserved.
3; *
4; * Licensed under the Apache License, Version 2.0 (the "License");
5; * you may not use this file except in compliance with the License.
6; * You may obtain a copy of the License at
7; *
8; *     http://www.apache.org/licenses/LICENSE-2.0
9; *
10; * Unless required by applicable law or agreed to in writing, software
11; * distributed under the License is distributed on an "AS IS" BASIS,
12; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13; * See the License for the specific language governing permissions and
14; * limitations under the License.
15; *
16; *
17; * This file is derivative of CMSIS V5.00 gcc_arm.ld
18; */
19
20/* Linker script to configure memory regions. */
21/* This file will be run trough the pre-processor. */
22
23#include "region_defs.h"
24
25MEMORY
26{
27  FLASH (rx)  : ORIGIN = NS_CODE_START, LENGTH = NS_CODE_SIZE
28  RAM   (rwx) : ORIGIN = NS_DATA_START, LENGTH = NS_DATA_SIZE
29}
30
31__heap_size__  = NS_HEAP_SIZE;
32__stack_size__ = NS_STACK_SIZE;
33
34ENTRY(Reset_Handler)
35
36SECTIONS
37{
38    .text (READONLY) :
39    {
40        KEEP(*(.vectors))
41        __Vectors_End = .;
42        __Vectors_Size = __Vectors_End - __Vectors;
43        __end__ = .;
44
45        *(.text*)
46
47        . = ALIGN(4);
48        /* preinit data */
49        PROVIDE_HIDDEN (__preinit_array_start = .);
50        KEEP(*(.preinit_array))
51        PROVIDE_HIDDEN (__preinit_array_end = .);
52
53        . = ALIGN(4);
54        /* init data */
55        PROVIDE_HIDDEN (__init_array_start = .);
56        KEEP(*(SORT(.init_array.*)))
57        KEEP(*(.init_array))
58        PROVIDE_HIDDEN (__init_array_end = .);
59
60        . = ALIGN(4);
61        /* finit data */
62        PROVIDE_HIDDEN (__fini_array_start = .);
63        KEEP(*(SORT(.fini_array.*)))
64        KEEP(*(.fini_array))
65        PROVIDE_HIDDEN (__fini_array_end = .);
66
67        /* .copy.table */
68        . = ALIGN(4);
69        __copy_table_start__ = .;
70        LONG (__etext)
71        LONG (__data_start__)
72        LONG ((__data_end__ - __data_start__) / 4)
73        LONG (DEFINED(__etext2) ? __etext2 : 0)
74        LONG (DEFINED(__data2_start__) ? __data2_start__ : 0)
75        LONG (DEFINED(__data2_start__) ? ((__data2_end__ - __data2_start__) / 4) : 0)
76        __copy_table_end__ = .;
77
78        /* .zero.table */
79        . = ALIGN(4);
80        __zero_table_start__ = .;
81        LONG (__bss_start__)
82        LONG ((__bss_end__ - __bss_start__) / 4)
83        LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0)
84        LONG (DEFINED(__bss2_start__) ? ((__bss2_end__ - __bss2_start__) / 4) : 0)
85        __zero_table_end__ = .;
86
87        KEEP(*(.init))
88        KEEP(*(.fini))
89
90        /* .ctors */
91        *crtbegin.o(.ctors)
92        *crtbegin?.o(.ctors)
93        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
94        *(SORT(.ctors.*))
95        *(.ctors)
96
97        /* .dtors */
98         *crtbegin.o(.dtors)
99         *crtbegin?.o(.dtors)
100         *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
101         *(SORT(.dtors.*))
102         *(.dtors)
103
104        *(.rodata*)
105
106        KEEP(*(.eh_frame*))
107    } > FLASH
108
109    .ARM.extab :
110    {
111        *(.ARM.extab* .gnu.linkonce.armextab.*)
112    } > FLASH
113
114    __exidx_start = .;
115    .ARM.exidx :
116    {
117        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
118    } > FLASH
119    __exidx_end = .;
120
121    __etext = ALIGN(4);
122
123    .data : AT (__etext)
124    {
125        __data_start__ = .;
126        *(vtable)
127        *(.data*)
128
129        KEEP(*(.jcr*))
130        . = ALIGN(4);
131        /* All data end */
132        __data_end__ = .;
133
134    } > RAM
135
136    .bss :
137    {
138        . = ALIGN(4);
139        __bss_start__ = .;
140        *(.bss*)
141        *(COMMON)
142        . = ALIGN(4);
143        __bss_end__ = .;
144    } > RAM
145
146    bss_size = __bss_end__ - __bss_start__;
147
148    .stack : ALIGN(32)
149    {
150        . += __stack_size__;
151    } > RAM
152    __StackLimit = ADDR(.stack);
153    __StackTop = ADDR(.stack) + SIZEOF(.stack);
154
155    .heap : ALIGN(8)
156    {
157        . = ALIGN(8);
158        __end__ = .;
159        PROVIDE(end = .);
160        __HeapBase = .;
161        . += __heap_size__;
162        __HeapLimit = .;
163        __heap_limit = .; /* Add for _sbrk */
164    } > RAM
165
166    PROVIDE(__stack = __StackTop);
167}
168