1/*
2 * linker script for STM32F4xx with GNU ld
3 * bernard.xiong 2009-10-14
4 * flybreak      2018-11-19  Add support for RAM2
5 */
6
7/* Program Entry, set to mark it as "used" and avoid gc */
8MEMORY
9{
10    CODE (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
11    RAM1 (rw) : ORIGIN = 0x20000000, LENGTH =  192k /* 192K sram */
12    RAM2 (rw) : ORIGIN = 0x10000000, LENGTH =   64k /* 64K sram */
13}
14ENTRY(Reset_Handler)
15_system_stack_size = 0x400;
16
17SECTIONS
18{
19    .text :
20    {
21        . = ALIGN(4);
22        _stext = .;
23        KEEP(*(.isr_vector))            /* Startup code */
24
25        . = ALIGN(4);
26        *(.text)                        /* remaining code */
27        *(.text.*)                      /* remaining code */
28        *(.rodata)                      /* read-only data (constants) */
29        *(.rodata*)
30        *(.glue_7)
31        *(.glue_7t)
32        *(.gnu.linkonce.t*)
33
34        /* section information for finsh shell */
35        . = ALIGN(4);
36        __fsymtab_start = .;
37        KEEP(*(FSymTab))
38        __fsymtab_end = .;
39
40        . = ALIGN(4);
41        __vsymtab_start = .;
42        KEEP(*(VSymTab))
43        __vsymtab_end = .;
44
45        /* section information for initial. */
46        . = ALIGN(4);
47        __rt_init_start = .;
48        KEEP(*(SORT(.rti_fn*)))
49        __rt_init_end = .;
50
51        . = ALIGN(4);
52
53        PROVIDE(__ctors_start__ = .);
54        KEEP (*(SORT(.init_array.*)))
55        KEEP (*(.init_array))
56        PROVIDE(__ctors_end__ = .);
57
58        . = ALIGN(4);
59
60        _etext = .;
61    } > CODE = 0
62
63    /* .ARM.exidx is sorted, so has to go in its own output section.  */
64    __exidx_start = .;
65    .ARM.exidx :
66    {
67        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
68
69        /* This is used by the startup in order to initialize the .data secion */
70        _sidata = .;
71    } > CODE
72    __exidx_end = .;
73
74    /* .data section which is used for initialized data */
75
76    .data : AT (_sidata)
77    {
78        . = ALIGN(4);
79        /* This is used by the startup in order to initialize the .data secion */
80        _sdata = . ;
81
82        *(.data)
83        *(.data.*)
84        *(.gnu.linkonce.d*)
85
86        PROVIDE(__dtors_start__ = .);
87        KEEP(*(SORT(.dtors.*)))
88        KEEP(*(.dtors))
89        PROVIDE(__dtors_end__ = .);
90
91        . = ALIGN(4);
92        /* This is used by the startup in order to initialize the .data secion */
93        _edata = . ;
94    } >RAM1
95
96    .stack :
97    {
98        . = ALIGN(4);
99        _sstack = .;
100        . = . + _system_stack_size;
101        . = ALIGN(4);
102        _estack = .;
103    } >RAM1
104
105    __bss_start = .;
106    .bss :
107    {
108        . = ALIGN(4);
109        /* This is used by the startup in order to initialize the .bss secion */
110        _sbss = .;
111
112        *(.bss)
113        *(.bss.*)
114        *(COMMON)
115
116        . = ALIGN(4);
117        /* This is used by the startup in order to initialize the .bss secion */
118        _ebss = . ;
119
120        *(.bss.init)
121    } > RAM1
122    __bss_end = .;
123
124    _end = .;
125
126    /* Stabs debugging sections.  */
127    .stab          0 : { *(.stab) }
128    .stabstr       0 : { *(.stabstr) }
129    .stab.excl     0 : { *(.stab.excl) }
130    .stab.exclstr  0 : { *(.stab.exclstr) }
131    .stab.index    0 : { *(.stab.index) }
132    .stab.indexstr 0 : { *(.stab.indexstr) }
133    .comment       0 : { *(.comment) }
134    /* DWARF debug sections.
135     * Symbols in the DWARF debugging sections are relative to the beginning
136     * of the section so we begin them at 0.  */
137    /* DWARF 1 */
138    .debug          0 : { *(.debug) }
139    .line           0 : { *(.line) }
140    /* GNU DWARF 1 extensions */
141    .debug_srcinfo  0 : { *(.debug_srcinfo) }
142    .debug_sfnames  0 : { *(.debug_sfnames) }
143    /* DWARF 1.1 and DWARF 2 */
144    .debug_aranges  0 : { *(.debug_aranges) }
145    .debug_pubnames 0 : { *(.debug_pubnames) }
146    /* DWARF 2 */
147    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
148    .debug_abbrev   0 : { *(.debug_abbrev) }
149    .debug_line     0 : { *(.debug_line) }
150    .debug_frame    0 : { *(.debug_frame) }
151    .debug_str      0 : { *(.debug_str) }
152    .debug_loc      0 : { *(.debug_loc) }
153    .debug_macinfo  0 : { *(.debug_macinfo) }
154    /* SGI/MIPS DWARF 2 extensions */
155    .debug_weaknames 0 : { *(.debug_weaknames) }
156    .debug_funcnames 0 : { *(.debug_funcnames) }
157    .debug_typenames 0 : { *(.debug_typenames) }
158    .debug_varnames  0 : { *(.debug_varnames) }
159}
160