first commit
[clinton/Smoothieware.git] / gcc4mbed / build / mbed.ld
1 /*Copyright (C) 2011 by Sagar G V, Thejasvi M V
2
3 Permission is hereby granted, free of charge, to any person obtaining a copy
4 of this software and associated documentation files (the "Software"), to deal
5 in the Software without restriction, including without limitation the rights
6 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 copies of the Software, and to permit persons to whom the Software is
8 furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 THE SOFTWARE.
20 */
21 /* Updates:
22 Arthur Wolf & Adam Green in 2011 - Updated to work with mbed.
23 */
24
25 OUTPUT_FORMAT ("elf32-littlearm")
26 ENTRY(Reset_Handler)
27 SEARCH_DIR(.)
28
29 MEMORY
30 {
31 /* LPC1768 : 512k ROM + 64k SRAM */
32 /*------------------------------ */
33
34 /* On-chip ROM is a readable (r), executable region (x) */
35 /* On-chip SRAM is a readable (r), writable (w) and */
36 /* executable region (x) */
37
38 /* Main ROM region - 512k for LPC1768 */
39 IROM (rx) : ORIGIN = 0x00000000, LENGTH = 512k
40
41 /* local static RAM - 32k for LPC1768 */
42 IRAM0 (rwx) : ORIGIN = 0x10000000, LENGTH = 32k
43
44 /* AHB SRAM - 16k for LPC1768 - often used for USB */
45 IRAM1 (rwx) : ORIGIN = 0x2007C000, LENGTH = 16k
46 IRAM2 (rwx) : ORIGIN = 0x20080000, LENGTH = 16k
47 }
48
49 /* SECTION command : Define mapping of input sections */
50 /* into output sections. */
51
52 SECTIONS
53 {
54 /******************************************/
55 /* code section */
56
57 /* "normal" code */
58
59 .text :
60 {
61 KEEP(*(RESET))
62 *(.text .text.*)
63 *(.gnu.linkonce.t.*)
64 *(.glue_7)
65 *(.glue_7t)
66 *(.gcc_except_table)
67 *(.rodata .rodata*)
68 *(.gnu.linkonce.r.*)
69 . = ALIGN(4);
70 KEEP(*(.init))
71
72 . = ALIGN(4);
73 __preinit_array_start = .;
74 KEEP (*(.preinit_array))
75 __preinit_array_end = .;
76
77 . = ALIGN(4);
78 __init_array_start = .;
79 KEEP (*(SORT(.init_array.*)))
80 KEEP (*(.init_array))
81 __init_array_end = .;
82
83 . = ALIGN(0x4);
84 KEEP (*crtbegin.o(.ctors))
85 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
86 KEEP (*(SORT(.ctors.*)))
87 KEEP (*crtend.o(.ctors))
88
89 . = ALIGN(4);
90 KEEP(*(.fini))
91
92 . = ALIGN(4);
93 __fini_array_start = .;
94 KEEP (*(.fini_array))
95 KEEP (*(SORT(.fini_array.*)))
96 __fini_array_end = .;
97
98
99 . = ALIGN(0x4);
100 KEEP (*crtbegin.o(.dtors))
101 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
102 KEEP (*(SORT(.dtors.*)))
103 KEEP (*crtend.o(.dtors))
104
105 /* End Of .text section */
106 _etext = .;
107 _sifastcode = .;
108 } >IROM
109
110
111 __exidx_start = .;
112 .ARM.exidx :
113 {
114 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
115 } >IROM
116 __exidx_end = .;
117
118 /**************************************************/
119 /* fastcode - copied at startup & executed in RAM */
120
121 .fastcode :
122 {
123 . = ALIGN (4);
124 _sfastcode = . ;
125
126 *(.glue_7t) *(.glue_7)
127 *(.fastcode)
128
129 /* add other modules here ... */
130
131 . = ALIGN (4);
132 _efastcode = . ;
133 _sidata = .;
134 } >IRAM0 AT>IROM
135
136 /******************************************/
137 /* This used for USB RAM section */
138 .usb_ram (NOLOAD):
139 {
140 *.o (USB_RAM)
141 } > IRAM1
142
143 /******************************************/
144 /* data section */
145 .data :
146 {
147 _sidata = LOADADDR (.data);
148 . = ALIGN(4);
149 _sdata = .;
150
151 *(.ARM.__AT_0x10000000)
152 *(vtable vtable.*)
153 *(.data .data.*)
154 *(.gnu.linkonce.d*)
155
156 . = ALIGN(4);
157 _edata = . ;
158 } >IRAM0 AT>IROM
159
160 /******************************************/
161 /* For no-init variables section */
162 .bss (NOLOAD) :
163 {
164 . = ALIGN(4);
165 _sbss = . ;
166
167 *(.bss .bss.*)
168 *(.gnu.linkonce.b*)
169 *(COMMON)
170
171 . = ALIGN(4);
172 _ebss = . ;
173 } >IRAM0
174
175 /******************************************/
176 /* For stack section */
177 .stackarea (NOLOAD) :
178 {
179 . = ALIGN(8);
180 _sstack = .;
181
182 *(.stackarea .stackarea.*)
183
184 . = ALIGN(8);
185 _estack = .;
186
187 . = ALIGN(4);
188 _end = . ;
189 PROVIDE (end = .);
190 } > IRAM0
191 _stack = ORIGIN(IRAM0) + LENGTH(IRAM0);
192
193
194 /******************************************/
195 /* Stabs debugging sections. */
196 .stab 0 : { *(.stab) }
197 .stabstr 0 : { *(.stabstr) }
198 .stab.excl 0 : { *(.stab.excl) }
199 .stab.exclstr 0 : { *(.stab.exclstr) }
200 .stab.index 0 : { *(.stab.index) }
201 .stab.indexstr 0 : { *(.stab.indexstr) }
202 /* .comment 0 : { *(.comment) } */
203 /* DWARF debug sections.
204 Symbols in the DWARF debugging sections are relative to the beginning
205 of the section so we begin them at 0. */
206 /* DWARF 1 */
207 .debug 0 : { *(.debug) }
208 .line 0 : { *(.line) }
209 /* GNU DWARF 1 extensions */
210 .debug_srcinfo 0 : { *(.debug_srcinfo) }
211 .debug_sfnames 0 : { *(.debug_sfnames) }
212 /* DWARF 1.1 and DWARF 2 */
213 .debug_aranges 0 : { *(.debug_aranges) }
214 .debug_pubnames 0 : { *(.debug_pubnames) }
215 /* DWARF 2 */
216 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
217 .debug_abbrev 0 : { *(.debug_abbrev) }
218 .debug_line 0 : { *(.debug_line) }
219 .debug_frame 0 : { *(.debug_frame) }
220 .debug_str 0 : { *(.debug_str) }
221 .debug_loc 0 : { *(.debug_loc) }
222 .debug_macinfo 0 : { *(.debug_macinfo) }
223 /* SGI/MIPS DWARF 2 extensions */
224 .debug_weaknames 0 : { *(.debug_weaknames) }
225 .debug_funcnames 0 : { *(.debug_funcnames) }
226 .debug_typenames 0 : { *(.debug_typenames) }
227 .debug_varnames 0 : { *(.debug_varnames) }
228
229 /* TODO: Figure out how to properly deal with these. It looks like RealView might expect this symbol to come from
230 the main program and not mbed.ar These inline virtual methods provided by base classes end up having code
231 created for them by the class that use them (ie. LocalFileSystem instantiates code for
232 FileSystemLike::rename but doesn't instantiate the debug_frame)
233 */
234 PROVIDE (__ARM_grp_.debug_frame$i._ZN4mbed14FileSystemLike6renameEPKcS2_ = 0xBAADF00D);
235 PROVIDE (__ARM_grp_.debug_frame$i._ZN4mbed10DigitalOut5writeEi = 0xBAADF00D);
236 PROVIDE (__ARM_grp_.debug_frame$$$i._ZN4mbed14FileSystemLike6renameEPKcS2_$i._ZN4mbed14FileSystemLike6renameEPKcS2_ = 0xBAADF00D);
237 PROVIDE (__ARM_grp_.debug_frame$i._ZN4mbed14FileSystemLike5mkdirEPKci = 0xBAADF00D);
238 }