blob: e56a435a7431cd2ba8403100efb239ac7fc60f7a [file] [log] [blame]
Harald Welted8a003d2017-02-27 20:31:09 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2009, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
29
30/*------------------------------------------------------------------------------
31 * Linker script for running in internal FLASH on the ATSAM3S4
32 *----------------------------------------------------------------------------*/
33
34OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
35OUTPUT_ARCH(arm)
36SEARCH_DIR(.)
37
38/* Memory Spaces Definitions */
39MEMORY
40{
Harald Welteadba0ce2017-02-28 01:02:24 +010041 /* reserve the first 16k (= 0x4000) for the DFU bootloader */
Harald Welted8a003d2017-02-27 20:31:09 +010042 rom (rx) : ORIGIN = 0x00404000, LENGTH = 0x0003c000 /* flash, 256K */
Harald Welteadba0ce2017-02-28 01:02:24 +010043 /* reserve the first 32 (= 0x20) bytes for the _g_dfu struct */
44 ram (rwx) : ORIGIN = 0x20000020, LENGTH = 0x0000bfe0 /* sram, 48K */
Harald Welted8a003d2017-02-27 20:31:09 +010045}
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 /* Support C constructors, and C destructors in both user code
61 and the C library. This also provides support for C++ code. */
62 . = ALIGN(4);
63 KEEP(*(.init))
64 . = ALIGN(4);
65 __preinit_array_start = .;
66 KEEP (*(.preinit_array))
67 __preinit_array_end = .;
68
69 . = ALIGN(4);
70 __init_array_start = .;
71 KEEP (*(SORT(.init_array.*)))
72 KEEP (*(.init_array))
73 __init_array_end = .;
74
75 . = ALIGN(0x4);
76 KEEP (*crtbegin.o(.ctors))
77 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
78 KEEP (*(SORT(.ctors.*)))
79 KEEP (*crtend.o(.ctors))
80
81 . = ALIGN(4);
82 KEEP(*(.fini))
83
84 . = ALIGN(4);
85 __fini_array_start = .;
86 KEEP (*(.fini_array))
87 KEEP (*(SORT(.fini_array.*)))
88 __fini_array_end = .;
89
90 KEEP (*crtbegin.o(.dtors))
91 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
92 KEEP (*(SORT(.dtors.*)))
93 KEEP (*crtend.o(.dtors))
94
95 . = ALIGN(4);
96 _efixed = .; /* End of text section */
97 } > rom
98
99 /* .ARM.exidx is sorted, so has to go in its own output section. */
100 PROVIDE_HIDDEN (__exidx_start = .);
101 .ARM.exidx :
102 {
103 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
104 } > rom
105 PROVIDE_HIDDEN (__exidx_end = .);
106
107 . = ALIGN(4);
108 _etext = .;
109
110 .relocate : AT (_etext)
111 {
112 . = ALIGN(4);
113 _srelocate = .;
114 *(.ramfunc .ramfunc.*);
115 *(.data .data.*);
116 . = ALIGN(4);
117 _erelocate = .;
118 } > ram
119
120 /* .bss section which is used for uninitialized data */
121 .bss (NOLOAD) :
122 {
123 . = ALIGN(4);
124 _sbss = . ;
125 _szero = .;
126 *(.bss .bss.*)
127 *(COMMON)
128 . = ALIGN(4);
129 _ebss = . ;
130 _ezero = .;
131 } > ram
132
133 /* stack section */
134 .stack (NOLOAD):
135 {
136 . = ALIGN(8);
137 *(.stack .stack.*)
138 } > ram
139
140 . = ALIGN(4);
141 _end = . ;
142}