Debian Codegraph @

tests/site_scons/platforms/stm32/stm32_ram.ld

raw
1 /* Linker script to configure memory regions.
2 * Need modifying for a specific board.
3 * FLASH.ORIGIN: starting address of flash
4 * FLASH.LENGTH: length of flash
5 * RAM.ORIGIN: starting address of RAM bank 0
6 * RAM.LENGTH: length of RAM bank 0
7 */
8 MEMORY
9 {
10 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128k
11 }
12
13 /* Linker script to place sections and symbol values. Should be used together
14 * with other linker script that defines memory regions FLASH and RAM.
15 * It references following symbols, which must be defined in code:
16 * Reset_Handler : Entry of reset handler
17 *
18 * It defines following symbols, which code can use without definition:
19 * __exidx_start
20 * __exidx_end
21 * __copy_table_start__
22 * __copy_table_end__
23 * __zero_table_start__
24 * __zero_table_end__
25 * __etext
26 * __data_start__
27 * __preinit_array_start
28 * __preinit_array_end
29 * __init_array_start
30 * __init_array_end
31 * __fini_array_start
32 * __fini_array_end
33 * __data_end__
34 * __bss_start__
35 * __bss_end__
36 * __end__
37 * end
38 * __HeapLimit
39 * __StackLimit
40 * __StackTop
41 * __stack
42 */
43 ENTRY(_start)
44
45 SECTIONS
46 {
47 .text :
48 {
49 KEEP(*(.isr_vector))
50 KEEP(*(.ramboot))
51 *(.text*)
52
53 KEEP(*(.init))
54 KEEP(*(.fini))
55
56 /* .ctors */
57 *crtbegin.o(.ctors)
58 *crtbegin?.o(.ctors)
59 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
60 *(SORT(.ctors.*))
61 *(.ctors)
62
63 /* .dtors */
64 *crtbegin.o(.dtors)
65 *crtbegin?.o(.dtors)
66 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
67 *(SORT(.dtors.*))
68 *(.dtors)
69
70 *(.rodata*)
71
72 KEEP(*(.eh_frame*))
73 } > RAM
74
75 .ARM.extab :
76 {
77 *(.ARM.extab* .gnu.linkonce.armextab.*)
78 } > RAM
79
80 __exidx_start = .;
81 .ARM.exidx :
82 {
83 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
84 } > RAM
85 __exidx_end = .;
86
87 /* To copy multiple ROM to RAM sections,
88 * uncomment .copy.table section and,
89 * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
90 /*
91 .copy.table :
92 {
93 . = ALIGN(4);
94 __copy_table_start__ = .;
95 LONG (__etext)
96 LONG (__data_start__)
97 LONG (__data_end__ - __data_start__)
98 LONG (__etext2)
99 LONG (__data2_start__)
100 LONG (__data2_end__ - __data2_start__)
101 __copy_table_end__ = .;
102 } > FLASH
103 */
104
105 /* To clear multiple BSS sections,
106 * uncomment .zero.table section and,
107 * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
108 /*
109 .zero.table :
110 {
111 . = ALIGN(4);
112 __zero_table_start__ = .;
113 LONG (__bss_start__)
114 LONG (__bss_end__ - __bss_start__)
115 LONG (__bss2_start__)
116 LONG (__bss2_end__ - __bss2_start__)
117 __zero_table_end__ = .;
118 } > FLASH
119 */
120
121 /* Location counter can end up 2byte aligned with narrow Thumb code but
122 __etext is assumed by startup code to be the LMA of a section in RAM
123 which must be 4byte aligned */
124 __etext = ALIGN (4);
125
126 .data :
127 {
128 __data_start__ = .;
129 *(vtable)
130 *(.data*)
131
132 . = ALIGN(4);
133 /* preinit data */
134 PROVIDE_HIDDEN (__preinit_array_start = .);
135 KEEP(*(.preinit_array))
136 PROVIDE_HIDDEN (__preinit_array_end = .);
137
138 . = ALIGN(4);
139 /* init data */
140 PROVIDE_HIDDEN (__init_array_start = .);
141 KEEP(*(SORT(.init_array.*)))
142 KEEP(*(.init_array))
143 PROVIDE_HIDDEN (__init_array_end = .);
144
145
146 . = ALIGN(4);
147 /* finit data */
148 PROVIDE_HIDDEN (__fini_array_start = .);
149 KEEP(*(SORT(.fini_array.*)))
150 KEEP(*(.fini_array))
151 PROVIDE_HIDDEN (__fini_array_end = .);
152
153 KEEP(*(.jcr*))
154 . = ALIGN(4);
155 /* All data end */
156 __data_end__ = .;
157
158 } > RAM
159
160 .bss :
161 {
162 . = ALIGN(4);
163 __bss_start__ = .;
164 *(.bss*)
165 *(COMMON)
166 . = ALIGN(4);
167 __bss_end__ = .;
168 } > RAM
169
170 .heap (COPY):
171 {
172 __end__ = .;
173 PROVIDE(end = .);
174 *(.heap*)
175 __HeapLimit = .;
176 } > RAM
177
178 /* .stack_dummy section doesn't contains any symbols. It is only
179 * used for linker to calculate size of stack sections, and assign
180 * values to stack symbols later */
181 .stack_dummy (COPY):
182 {
183 *(.stack*)
184 } > RAM
185
186 /* Set stack top to end of RAM, and stack limit move down by
187 * size of stack_dummy section */
188 __StackTop = ORIGIN(RAM) + LENGTH(RAM);
189 __StackLimit = __StackTop - SIZEOF(.stack_dummy);
190 PROVIDE(__stack = __StackTop);
191
192 /* Check if data + heap + stack exceeds RAM limit */
193 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
194 }