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 = 2048k /* 2048KB flash */
9    RAM1 (rw) : ORIGIN = 0x20000000, LENGTH =  192k /* 192K sram */
10    RAM2 (rw) : ORIGIN = 0x20040000, LENGTH =  384k /* 384K sram */
11    RAM3 (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        PROVIDE(__ctors_start__ = .);
52        KEEP (*(SORT(.init_array.*)))
53        KEEP (*(.init_array))
54        PROVIDE(__ctors_end__ = .);
55
56        . = ALIGN(4);
57        _etext = .;
58    } > ROM = 0
59
60    /* .ARM.exidx is sorted, so has to go in its own output section.  */
61    __exidx_start = .;
62    .ARM.exidx :
63    {
64        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
65
66        /* This is used by the startup in order to initialize the .data secion */
67        _sidata = .;
68    } > ROM
69    __exidx_end = .;
70
71    /* .data section which is used for initialized data */
72
73    .data : AT (_sidata)
74    {
75        . = ALIGN(4);
76        /* This is used by the startup in order to initialize the .data secion */
77        _sdata = . ;
78
79        *(.data)
80        *(.data.*)
81        *(.gnu.linkonce.d*)
82        PROVIDE(__dtors_start__ = .);
83        KEEP(*(SORT(.dtors.*)))
84        KEEP(*(.dtors))
85        PROVIDE(__dtors_end__ = .);
86
87        . = ALIGN(4);
88        /* This is used by the startup in order to initialize the .data secion */
89        _edata = . ;
90    } >RAM1
91
92    .stack :
93    {
94        . = ALIGN(4);
95        _sstack = .;
96        . = . + _system_stack_size;
97        . = ALIGN(4);
98        _estack = .;
99    } >RAM1
100
101    __bss_start = .;
102    .bss :
103    {
104        . = ALIGN(4);
105        /* This is used by the startup in order to initialize the .bss secion */
106        _sbss = .;
107
108        *(.bss)
109        *(.bss.*)
110        *(COMMON)
111
112        . = ALIGN(4);
113        /* This is used by the startup in order to initialize the .bss secion */
114        _ebss = . ;
115
116        *(.bss.init)
117    } > RAM1
118    __bss_end = .;
119
120    _end = .;
121
122    /* Stabs debugging sections.  */
123    .stab          0 : { *(.stab) }
124    .stabstr       0 : { *(.stabstr) }
125    .stab.excl     0 : { *(.stab.excl) }
126    .stab.exclstr  0 : { *(.stab.exclstr) }
127    .stab.index    0 : { *(.stab.index) }
128    .stab.indexstr 0 : { *(.stab.indexstr) }
129    .comment       0 : { *(.comment) }
130    /* DWARF debug sections.
131     * Symbols in the DWARF debugging sections are relative to the beginning
132     * of the section so we begin them at 0.  */
133    /* DWARF 1 */
134    .debug          0 : { *(.debug) }
135    .line           0 : { *(.line) }
136    /* GNU DWARF 1 extensions */
137    .debug_srcinfo  0 : { *(.debug_srcinfo) }
138    .debug_sfnames  0 : { *(.debug_sfnames) }
139    /* DWARF 1.1 and DWARF 2 */
140    .debug_aranges  0 : { *(.debug_aranges) }
141    .debug_pubnames 0 : { *(.debug_pubnames) }
142    /* DWARF 2 */
143    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
144    .debug_abbrev   0 : { *(.debug_abbrev) }
145    .debug_line     0 : { *(.debug_line) }
146    .debug_frame    0 : { *(.debug_frame) }
147    .debug_str      0 : { *(.debug_str) }
148    .debug_loc      0 : { *(.debug_loc) }
149    .debug_macinfo  0 : { *(.debug_macinfo) }
150    /* SGI/MIPS DWARF 2 extensions */
151    .debug_weaknames 0 : { *(.debug_weaknames) }
152    .debug_funcnames 0 : { *(.debug_funcnames) }
153    .debug_typenames 0 : { *(.debug_typenames) }
154    .debug_varnames  0 : { *(.debug_varnames) }
155}
156