38
|
1 /* ---------------------------------------------------------------------------- */
|
|
2 /* Em::Blocks embedded development Support */
|
|
3 /* ---------------------------------------------------------------------------- */
|
|
4 /* Copyright (c) 2014, EmBlocks */
|
|
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 condition is met: */
|
|
10 /* */
|
|
11 /* - Redistributions of source code must retain the above copyright notice, */
|
|
12 /* this list of conditions and the disclaimer below. */
|
|
13 /* */
|
|
14 /* EmBlocks'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 EBLOCKS "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 EMBLOCKS 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 * Linker script for running in internal FLASH on the STM32F401RE
|
|
31 *----------------------------------------------------------------------------*/
|
|
32
|
|
33 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
|
34 OUTPUT_ARCH(arm)
|
|
35 SEARCH_DIR(.)
|
|
36
|
|
37 /* Memory Spaces Definitions */
|
|
38 MEMORY
|
|
39 {
|
|
40 ROM (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 80000 */
|
|
41 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
|
|
42 }
|
|
43 /* Linker script to place sections and symbol values. Should be used together
|
|
44 * with other linker script that defines memory regions FLASH and RAM.
|
|
45 * It references following symbols, which must be defined in code:
|
|
46 * Reset_Handler : Entry of reset handler
|
|
47 *
|
|
48 * It defines following symbols, which code can use without definition:
|
|
49 * __exidx_start
|
|
50 * __exidx_end
|
|
51 * __etext
|
|
52 * __data_start__
|
|
53 * __preinit_array_start
|
|
54 * __preinit_array_end
|
|
55 * __init_array_start
|
|
56 * __init_array_end
|
|
57 * __fini_array_start
|
|
58 * __fini_array_end
|
|
59 * __data_end__
|
|
60 * __bss_start__
|
|
61 * __bss_end__
|
|
62 * __end__
|
|
63 * end
|
|
64 * __HeapLimit
|
|
65 * __StackLimit
|
|
66 * __StackTop
|
|
67 * __stack
|
|
68 */
|
|
69
|
|
70
|
|
71 SECTIONS
|
|
72 {
|
40
|
73 .isr_vector 0x08000000 :
|
|
74 {
|
|
75 . = ALIGN(4);
|
|
76 KEEP( *(.isr_vector) )
|
|
77 KEEP(*(.init))
|
|
78 KEEP(*(.fini))
|
|
79 } >ROM
|
|
80
|
38
|
81 /* Place FirmwareData at absolute address */
|
|
82 .firmware_data 0x08005000:
|
|
83 {
|
40
|
84 cpu2_FirmwareData = 0;
|
|
85 KEEP( *(.firmware_data) )
|
38
|
86 } > ROM
|
|
87
|
40
|
88 .text 0x08005100 :
|
|
89 {
|
|
90 . = ALIGN(4);
|
|
91 *(.text) /* .text sections (code) */
|
38
|
92 *(.text*)
|
40
|
93 *(.eh_frame*)
|
|
94 . = ALIGN(4);
|
|
95
|
38
|
96 } > ROM
|
|
97
|
40
|
98 /********************** Constant data into ROM memory *********************/
|
|
99 .rodata :
|
|
100 {
|
|
101 . = ALIGN(4);
|
|
102 *(.rodata) /* .rodata sections (constants, strings, etc.) */
|
|
103 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
|
104 . = ALIGN(4);
|
|
105 } >ROM
|
|
106
|
38
|
107 .ARM.extab :
|
|
108 {
|
|
109 *(.ARM.extab* .gnu.linkonce.armextab.*)
|
|
110 } > ROM
|
|
111
|
|
112 __exidx_start = .;
|
|
113 .ARM.exidx :
|
|
114 {
|
|
115 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
|
116 } > ROM
|
|
117 __exidx_end = .;
|
|
118
|
40
|
119 .preinit_array :
|
|
120 {
|
|
121 . = ALIGN(4);
|
|
122 PROVIDE_HIDDEN( __preinit_array_start = . );
|
|
123 KEEP( *(.preinit_array*) )
|
|
124 PROVIDE_HIDDEN( __preinit_array_end = . );
|
|
125 . = ALIGN(4);
|
|
126 } >ROM
|
|
127
|
|
128 .init_array :
|
|
129 {
|
|
130 . = ALIGN(4);
|
|
131 PROVIDE_HIDDEN( __init_array_start = . );
|
|
132 KEEP( *(SORT(.init_array.*)) )
|
|
133 KEEP( *(.init_array*) )
|
|
134 PROVIDE_HIDDEN( __init_array_end = . );
|
|
135 . = ALIGN(4);
|
|
136 } >ROM
|
|
137
|
|
138 .fini_array :
|
|
139 {
|
|
140 . = ALIGN(4);
|
|
141 PROVIDE_HIDDEN( __fini_array_start = . );
|
|
142 KEEP( *(SORT(.fini_array.*)) )
|
|
143 KEEP( *(.fini_array*) )
|
|
144 PROVIDE_HIDDEN( __fini_array_end = . );
|
|
145 . = ALIGN(4);
|
|
146
|
|
147 __etext = .; /* define a global symbols at end of code */
|
|
148 } >ROM
|
38
|
149
|
40
|
150 /* Used by the startup to initialize data */
|
|
151 _sidata = LOADADDR(.data);
|
|
152
|
|
153 .data :
|
38
|
154 {
|
|
155 . = ALIGN(4);
|
40
|
156 __data_start__ = .;
|
|
157 _sdata = .; /* create a global symbol at data start */
|
|
158 *(.data) /* .data sections */
|
|
159 *(.data*)
|
|
160 *(vtable)
|
38
|
161 . = ALIGN(4);
|
|
162 /* All data end */
|
|
163 __data_end__ = .;
|
40
|
164 } >RAM AT>ROM
|
38
|
165
|
40
|
166 .bss :
|
38
|
167 {
|
|
168 __bss_start__ = .;
|
|
169 *(.bss*)
|
|
170 *(COMMON)
|
|
171 __bss_end__ = .;
|
40
|
172 } >RAM
|
38
|
173
|
40
|
174 .heap :
|
38
|
175 {
|
|
176 __end__ = .;
|
|
177 end = __end__;
|
|
178 *(.heap*)
|
|
179 __HeapLimit = .;
|
|
180 } > RAM
|
|
181
|
|
182 /* .stack_dummy section doesn't contains any symbols. It is only
|
|
183 * used for linker to calculate size of stack sections, and assign
|
|
184 * values to stack symbols later */
|
40
|
185 .stack_dummy :
|
38
|
186 {
|
|
187 *(.stack)
|
|
188 } > RAM
|
|
189
|
|
190 /* Set stack top to end of RAM, and stack limit move down by
|
|
191 * size of stack_dummy section */
|
|
192 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
|
193 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
|
194 PROVIDE(__stack = __StackTop);
|
|
195
|
|
196 /* Check if data + heap + stack exceeds RAM limit */
|
|
197 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
|
198 }
|