fix based on https://gist.github.com/timbrom/1942280
[DSO138] / STM32F10x_64k_20k_flash.ld
1 /*\r
2 Default linker script for STM32F10x_64K_20K\r
3 Copyright RAISONANCE S.A.S. 2008\r
4 */\r
5 \r
6 /* include the common STM32F10x sub-script */\r
7 \r
8 /* Common part of the linker scripts for STM32 devices*/\r
9 \r
10 \r
11 /* default stack sizes. \r
12 \r
13 These are used by the startup in order to allocate stacks for the different modes.\r
14 */\r
15 \r
16 __Stack_Size = 1024 ;\r
17 \r
18 PROVIDE ( _Stack_Size = __Stack_Size ) ;\r
19 \r
20 __Stack_Init = _estack  - __Stack_Size ;\r
21 \r
22 /*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/\r
23 PROVIDE ( _Stack_Init = __Stack_Init ) ;\r
24 \r
25 /*\r
26 There will be a link error if there is not this amount of RAM free at the end.\r
27 */\r
28 _Minimum_Stack_Size = 0x100 ;\r
29 \r
30 \r
31 /* include the memory spaces definitions sub-script */\r
32 /*\r
33 Linker subscript for STM32F10x definitions with 64K Flash and 20K RAM */\r
34 \r
35 /* Memory Spaces Definitions */\r
36 \r
37 MEMORY\r
38 {\r
39   RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K\r
40   FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K\r
41   FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
42   EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
43   EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
44   EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
45   EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
46 }\r
47 \r
48 /* higher address of the user mode stack */\r
49 _estack = 0x20005000;\r
50 \r
51 \r
52 \r
53 /* include the sections management sub-script for FLASH mode */\r
54 /*\r
55 Common part of the linker scripts for STR71x devices in FLASH mode\r
56 (that is, the FLASH is seen at 0)\r
57 Copyright RAISONANCE 2005\r
58 You can use, modify and distribute thisfile freely, but without any waranty.\r
59 */\r
60 \r
61 \r
62 \r
63 /* Sections Definitions */\r
64 \r
65 SECTIONS\r
66 {\r
67     /* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */\r
68     .isr_vector :\r
69     {\r
70         . = ALIGN(4);\r
71         KEEP(*(.isr_vector))            /* Startup code */\r
72         . = ALIGN(4);\r
73     } >FLASH\r
74  \r
75     /* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */\r
76     .flashtext :\r
77     {\r
78         . = ALIGN(4);\r
79         *(.flashtext)            /* Startup code */\r
80         . = ALIGN(4);\r
81     } >FLASH\r
82  \r
83     \r
84     /* the program code is stored in the .text section, which goes to Flash */\r
85     .text :\r
86     {\r
87             . = ALIGN(4);\r
88             \r
89         *(.text)                   /* remaining code */\r
90         *(.text.*)                   /* remaining code */\r
91         *(.rodata)                 /* read-only data (constants) */\r
92         *(.rodata*)\r
93         *(.glue_7)\r
94         *(.glue_7t)\r
95 \r
96             . = ALIGN(4);\r
97          _etext = .;\r
98             /* This is used by the startup in order to initialize the .data secion */\r
99          _sidata = _etext;\r
100     } >FLASH\r
101     \r
102  \r
103 \r
104     /* This is the initialized data section\r
105     The program executes knowing that the data is in the RAM\r
106     but the loader puts the initial values in the FLASH (inidata).\r
107     It is one task of the startup to copy the initial values from FLASH to RAM. */\r
108     .data  : AT ( _sidata )\r
109     {\r
110             . = ALIGN(4);\r
111         /* This is used by the startup in order to initialize the .data secion */\r
112         _sdata = . ;\r
113         \r
114         *(.data)\r
115         *(.data.*)\r
116 \r
117             . = ALIGN(4);\r
118             /* This is used by the startup in order to initialize the .data secion */\r
119          _edata = . ;\r
120     } >RAM\r
121     \r
122     \r
123 \r
124     /* This is the uninitialized data section */\r
125     .bss :\r
126     {\r
127             . = ALIGN(4);\r
128         /* This is used by the startup in order to initialize the .bss secion */\r
129         _sbss = .;\r
130         \r
131         *(.bss)\r
132         *(COMMON)\r
133         \r
134             . = ALIGN(4);\r
135             /* This is used by the startup in order to initialize the .bss secion */\r
136          _ebss = . ;\r
137     } >RAM\r
138     \r
139     PROVIDE ( end = _ebss );\r
140     PROVIDE ( _end = _ebss );\r
141     \r
142     /* This is the user stack section \r
143     This is just to check that there is enough RAM left for the User mode stack\r
144     It should generate an error if it's full.\r
145      */\r
146     ._usrstack :\r
147     {\r
148             . = ALIGN(4);\r
149         _susrstack = . ;\r
150         \r
151         . = . + _Minimum_Stack_Size ;\r
152         \r
153             . = ALIGN(4);\r
154         _eusrstack = . ;\r
155     } >RAM\r
156     \r
157 \r
158    \r
159     /* this is the FLASH Bank1 */\r
160     /* the C or assembly source must explicitly place the code or data there\r
161     using the "section" attribute */\r
162     .b1text :\r
163     {\r
164         *(.b1text)                   /* remaining code */\r
165         *(.b1rodata)                 /* read-only data (constants) */\r
166         *(.b1rodata*)\r
167     } >FLASHB1\r
168     \r
169     /* this is the EXTMEM */\r
170     /* the C or assembly source must explicitly place the code or data there\r
171     using the "section" attribute */\r
172     \r
173     /* EXTMEM Bank0 */\r
174     .eb0text :\r
175     {\r
176         *(.eb0text)                   /* remaining code */\r
177         *(.eb0rodata)                 /* read-only data (constants) */\r
178         *(.eb0rodata*)\r
179     } >EXTMEMB0\r
180     \r
181     /* EXTMEM Bank1 */\r
182     .eb1text :\r
183     {\r
184         *(.eb1text)                   /* remaining code */\r
185         *(.eb1rodata)                 /* read-only data (constants) */\r
186         *(.eb1rodata*)\r
187     } >EXTMEMB1\r
188     \r
189     /* EXTMEM Bank2 */\r
190     .eb2text :\r
191     {\r
192         *(.eb2text)                   /* remaining code */\r
193         *(.eb2rodata)                 /* read-only data (constants) */\r
194         *(.eb2rodata*)\r
195     } >EXTMEMB2\r
196     \r
197     /* EXTMEM Bank0 */\r
198     .eb3text :\r
199     {\r
200         *(.eb3text)                   /* remaining code */\r
201         *(.eb3rodata)                 /* read-only data (constants) */\r
202         *(.eb3rodata*)\r
203     } >EXTMEMB3\r
204     \r
205     \r
206     \r
207     /* after that it's only debugging information. */\r
208     \r
209     /* remove the debugging information from the standard libraries */\r
210     DISCARD :\r
211     {\r
212      libc.a ( * )\r
213      libm.a ( * )\r
214      libgcc.a ( * )\r
215      }\r
216 \r
217     /* Stabs debugging sections.  */\r
218     .stab          0 : { *(.stab) }\r
219     .stabstr       0 : { *(.stabstr) }\r
220     .stab.excl     0 : { *(.stab.excl) }\r
221     .stab.exclstr  0 : { *(.stab.exclstr) }\r
222     .stab.index    0 : { *(.stab.index) }\r
223     .stab.indexstr 0 : { *(.stab.indexstr) }\r
224     .comment       0 : { *(.comment) }\r
225     /* DWARF debug sections.\r
226        Symbols in the DWARF debugging sections are relative to the beginning\r
227        of the section so we begin them at 0.  */\r
228     /* DWARF 1 */\r
229     .debug          0 : { *(.debug) }\r
230     .line           0 : { *(.line) }\r
231     /* GNU DWARF 1 extensions */\r
232     .debug_srcinfo  0 : { *(.debug_srcinfo) }\r
233     .debug_sfnames  0 : { *(.debug_sfnames) }\r
234     /* DWARF 1.1 and DWARF 2 */\r
235     .debug_aranges  0 : { *(.debug_aranges) }\r
236     .debug_pubnames 0 : { *(.debug_pubnames) }\r
237     /* DWARF 2 */\r
238     .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }\r
239     .debug_abbrev   0 : { *(.debug_abbrev) }\r
240     .debug_line     0 : { *(.debug_line) }\r
241     .debug_frame    0 : { *(.debug_frame) }\r
242     .debug_str      0 : { *(.debug_str) }\r
243     .debug_loc      0 : { *(.debug_loc) }\r
244     .debug_macinfo  0 : { *(.debug_macinfo) }\r
245     /* SGI/MIPS DWARF 2 extensions */\r
246     .debug_weaknames 0 : { *(.debug_weaknames) }\r
247     .debug_funcnames 0 : { *(.debug_funcnames) }\r
248     .debug_typenames 0 : { *(.debug_typenames) }\r
249     .debug_varnames  0 : { *(.debug_varnames) }\r
250 }\r
251 \r