2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 __flash_size = 4K - 0x300;
27 * SPDX-License-Identifier: BSD-3-Clause
29 * Copyright © 2019 Keith Packard
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above
39 * copyright notice, this list of conditions and the following
40 * disclaimer in the documentation and/or other materials provided
41 * with the distribution.
43 * 3. Neither the name of the copyright holder nor the names of its
44 * contributors may be used to endorse or promote products derived
45 * from this software without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
50 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
51 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
52 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58 * OF THE POSSIBILITY OF SUCH DAMAGE.
64 * These values should be provided by the application. We'll include
65 * some phony values here to make things link for testing
70 low (rxai!w) : ORIGIN = 0x0, LENGTH = 0x2fc
71 no_isp (rxai!w): ORIGIN = 0x2fc, LENGTH = 4
72 flash (rxai!w) : ORIGIN = DEFINED(__flash) ? __flash : 0x10000000, LENGTH = DEFINED(__flash_size) ? __flash_size : 0x10000
73 ram (wxa!ri) : ORIGIN = DEFINED(__ram ) ? __ram : 0x20000000, LENGTH = DEFINED(__ram_size ) ? __ram_size : 0x08000
86 PROVIDE(__stack = ORIGIN(ram) + LENGTH(ram));
89 KEEP (*(.text.init.enter))
90 KEEP (*(.data.init.enter))
91 KEEP (*(SORT_BY_NAME(.init) SORT_BY_NAME(.init.*)))
95 ao_boot_chain.o(.text .text.*)
96 ao_boot_pin.o(.text .text.*)
97 ao_flash_loader_lpc.o(.text .text.*)
98 ao_notask.o(*.text .text.*)
99 ao_product.o(.rodata .rodata.*)
104 } > no_isp AT>no_isp :text
109 *(.text.unlikely .text.unlikely.*)
110 *(.text.startup .text.startup.*)
113 KEEP (*(.fini .fini.*))
116 PROVIDE (__etext = __text_end);
117 PROVIDE (_etext = __text_end);
118 PROVIDE (etext = __text_end);
129 *(.srodata .srodata.*)
130 *(.data.rel.ro .data.rel.ro.*)
133 /* Need to pre-align so that the symbols come after padding */
136 /* lists of constructors and destructors */
137 PROVIDE_HIDDEN ( __preinit_array_start = . );
138 KEEP (*(.preinit_array))
139 PROVIDE_HIDDEN ( __preinit_array_end = . );
141 PROVIDE_HIDDEN ( __init_array_start = . );
142 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
143 KEEP (*(.init_array .ctors))
144 PROVIDE_HIDDEN ( __init_array_end = . );
146 PROVIDE_HIDDEN ( __fini_array_start = . );
147 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
148 KEEP (*(.fini_array .dtors))
149 PROVIDE_HIDDEN ( __fini_array_end = . );
150 } >flash AT>flash :text
152 /* additional sections when compiling with C++ exception support */
155 *(.gcc_except_table *.gcc_except_table.*)
156 KEEP (*(.eh_frame .eh_frame.*))
157 *(.ARM.extab* .gnu.linkonce.armextab.*)
158 } >flash AT>flash :text
160 .except_unordered : {
163 PROVIDE(__exidx_start = .);
165 PROVIDE(__exidx_end = .);
166 } >flash AT>flash :text
170 * Data values which are preserved across reset
172 .preserve (NOLOAD) : {
173 PROVIDE(__preserve_start__ = .);
174 KEEP(*(SORT_BY_NAME(.preserve.*)))
176 PROVIDE(__preserve_end__ = .);
179 .data : ALIGN_WITH_INPUT {
183 /* Need to pre-align so that the symbols come after padding */
186 PROVIDE( __global_pointer$ = . + 0x800 );
187 *(.sdata .sdata.* .sdata2.*)
189 } >ram AT>flash :ram_init
190 PROVIDE(__data_start = ADDR(.data));
191 PROVIDE(__data_source = LOADADDR(.data));
193 /* Thread local initialized data. This gets
194 * space allocated as it is expected to be placed
195 * in ram to be used as a template for TLS data blocks
196 * allocated at runtime. We're slightly abusing that
197 * by placing the data in flash where it will be copied
198 * into the allocate ram addresses by the existing
199 * data initialization code in crt0
201 .tdata : ALIGN_WITH_INPUT {
202 *(.tdata .tdata.* .gnu.linkonce.td.*)
203 PROVIDE(__data_end = .);
204 PROVIDE(__tdata_end = .);
205 } >ram AT>flash :tls :ram_init
206 PROVIDE( __tls_base = ADDR(.tdata));
207 PROVIDE( __tdata_start = ADDR(.tdata));
208 PROVIDE( __tdata_source = LOADADDR(.tdata) );
209 PROVIDE( __tdata_source_end = LOADADDR(.tdata) + SIZEOF(.tdata) );
210 PROVIDE( __tdata_size = SIZEOF(.tdata) );
212 PROVIDE( __edata = __data_end );
213 PROVIDE( _edata = __data_end );
214 PROVIDE( edata = __data_end );
215 PROVIDE( __data_size = __data_end - __data_start );
218 *(.tbss .tbss.* .gnu.linkonce.tb.*)
220 PROVIDE( __tls_end = . );
221 PROVIDE( __tbss_end = . );
222 } >ram AT>ram :tls :ram
223 PROVIDE( __bss_start = ADDR(.tbss));
224 PROVIDE( __tbss_start = ADDR(.tbss));
225 PROVIDE( __tbss_size = SIZEOF(.tbss) );
226 PROVIDE( __tls_size = __tls_end - __tls_base );
229 * The linker special cases .tbss segments which are
230 * identified as segments which are not loaded and are
233 * For these segments, the linker does not advance 'dot'
234 * across them. We actually need memory allocated for tbss,
235 * so we create a special segment here just to make room
237 .tbss_space (NOLOAD) : {
238 . = . + SIZEOF(.tbss);
243 *(.gnu.linkonce.sb.*)
252 PROVIDE( __end = __bss_end );
253 PROVIDE( _end = __bss_end );
254 PROVIDE( end = __bss_end );
255 PROVIDE( __bss_size = __bss_end - __bss_start );
257 /* Make the rest of memory available for heap storage */
258 PROVIDE (__heap_start = __end);
259 PROVIDE (__heap_end = __stack - (DEFINED(__stack_size) ? __stack_size : 0x800));
260 PROVIDE (__heap_size = __heap_end - __heap_start);
262 /* Define a stack region to make sure it fits in memory */
264 . += (DEFINED(__stack_size) ? __stack_size : 0x800);
267 /* Throw away C++ exception handling information */
273 *(.eh_frame .eh_frame.*)
274 *(.ARM.extab* .gnu.linkonce.armextab.*)