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