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