1/**
2 * \file
3 *
4 * \brief Linker script for running in internal FLASH on the SAMD51P19A
5 *
6 * Copyright (c) 2019 Microchip Technology Inc.
7 *
8 * \asf_license_start
9 *
10 * \page License
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License"); you may
15 * not use this file except in compliance with the License.
16 * You may obtain a copy of the Licence at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *
26 * \asf_license_stop
27 *
28 */
29
30
31OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
32OUTPUT_ARCH(arm)
33SEARCH_DIR(.)
34
35/* Memory Spaces Definitions */
36MEMORY
37{
38  rom      (rx)  : ORIGIN = 0x00000000, LENGTH = 0x00080000
39  ram      (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
40  bkupram  (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
41  qspi     (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
42}
43
44/* The stack size used by the application. NOTE: you need to adjust according to your application. */
45STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
46
47/* Section Definitions */
48SECTIONS
49{
50    .text :
51    {
52        . = ALIGN(4);
53        _sfixed = .;
54        KEEP(*(.vectors .vectors.*))
55        *(.text .text.* .gnu.linkonce.t.*)
56        *(.glue_7t) *(.glue_7)
57        *(.rodata .rodata* .gnu.linkonce.r.*)
58        *(.ARM.extab* .gnu.linkonce.armextab.*)
59
60        /* section information for finsh shell */
61        . = ALIGN(4);
62        __fsymtab_start = .;
63        KEEP(*(FSymTab))
64        __fsymtab_end = .;
65        . = ALIGN(4);
66        __vsymtab_start = .;
67        KEEP(*(VSymTab))
68        __vsymtab_end = .;
69        . = ALIGN(4);
70
71        /* section information for initial. */
72        . = ALIGN(4);
73        __rt_init_start = .;
74        KEEP(*(SORT(.rti_fn*)))
75        __rt_init_end = .;
76        . = ALIGN(4);
77
78        /* section information for utest */
79        . = ALIGN(4);
80        __rt_utest_tc_tab_start = .;
81        KEEP(*(UtestTcTab))
82        __rt_utest_tc_tab_end = .;
83
84        /* Support C constructors, and C destructors in both user code
85           and the C library. This also provides support for C++ code. */
86        . = ALIGN(4);
87        KEEP(*(.init))
88        . = ALIGN(4);
89        __preinit_array_start = .;
90        KEEP (*(.preinit_array))
91        __preinit_array_end = .;
92
93        . = ALIGN(4);
94        __init_array_start = .;
95        KEEP (*(SORT(.init_array.*)))
96        KEEP (*(.init_array))
97        __init_array_end = .;
98
99        . = ALIGN(4);
100        KEEP (*crtbegin.o(.ctors))
101        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
102        KEEP (*(SORT(.ctors.*)))
103        KEEP (*crtend.o(.ctors))
104
105        . = ALIGN(4);
106        KEEP(*(.fini))
107
108        . = ALIGN(4);
109        __fini_array_start = .;
110        KEEP (*(.fini_array))
111        KEEP (*(SORT(.fini_array.*)))
112        __fini_array_end = .;
113
114        KEEP (*crtbegin.o(.dtors))
115        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
116        KEEP (*(SORT(.dtors.*)))
117        KEEP (*crtend.o(.dtors))
118
119        . = ALIGN(4);
120        _efixed = .;            /* End of text section */
121    } > rom
122
123    /* .ARM.exidx is sorted, so has to go in its own output section.  */
124    PROVIDE_HIDDEN (__exidx_start = .);
125    .ARM.exidx :
126    {
127      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
128    } > rom
129    PROVIDE_HIDDEN (__exidx_end = .);
130
131    . = ALIGN(4);
132    _etext = .;
133
134    .relocate : AT (_etext)
135    {
136        . = ALIGN(4);
137        _srelocate = .;
138        *(.ramfunc .ramfunc.*);
139        *(.data .data.*);
140        . = ALIGN(4);
141        _erelocate = .;
142    } > ram
143
144    .bkupram (NOLOAD):
145    {
146        . = ALIGN(8);
147        _sbkupram = .;
148        *(.bkupram .bkupram.*);
149        . = ALIGN(8);
150        _ebkupram = .;
151    } > bkupram
152
153    .qspi (NOLOAD):
154    {
155        . = ALIGN(8);
156        _sqspi = .;
157        *(.qspi .qspi.*);
158        . = ALIGN(8);
159        _eqspi = .;
160    } > qspi
161
162    /* .bss section which is used for uninitialized data */
163    .bss (NOLOAD) :
164    {
165        . = ALIGN(4);
166        _sbss = . ;
167        _szero = .;
168        *(.bss .bss.*)
169        *(COMMON)
170        . = ALIGN(4);
171        _ebss = . ;
172        _ezero = .;
173    } > ram
174
175    /* stack section */
176    .stack (NOLOAD):
177    {
178        . = ALIGN(8);
179        _sstack = .;
180        . = . + STACK_SIZE;
181        . = ALIGN(8);
182        _estack = .;
183    } > ram
184
185    . = ALIGN(4);
186    _end = . ;
187    __bss_end = _end;
188    _ram_end_ = ORIGIN(ram) + LENGTH(ram) - 1 ;
189}
190