1/*
2 * linker script for APM32F10x 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 = 512K /* 512K flash */
9    RAM (rw) : ORIGIN = 0x20000000, LENGTH = 128K /* 128K sram */
10}
11ENTRY(Reset_Handler)
12_system_stack_size = 0x400;
13
14SECTIONS
15{
16    .text :
17    {
18        . = ALIGN(4);
19        _stext = .;
20        KEEP(*(.isr_vector))            /* Startup code */
21
22        . = ALIGN(4);
23        *(.text)                        /* remaining code */
24        *(.text.*)                      /* remaining code */
25        *(.rodata)                      /* read-only data (constants) */
26        *(.rodata*)
27        *(.glue_7)
28        *(.glue_7t)
29        *(.gnu.linkonce.t*)
30
31        /* section information for finsh shell */
32        . = ALIGN(4);
33        __fsymtab_start = .;
34        KEEP(*(FSymTab))
35        __fsymtab_end = .;
36
37        . = ALIGN(4);
38        __vsymtab_start = .;
39        KEEP(*(VSymTab))
40        __vsymtab_end = .;
41
42        /* section information for initial. */
43        . = ALIGN(4);
44        __rt_init_start = .;
45        KEEP(*(SORT(.rti_fn*)))
46        __rt_init_end = .;
47
48        . = ALIGN(4);
49
50        PROVIDE(__ctors_start__ = .);
51        KEEP (*(SORT(.init_array.*)))
52        KEEP (*(.init_array))
53        PROVIDE(__ctors_end__ = .);
54
55        . = ALIGN(4);
56
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        _start_address_init_data = .;
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        _start_address_data = .;
80
81        *(.data)
82        *(.data.*)
83        *(.gnu.linkonce.d*)
84
85
86        PROVIDE(__dtors_start__ = .);
87        KEEP(*(SORT(.dtors.*)))
88        KEEP(*(.dtors))
89        PROVIDE(__dtors_end__ = .);
90
91        . = ALIGN(4);
92        /* This is used by the startup in order to initialize the .data secion */
93        _edata = . ;
94        _end_address_data = .;
95    } >RAM
96
97    .stack :
98    {
99        . = ALIGN(4);
100        _sstack = .;
101        . = . + _system_stack_size;
102        . = ALIGN(4);
103        _estack = .;
104        _end_stack = .;
105    } >RAM
106
107    __bss_start = .;
108    _start_address_bss = .;
109    .bss :
110    {
111        . = ALIGN(4);
112        /* This is used by the startup in order to initialize the .bss secion */
113        _sbss = .;
114
115        *(.bss)
116        *(.bss.*)
117        *(COMMON)
118
119        . = ALIGN(4);
120        /* This is used by the startup in order to initialize the .bss secion */
121        _ebss = . ;
122
123        *(.bss.init)
124    } > RAM
125    __bss_end = .;
126    _end_address_bss = .;
127
128    _end = .;
129
130    /* Stabs debugging sections.  */
131    .stab          0 : { *(.stab) }
132    .stabstr       0 : { *(.stabstr) }
133    .stab.excl     0 : { *(.stab.excl) }
134    .stab.exclstr  0 : { *(.stab.exclstr) }
135    .stab.index    0 : { *(.stab.index) }
136    .stab.indexstr 0 : { *(.stab.indexstr) }
137    .comment       0 : { *(.comment) }
138    /* DWARF debug sections.
139     * Symbols in the DWARF debugging sections are relative to the beginning
140     * of the section so we begin them at 0.  */
141    /* DWARF 1 */
142    .debug          0 : { *(.debug) }
143    .line           0 : { *(.line) }
144    /* GNU DWARF 1 extensions */
145    .debug_srcinfo  0 : { *(.debug_srcinfo) }
146    .debug_sfnames  0 : { *(.debug_sfnames) }
147    /* DWARF 1.1 and DWARF 2 */
148    .debug_aranges  0 : { *(.debug_aranges) }
149    .debug_pubnames 0 : { *(.debug_pubnames) }
150    /* DWARF 2 */
151    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
152    .debug_abbrev   0 : { *(.debug_abbrev) }
153    .debug_line     0 : { *(.debug_line) }
154    .debug_frame    0 : { *(.debug_frame) }
155    .debug_str      0 : { *(.debug_str) }
156    .debug_loc      0 : { *(.debug_loc) }
157    .debug_macinfo  0 : { *(.debug_macinfo) }
158    /* SGI/MIPS DWARF 2 extensions */
159    .debug_weaknames 0 : { *(.debug_weaknames) }
160    .debug_funcnames 0 : { *(.debug_funcnames) }
161    .debug_typenames 0 : { *(.debug_typenames) }
162    .debug_varnames  0 : { *(.debug_varnames) }
163}
164