blob: bcda98c47ec2969bdbe4a6090be5de63f3e3d7e7 [file] [log] [blame]
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01001/*
Per Åstrand81e01af2021-02-19 13:45:26 +01002 * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
Kristofer Jonsson43ce4912020-11-20 09:42:53 +01003 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010019__STACK_SIZE = 0x00008000;
20__HEAP_SIZE = 0x00008000;
21
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010022MEMORY
23{
Per Åstrand0b7bbb42021-03-25 12:34:24 +010024 ITCM (rx) : ORIGIN = 0x10000000, LENGTH = 0x00080000
25 SRAM (rw) : ORIGIN = 0x11000000, LENGTH = 0x01000000
26 DTCM (rw) : ORIGIN = 0x30000000, LENGTH = 0x00080000
27 DDR (rwx) : ORIGIN = 0x70000000, LENGTH = 0x60000000
28}
29
30PHDRS
31{
32 rom_exec PT_LOAD;
33 rom_dram PT_LOAD;
34 null PT_NULL;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010035}
36
37/* Linker script to place sections and symbol values. Should be used together
38 * with other linker script that defines memory regions ITCM and RAM.
39 * It references following symbols, which must be defined in code:
40 * Reset_Handler : Entry of reset handler
41 *
42 * It defines following symbols, which code can use without definition:
43 * __exidx_start
44 * __exidx_end
45 * __copy_table_start__
46 * __copy_table_end__
47 * __zero_table_start__
48 * __zero_table_end__
49 * __etext
50 * __data_start__
51 * __preinit_array_start
52 * __preinit_array_end
53 * __init_array_start
54 * __init_array_end
55 * __fini_array_start
56 * __fini_array_end
57 * __data_end__
58 * __bss_start__
59 * __bss_end__
60 * __end__
61 * end
62 * __HeapLimit
63 * __StackLimit
64 * __StackTop
65 * __stack
66 */
Per Åstrand0b7bbb42021-03-25 12:34:24 +010067
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010068ENTRY(Reset_Handler)
69
70SECTIONS
71{
72 .text :
73 {
74 KEEP(*(.vectors))
75 *(.text*)
76
77 KEEP(*(.init))
78 KEEP(*(.fini))
79
80 /* .ctors */
81 *crtbegin.o(.ctors)
82 *crtbegin?.o(.ctors)
83 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
84 *(SORT(.ctors.*))
85 *(.ctors)
86
87 /* .dtors */
88 *crtbegin.o(.dtors)
89 *crtbegin?.o(.dtors)
90 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
91 *(SORT(.dtors.*))
92 *(.dtors)
93
94 *(.rodata*)
95
96 KEEP(*(.eh_frame*))
Per Åstrand0b7bbb42021-03-25 12:34:24 +010097 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +010098
99 /*
100 * SG veneers:
101 * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100102 * must be set, either with the command line option '--section-start' or in a linker script,
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100103 * to indicate where to place these veneers in memory.
104 */
105/*
106 .gnu.sgstubs :
107 {
108 . = ALIGN(32);
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100109 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100110*/
111 .ARM.extab :
112 {
113 *(.ARM.extab* .gnu.linkonce.armextab.*)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100114 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100115
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100116 .ARM.exidx :
117 {
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100118 __exidx_start = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100119 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100120 __exidx_end = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100121 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100122
123 .copy.table :
124 {
125 . = ALIGN(4);
126 __copy_table_start__ = .;
127 LONG (__etext)
128 LONG (__data_start__)
129 LONG (__data_end__ - __data_start__)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100130
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100131 LONG (__eddr_data)
132 LONG (__sram_data_start__)
133 LONG (__sram_data_end__ - __sram_data_start__ )
134
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100135 __copy_table_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100136 } > ITCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100137
138 .zero.table :
139 {
140 . = ALIGN(4);
141 __zero_table_start__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100142 LONG (__bss_start__)
143 LONG (__bss_end__ - __bss_start__)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100144 __zero_table_end__ = .;
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100145
146 /**
147 * Location counter can end up 2byte aligned with narrow Thumb code but
148 * __etext is assumed by startup code to be the LMA of a section in DTCM
149 * which must be 4byte aligned
150 */
151 __etext = ALIGN (4);
152
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100153 } > ITCM :rom_exec
154
155 .data : AT(__etext)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100156 {
157 __data_start__ = .;
158 *(vtable)
159 *(.data)
160 *(.data.*)
161
162 . = ALIGN(4);
163 /* preinit data */
164 PROVIDE_HIDDEN (__preinit_array_start = .);
165 KEEP(*(.preinit_array))
166 PROVIDE_HIDDEN (__preinit_array_end = .);
167
168 . = ALIGN(4);
169 /* init data */
170 PROVIDE_HIDDEN (__init_array_start = .);
171 KEEP(*(SORT(.init_array.*)))
172 KEEP(*(.init_array))
173 PROVIDE_HIDDEN (__init_array_end = .);
174
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100175 . = ALIGN(4);
176 /* finit data */
177 PROVIDE_HIDDEN (__fini_array_start = .);
178 KEEP(*(SORT(.fini_array.*)))
179 KEEP(*(.fini_array))
180 PROVIDE_HIDDEN (__fini_array_end = .);
181
182 KEEP(*(.jcr*))
183 . = ALIGN(4);
184 /* All data end */
185 __data_end__ = .;
186
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100187 } > DTCM :rom_exec
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100188
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100189 .sram.bss :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100190 {
191 . = ALIGN(16);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100192#ifdef ETHOSU_FAST_MEMORY_SIZE
Per Åstrand81e01af2021-02-19 13:45:26 +0100193 *(.bss.ethosu_scratch);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100194#else
195 *(.bss.tensor_arena)
196#endif
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100197 *.(output_data_sec)
198 } > SRAM :null
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100199
200 .ddr :
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100201 {
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100202#ifdef ETHOSU_FAST_MEMORY_SIZE
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100203 . = ALIGN(16);
Jonny Svärdf521be92021-03-01 14:35:49 +0100204 *(.bss.tensor_arena)
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100205#endif
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100206 . = ALIGN(4);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100207 *(input_data_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100208 . = ALIGN(16);
209 *(network_model_sec)
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +0100210 *(expected_output_data_sec)
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100211 } > DDR :rom_dram
212
213 __eddr_data = ALIGN (16) ;
214 .sram.data : {
215 __sram_data_start__ = .;
216 *(.sram.data)
217 __sram_data_end__ = .;
218 } > SRAM AT >DDR :rom_dram
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100219
220 .bss :
221 {
222 . = ALIGN(4);
223 __bss_start__ = .;
224 *(.bss)
225 *(.bss.*)
226 *(COMMON)
227 . = ALIGN(4);
228 __bss_end__ = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100229 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100230
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100231 .heap (COPY) :
232 {
233 . = ALIGN(8);
234 __end__ = .;
235 PROVIDE(end = .);
236 . = . + __HEAP_SIZE;
237 . = ALIGN(8);
238 __HeapLimit = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100239 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100240
241 .stack (ORIGIN(DTCM) + LENGTH(DTCM) - __STACK_SIZE) (COPY) :
242 {
243 . = ALIGN(8);
244 __StackLimit = .;
245 . = . + __STACK_SIZE;
246 . = ALIGN(8);
247 __StackTop = .;
Per Åstrand0b7bbb42021-03-25 12:34:24 +0100248 } > DTCM :null
Kristofer Jonsson43ce4912020-11-20 09:42:53 +0100249 PROVIDE(__stack = __StackTop);
250
251 /* Check if data + heap + stack exceeds DTCM limit */
252 ASSERT(__StackLimit >= __HeapLimit, "region DTCM overflowed with stack")
253}