-
Notifications
You must be signed in to change notification settings - Fork 18
/
sections.ld
431 lines (389 loc) · 17.6 KB
/
sections.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
/******************************************************************************
Filename : sections.ld
Author : eclipse-arm-gcc team, pry(modified)
Date : 27/02/2017
Description : Default linker script for Cortex-M (it includes specifics for STM32F[34]xx).
To make use of the multi-region initialisations, define
OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.c file.
******************************************************************************/
/* Memory Definitions *********************************************************
Description : This section will define the memory layout of the sytem. This section
requires modifying for a specific board. Typical settings for different
chips are listed below:
DTCM 64K, SRAM1 240K, SRAM2 16K, Flash 512k (R320/F512) - STM32F746
DTCM 128K, SRAM1 368K, SRAM2 16K, Flash 1024k (R512/F1024) - STM32F767
DTCM 128K, SRAM1 368K, SRAM2 16K, Flash 2048k (R1024/F2048) - STM32Hxxx
Component : .ORIGIN - Starting address of the memory region.
.LENGTH - Length of the region.
******************************************************************************/
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
EROMEM0 (rx) : ORIGIN = 0x00000000, LENGTH = 0
ERWMEM0 (xrw) : ORIGIN = 0xC0000000, LENGTH = 32768K
}
_Privileged_Functions_Region_Size = 32K;
_Privileged_Data_Region_Size = 512;
__FLASH_segment_start__ = ORIGIN( FLASH );
__FLASH_segment_end__ = __FLASH_segment_start__ + LENGTH( FLASH );
__privileged_functions_start__ = ORIGIN( FLASH );
__privileged_functions_end__ = __privileged_functions_start__ + _Privileged_Functions_Region_Size;
__SRAM_segment_start__ = ORIGIN( RAM );
__SRAM_segment_end__ = __SRAM_segment_start__ + LENGTH( RAM );
__privileged_data_start__ = ORIGIN( RAM );
__privileged_data_end__ = ORIGIN( RAM ) + _Privileged_Data_Region_Size;
/* End Memory Definitions ****************************************************/
/* Stack Definitions *********************************************************/
/* The '__stack' definition is required by crt0, do not remove it. */
__stack = ORIGIN(RAM) + LENGTH(RAM);
/* STM specific definition */
_estack = __stack;
/* Default stack sizes. These are used by the startup in order to allocate stacks for the different modes */
__Main_Stack_Size = 1024 ;
/* "PROVIDE" allows to easily override these values from an object file or the command line */
PROVIDE ( _Main_Stack_Size = __Main_Stack_Size );
__Main_Stack_Limit = __stack - __Main_Stack_Size ;
PROVIDE ( _Main_Stack_Limit = __Main_Stack_Limit ) ;
/* The default stack - There will be a link error if there is not this amount of RAM free at the end */
_Minimum_Stack_Size = 256 ;
/* End Stack Definitions *****************************************************/
/* Heap Definitions **********************************************************/
/* Default heap definitions.
* The heap start immediately after the last statically allocated
* .sbss/.noinit section, and extends up to the main stack limit.
*/
PROVIDE ( _Heap_Begin = _end_noinit ) ;
PROVIDE ( _Heap_Limit = __stack - __Main_Stack_Size ) ;
/* End Heap Definitions ******************************************************/
/* Entry Point Definitions ***************************************************/
/* The entry point is informative, for debuggers and simulators,
* since the Cortex-M vector points to it anyway.
*/
ENTRY(_start);
/* End Entry Point Definitions ***********************************************/
/* Section Definitions *******************************************************/
SECTIONS
{
/* Begin Section:.isr_vector **************************************************
Description : The interrupt section for Cortex-M devices.
Location : Flash
Component : .isr_vector - The ISR vector section.
.cfmconfig - The Freescale configuration words.
.after_vectors - The startup code and ISR.
******************************************************************************/
.isr_vector : ALIGN(4)
{
FILL(0xFF)
__vectors_start = ABSOLUTE(.) ;
/* STM specific definition */
__vectors_start__ = ABSOLUTE(.) ;
KEEP(*(.isr_vector))
*(privileged_functions)
/* Non privileged code is after _Privileged_Functions_Region_Size. */
__privileged_functions_actual_end__ = .;
. = _Privileged_Functions_Region_Size;
KEEP(*(.cfmconfig))
/* This section is here for convenience, to store the
* startup code at the beginning of the flash area, hoping that
* this will increase the readability of the listing.
*/
*(.after_vectors .after_vectors.*) /* Startup code and ISR */
} >FLASH
/* End Section:.isr_vector ***************************************************/
/* Begin Section:.inits *******************************************************
Description : Memory regions initialisation arrays. There are two kinds of arrays
for each RAM region, one for data and one for bss. Each is iterrated
at startup and the region initialisation is performed.
The data array includes:
- from (LOADADDR())
- region_begin (ADDR())
- region_end (ADDR()+SIZEOF())
The bss array includes:
- region_begin (ADDR())
- region_end (ADDR()+SIZEOF())
WARNING: It is mandatory that the regions are word aligned,
since the initialisation code works only on words.
Location : Flash
Component : .data.* - The data section initialization section.
.bss.* - The bss section initialization section.
.preinit_array - The preinit code to run before constructors.
.init_array - The constructor code for global C++ objects.
.fini_array - The destructor code for global C++ objects.
******************************************************************************/
.inits : ALIGN(4)
{
/* The data array */
__data_regions_array_start = .;
LONG(LOADADDR(.data));
LONG(ADDR(.data));
LONG(ADDR(.data)+SIZEOF(.data));
__data_regions_array_end = .;
/* The bss array */
__bss_regions_array_start = .;
LONG(ADDR(.bss));
LONG(ADDR(.bss)+SIZEOF(.bss));
__bss_regions_array_end = .;
/* These are the old initialisation sections, intended to contain
* naked code, with the prologue/epilogue added by crti.o/crtn.o
* when linking with startup files. The standalone startup code
* currently does not run these, better use the init arrays below.
*/
KEEP(*(.init))
KEEP(*(.fini))
. = ALIGN(4);
/* The preinit code, i.e. an array of pointers to initialisation
* functions to be performed before constructors.
*/
PROVIDE_HIDDEN (__preinit_array_start = .);
/* Used to run the SystemInit() before anything else. */
KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*))
/* Used for other platform inits. */
KEEP(*(.preinit_array_platform .preinit_array_platform.*))
/* The application inits. If you need to enforce some order in execution, create new sections, as before. */
KEEP(*(.preinit_array .preinit_array.*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* The init code, i.e. an array of pointers to static constructors. */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* The fini code, i.e. an array of pointers to static destructors. */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* End Section:.inits ********************************************************/
/* Begin Section:.flashtext ***************************************************
Description : For some STRx devices, the beginning of the startup code is stored
in the .flashtext section, which goes to FLASH.
Location : Flash
Component : .flashtext - The STRx devices startup code.
******************************************************************************/
.flashtext : ALIGN(4)
{
*(.flashtext .flashtext.*)
} >FLASH
/* End Section:.flashtext ****************************************************/
/* Begin Section:.text ********************************************************
Description : The program code is stored in the .text section, which goes to FLASH.
Location : Flash
Component : .text - The code segment.
.rodata.* - The reaad-only data segment.
vtable - C++ vtable segment.
******************************************************************************/
.text : ALIGN(4)
{
/* All remaining code */
*(.text .text.*)
/* Read-only data (constants) */
*(.rodata .rodata.* .constdata .constdata.*)
/* C++ virtual tables */
*(vtable)
KEEP(*(.eh_frame*))
/* Stub sections generated by the linker, to glue together
* ARM and Thumb code. .glue_7 is used for ARM code calling
* Thumb code, and .glue_7t is used for Thumb code calling
* ARM code. Apparently always generated by the linker, for some
* architectures, so better leave them here.
*/
*(.glue_7)
*(.glue_7t)
} >FLASH
/* End Section:.text *********************************************************/
/* Begin Section:.ARM.extab,.ARM.exidx ****************************************
Description : ARM magic sections. You don't need them if you don't care about unwinding
(unwinding is useful for C++ exception and for debugging).
Location : Flash
Component : .ARM.extab - The ARM external tab for unwinding.
.ARM.exidx - The ARM external index for unwinding.
******************************************************************************/
.ARM.extab : ALIGN(4)
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} >FLASH
. = ALIGN(4);
__exidx_start = .;
.ARM.exidx : ALIGN(4)
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} >FLASH
__exidx_end = .;
. = ALIGN(4);
_etext = .;
__etext = .;
/* End Section:.ARM.extab,.ARM.exidx *****************************************/
/* Begin Section:.data ********************************************************
Description : The main initialized data section. The program executes knowing that
the data is in the RAM but the loader puts the initial values in the
FLASH (inidata). It is one task of the startup to copy the initial
values from FLASH to RAM.
Location : RAM
Component : .data - The sections to put into the RAM.
******************************************************************************/
/* Used by the startup code to initialise the .data section */
_sidata = LOADADDR(.data);
.data : ALIGN(8192)
{
FILL(0xFF)
/* This is used by the startup code to initialise the .data section */
_sdata = . ; /* STM specific definition */
__data_start__ = . ;
*(privileged_data)
/* Non kernel data is kept out of the first _Privileged_Data_Region_Size bytes of SRAM. */
__privileged_data_actual_end__ = .;
. = _Privileged_Data_Region_Size;
*(.data_begin .data_begin.*)
*(.data .data.*)
*(.data_end .data_end.*)
. = ALIGN(4);
/* This is used by the startup code to initialise the .data section */
_edata = . ; /* STM specific definition */
__data_end__ = . ;
} >RAM AT>FLASH
/* End Section:.data *********************************************************/
/* Begin Section:.bss *********************************************************
Description : The initialised-to-0 data sections. NOLOAD is used to avoid
the "section `.bss' type changed to PROGBITS" warning. This is the
main region which is placed in RAM.
Location : RAM
Component : .bss - The sections to put into the RAM, and initialized to 0.
******************************************************************************/
.bss (NOLOAD) : ALIGN(4)
{
__bss_start__ = .; /* standard newlib definition */
_sbss = .; /* STM specific definition */
*(.bss_begin .bss_begin.*)
*(.bss .bss.*)
*(COMMON)
*(.bss_end .bss_end.*)
. = ALIGN(4);
__bss_end__ = .; /* standard newlib definition */
_ebss = . ; /* STM specific definition */
} >RAM
/* End Section:.bss **********************************************************/
/* Begin Section:.noinit ******************************************************
Description : The uninitialised data sections. NOLOAD is used to avoid
the "section `.noinit' type changed to PROGBITS" warning.
Location : RAM
Component : .noinit - The sections to put into the RAM, and not initialized.
******************************************************************************/
.noinit (NOLOAD) : ALIGN(4)
{
_noinit = .;
*(.noinit .noinit.*)
. = ALIGN(4) ;
_end_noinit = .;
} >RAM
/* Mandatory to be word aligned, _sbrk assumes this */
PROVIDE ( end = _end_noinit ); /* was _ebss */
PROVIDE ( _end = _end_noinit );
PROVIDE ( __end = _end_noinit );
PROVIDE ( __end__ = _end_noinit );
/* End Section:.noinit *******************************************************/
/* Begin Section:._check_stack ************************************************
Description : Used for validation only, do not allocate anything here!
This is just to check that there is enough RAM left for the Main
stack. It should generate an error if it's full. This stack,
in composite, is the section for kernel stack. All the component
related layouts will be in the component sections that follow.
Location : RAM
Component : Padding of size "_Minimum_Stack_Size" - The stack location.
******************************************************************************/
._check_stack : ALIGN(4)
{
. = . + _Minimum_Stack_Size ;
} >RAM
/* End Section:._check_stack *************************************************/
/* Begin Section:.eromem0 *****************************************************
Description : This section should only be used when there is external read-only
direct-executable memory, such as Quad SPI Flash, Nor Flash, etc.
(Nand flash does not count!)
When there is no such sections, this can be commented out. When this
is used, use the section attribute to explicitly place the code/data.
Location : EROMEM0
Component : .ero0text - The code section in this area.
.ero0rodata - The ro-data section in this area.
******************************************************************************/
/*
.eromem0 : ALIGN(4)
{
*(.ero0text)
*(.ero0rodata)
*(.ero0rodata.*)
} >EROMEM0
*/
/* End Section:.eromem0 ******************************************************/
/* Begin Section:.erwmem0 *****************************************************
Description : This section should only be used when there is external read-write
direct-executable memory, such as SRAM, FRAM, SDRAM, etc.
When there is no such sections, this can be commented out. When this
is used, use the section attribute to explicitly place the code/data.
This section is not initialized in the init code. Thus, this area will
not be initialized at the startup. It is the user's duty to initialize
this area manually.
Location : EROMEM0
Component : .ero0text - The code section in this area.
.ero0rodata - The ro-data section in this area.
******************************************************************************/
.erwmem0 : ALIGN(4)
{
*(.erw0text)
*(.erw0data)
} >ERWMEM0
/* End Section:.erwmem0 ******************************************************/
/* Begin Section:.debugging ***************************************************
Description : These are debuggingsections.
Location : None.
Component : None.
******************************************************************************/
/* This can remove the debugging information from the standard libraries */
/*
DISCARD :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
*/
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/*
* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0.
*/
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* End Section:.debugging ****************************************************/
}
/* End Section Definitions ***************************************************/