1/* Memory regions.*/
2MEMORY
3{
4  FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
5  RAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 96K
6  RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K
7}
8
9/* Entry Point */
10ENTRY(Reset_Handler)
11
12/* Define output sections */
13SECTIONS
14{
15    .text :
16    {
17        KEEP(*(.isr_vector))
18        *(.text*)
19
20        KEEP(*(.init))
21        KEEP(*(.fini))
22
23        /* .ctors */
24        *crtbegin.o(.ctors)
25        *crtbegin?.o(.ctors)
26        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
27        *(SORT(.ctors.*))
28        *(.ctors)
29
30        /* .dtors */
31        *crtbegin.o(.dtors)
32        *crtbegin?.o(.dtors)
33        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
34        *(SORT(.dtors.*))
35        *(.dtors)
36
37        *(.rodata*)
38
39        KEEP(*(.eh_frame*))
40    } > FLASH
41
42    .ARM.extab :
43    {
44        *(.ARM.extab* .gnu.linkonce.armextab.*)
45    } > FLASH
46
47    __exidx_start = .;
48    .ARM.exidx :
49    {
50        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
51    } > FLASH
52    __exidx_end = .;
53
54    __etext = .;
55    _sidata = .;
56
57    .data : AT (__etext)
58    {
59        __data_start__ = .;
60        _sdata = .;
61        *(vtable)
62        *(.data*)
63
64        . = ALIGN(4);
65        /* preinit data */
66        PROVIDE_HIDDEN (__preinit_array_start = .);
67        KEEP(*(.preinit_array))
68        PROVIDE_HIDDEN (__preinit_array_end = .);
69
70        . = ALIGN(4);
71        /* init data */
72        PROVIDE_HIDDEN (__init_array_start = .);
73        KEEP(*(SORT(.init_array.*)))
74        KEEP(*(.init_array))
75        PROVIDE_HIDDEN (__init_array_end = .);
76
77
78        . = ALIGN(4);
79        /* finit data */
80        PROVIDE_HIDDEN (__fini_array_start = .);
81        KEEP(*(SORT(.fini_array.*)))
82        KEEP(*(.fini_array))
83        PROVIDE_HIDDEN (__fini_array_end = .);
84
85        KEEP(*(.jcr*))
86        . = ALIGN(4);
87        /* All data end */
88        __data_end__ = .;
89        _edata = .;
90
91    } > RAM
92
93    .bss :
94    {
95        . = ALIGN(4);
96        __bss_start__ = .;
97        _sbss = .;
98        *(.bss*)
99        *(COMMON)
100        . = ALIGN(4);
101        __bss_end__ = .;
102        _ebss = .;
103    } > RAM
104
105    .heap (COPY):
106    {
107        __end__ = .;
108        end = __end__;
109        *(.heap*)
110        __HeapLimit = .;
111    } > RAM
112
113    /* .stack_dummy section doesn't contains any symbols. It is only
114     * used for linker to calculate size of stack sections, and assign
115     * values to stack symbols later */
116    .stack_dummy (COPY):
117    {
118        *(.stack*)
119    } > RAM
120
121    /* Set stack top to end of RAM, and stack limit move down by
122     * size of stack_dummy section */
123    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
124    _estack = __StackTop;
125    __StackLimit = __StackTop - SIZEOF(.stack_dummy);
126    PROVIDE(__stack = __StackTop);
127
128    /* Check if data + heap + stack exceeds RAM limit */
129    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
130}
131