Skip to content

Commit 0350408

Browse files
aethanielfbraghiroli
authored andcommitted
[sme] Adding linker scripts
1 parent d4c10ff commit 0350408

File tree

2 files changed

+425
-0
lines changed

2 files changed

+425
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2015 Amel-Tech (a division of Amel Srl). All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
See the GNU Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
/* Linker script to configure memory regions.
21+
* Need modifying for a specific board.
22+
* FLASH.ORIGIN: starting address of flash
23+
* FLASH.LENGTH: length of flash
24+
* RAM.ORIGIN: starting address of RAM bank 0
25+
* RAM.LENGTH: length of RAM bank 0
26+
*/
27+
MEMORY
28+
{
29+
FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */
30+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000-0x0004 /* Last 4B used by bootloader */
31+
}
32+
33+
/* Linker script to place sections and symbol values. Should be used together
34+
* with other linker script that defines memory regions FLASH and RAM.
35+
* It references following symbols, which must be defined in code:
36+
* Reset_Handler : Entry of reset handler
37+
*
38+
* It defines following symbols, which code can use without definition:
39+
* __exidx_start
40+
* __exidx_end
41+
* __copy_table_start__
42+
* __copy_table_end__
43+
* __zero_table_start__
44+
* __zero_table_end__
45+
* __etext
46+
* __data_start__
47+
* __preinit_array_start
48+
* __preinit_array_end
49+
* __init_array_start
50+
* __init_array_end
51+
* __fini_array_start
52+
* __fini_array_end
53+
* __data_end__
54+
* __bss_start__
55+
* __bss_end__
56+
* __end__
57+
* end
58+
* __HeapLimit
59+
* __StackLimit
60+
* __StackTop
61+
* __stack
62+
*/
63+
ENTRY(Reset_Handler)
64+
65+
SECTIONS
66+
{
67+
.text :
68+
{
69+
KEEP(*(.isr_vector))
70+
*(.text*)
71+
72+
KEEP(*(.init))
73+
KEEP(*(.fini))
74+
75+
/* .ctors */
76+
*crtbegin.o(.ctors)
77+
*crtbegin?.o(.ctors)
78+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
79+
*(SORT(.ctors.*))
80+
*(.ctors)
81+
82+
/* .dtors */
83+
*crtbegin.o(.dtors)
84+
*crtbegin?.o(.dtors)
85+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
86+
*(SORT(.dtors.*))
87+
*(.dtors)
88+
89+
*(.rodata*)
90+
91+
KEEP(*(.eh_frame*))
92+
} > FLASH
93+
94+
.ARM.extab :
95+
{
96+
*(.ARM.extab* .gnu.linkonce.armextab.*)
97+
} > FLASH
98+
99+
__exidx_start = .;
100+
.ARM.exidx :
101+
{
102+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
103+
} > FLASH
104+
__exidx_end = .;
105+
106+
/* To copy multiple ROM to RAM sections,
107+
* uncomment .copy.table section and,
108+
* define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
109+
/*
110+
.copy.table :
111+
{
112+
. = ALIGN(4);
113+
__copy_table_start__ = .;
114+
LONG (__etext)
115+
LONG (__data_start__)
116+
LONG (__data_end__ - __data_start__)
117+
LONG (__etext2)
118+
LONG (__data2_start__)
119+
LONG (__data2_end__ - __data2_start__)
120+
__copy_table_end__ = .;
121+
} > FLASH
122+
*/
123+
124+
/* To clear multiple BSS sections,
125+
* uncomment .zero.table section and,
126+
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
127+
/*
128+
.zero.table :
129+
{
130+
. = ALIGN(4);
131+
__zero_table_start__ = .;
132+
LONG (__bss_start__)
133+
LONG (__bss_end__ - __bss_start__)
134+
LONG (__bss2_start__)
135+
LONG (__bss2_end__ - __bss2_start__)
136+
__zero_table_end__ = .;
137+
} > FLASH
138+
*/
139+
140+
__etext = .;
141+
142+
.data : AT (__etext)
143+
{
144+
__data_start__ = .;
145+
*(vtable)
146+
*(.data*)
147+
148+
. = ALIGN(4);
149+
/* preinit data */
150+
PROVIDE_HIDDEN (__preinit_array_start = .);
151+
KEEP(*(.preinit_array))
152+
PROVIDE_HIDDEN (__preinit_array_end = .);
153+
154+
. = ALIGN(4);
155+
/* init data */
156+
PROVIDE_HIDDEN (__init_array_start = .);
157+
KEEP(*(SORT(.init_array.*)))
158+
KEEP(*(.init_array))
159+
PROVIDE_HIDDEN (__init_array_end = .);
160+
161+
162+
. = ALIGN(4);
163+
/* finit data */
164+
PROVIDE_HIDDEN (__fini_array_start = .);
165+
KEEP(*(SORT(.fini_array.*)))
166+
KEEP(*(.fini_array))
167+
PROVIDE_HIDDEN (__fini_array_end = .);
168+
169+
KEEP(*(.jcr*))
170+
. = ALIGN(4);
171+
/* All data end */
172+
__data_end__ = .;
173+
174+
} > RAM
175+
176+
.bss :
177+
{
178+
. = ALIGN(4);
179+
__bss_start__ = .;
180+
*(.bss*)
181+
*(COMMON)
182+
. = ALIGN(4);
183+
__bss_end__ = .;
184+
} > RAM
185+
186+
.heap (COPY):
187+
{
188+
__end__ = .;
189+
PROVIDE(end = .);
190+
*(.heap*)
191+
__HeapLimit = .;
192+
} > RAM
193+
194+
/* .stack_dummy section doesn't contains any symbols. It is only
195+
* used for linker to calculate size of stack sections, and assign
196+
* values to stack symbols later */
197+
.stack_dummy (COPY):
198+
{
199+
*(.stack*)
200+
} > RAM
201+
202+
/* Set stack top to end of RAM, and stack limit move down by
203+
* size of stack_dummy section */
204+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
205+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
206+
PROVIDE(__stack = __StackTop);
207+
208+
__ram_end__ = ORIGIN(RAM) + LENGTH(RAM) -1 ;
209+
210+
/* Check if data + heap + stack exceeds RAM limit */
211+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
212+
}

0 commit comments

Comments
 (0)