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