1/*
2 * linker script for STM32L4XX with GNU ld
3 */
4
5/* Program Entry, set to mark it as "used" and avoid gc */
6MEMORY
7{
8    ROM  (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
9    RAM1 (rw) : ORIGIN = 0x20000000, LENGTH =  96k /* 96K sram */
10
11    RAM2 (rw) : ORIGIN = 0x10000000, LENGTH =  32k /* 32K 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    } > ROM = 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    } > ROM
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        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    } > RAM2
94
95    .stack :
96    {
97        . = ALIGN(4);
98        _sstack = .;
99        . = . + _system_stack_size;
100        . = ALIGN(4);
101        _estack = .;
102    } > RAM2
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    } > RAM2
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