1;/*
2; * Copyright (c) 2018-2022 ARM Limited
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         * To copy multiple ROM to RAM sections,
69         * define etext2/data2_start/data2_end and
70         * define __STARTUP_COPY_MULTIPLE in startup_stm32l5562xx_ns.S or
71         * startup_stm32l552xx_ns.S */
72        . = ALIGN(4);
73        __copy_table_start__ = .;
74        LONG (__etext)
75        LONG (__data_start__)
76        LONG ((__data_end__ - __data_start__) / 4)
77        LONG (DEFINED(__etext2) ? __etext2 : 0)
78        LONG (DEFINED(__data2_start__) ? __data2_start__ : 0)
79        LONG (DEFINED(__data2_start__) ? ((__data2_end__ - __data2_start__) / 4) : 0)
80        __copy_table_end__ = .;
81
82        /* .zero.table
83         * To clear multiple BSS sections,
84         * uncomment .zero.table and,
85         * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_stm32l5562xx_ns.S or
86         * startup_stm32l552xx_ns.S */
87        . = ALIGN(4);
88        __zero_table_start__ = .;
89        LONG (__bss_start__)
90        LONG ((__bss_end__ - __bss_start__) / 4)
91        LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0)
92        LONG (DEFINED(__bss2_start__) ? ((__bss2_end__ - __bss2_start__) / 4) : 0)
93        __zero_table_end__ = .;
94
95        KEEP(*(.init))
96        KEEP(*(.fini))
97
98        /* .ctors */
99        *crtbegin.o(.ctors)
100        *crtbegin?.o(.ctors)
101        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
102        *(SORT(.ctors.*))
103        *(.ctors)
104
105        /* .dtors */
106         *crtbegin.o(.dtors)
107         *crtbegin?.o(.dtors)
108         *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
109         *(SORT(.dtors.*))
110         *(.dtors)
111
112        *(.rodata*)
113
114        KEEP(*(.eh_frame*))
115    } > FLASH
116
117    .ARM.extab :
118    {
119        *(.ARM.extab* .gnu.linkonce.armextab.*)
120    } > FLASH
121
122    __exidx_start = .;
123    .ARM.exidx :
124    {
125        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
126    } > FLASH
127    __exidx_end = .;
128
129    __etext = ALIGN(4);
130
131    .testprotection NS_DATA_START :
132    {
133         *(.bss.NoInit);
134    } > RAM
135
136    .data (NS_DATA_START+NS_NO_INIT_DATA_SIZE) : AT (__etext)
137    {
138        __data_start__ = .;
139        *(vtable)
140        *(.data*)
141
142        KEEP(*(.jcr*))
143        . = ALIGN(4);
144        /* All data end */
145        __data_end__ = .;
146
147    } > RAM
148
149    .bss :
150    {
151        . = ALIGN(4);
152        __bss_start__ = .;
153        *(.bss*)
154        *(COMMON)
155        . = ALIGN(4);
156        __bss_end__ = .;
157    } > RAM
158
159    bss_size = __bss_end__ - __bss_start__;
160
161    .stack : ALIGN(32)
162    {
163        . += __stack_size__;
164    } > RAM
165    __StackLimit = ADDR(.stack);
166    __StackTop = ADDR(.stack) + SIZEOF(.stack);
167
168    .heap : ALIGN(8)
169    {
170        __end__ = .;
171        PROVIDE(end = .);
172        __HeapBase = .;
173        . += __heap_size__;
174        __HeapLimit = .;
175        __heap_limit = .; /* Add for _sbrk */
176    } > RAM
177
178    PROVIDE(__stack = __StackTop);
179}
180