Make sure to create the logger first. Fixes a segfault due to a race with info downlo...
[Rockbox.git] / firmware / boot.lds
blobfc876b1d200f9fa0cbd8606cf528bdf372f1434e
1 #include "config.h"
3 ENTRY(start)
4 #ifdef CPU_COLDFIRE
5 OUTPUT_FORMAT(elf32-m68k)
6 INPUT(target/coldfire/crt0.o)
7 #elif defined (CPU_ARM)
8 OUTPUT_FORMAT(elf32-littlearm)
9 OUTPUT_ARCH(arm)
10 #ifdef CPU_PP
11 INPUT(target/arm/crt0-pp-bl.o)
12 #elif CONFIG_CPU==DM320
13 INPUT(target/arm/tms320dm320/crt0.o)
14 #elif CONFIG_CPU==S3C2440
15 INPUT(target/arm/s3c2440/crt0.o)
16 #elif defined(CPU_TCC77X)
17 INPUT(target/arm/tcc77x/crt0.o)
18 #elif defined(CPU_TCC780X)
19 INPUT(target/arm/tcc780x/crt0.o)
20 #elif CONFIG_CPU==IMX31L
21 INPUT(target/arm/imx31/crt0.o)
22 #else
23 INPUT(target/arm/crt0.o)
24 #endif
25 #else
26 OUTPUT_FORMAT(elf32-sh)
27 INPUT(target/sh/crt0.o)
28 #endif
30 #define DRAMSIZE (MEMORYSIZE * 0x100000)
32 #ifdef IRIVER_H100_SERIES
33 #define DRAMORIG 0x31000000
34 #define IRAMORIG 0x10000000
35 #define IRAMSIZE 0x18000
36 #define FLASHORIG 0x001f0000
37 #define FLASHSIZE 2M
38 #elif defined(IRIVER_H300_SERIES)
39 #define DRAMORIG 0x31000000
40 #define IRAMORIG 0x10000000
41 #define IRAMSIZE 0x18000
42 #define FLASHORIG 0x003f0000
43 #define FLASHSIZE 4M
44 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
45 #define DRAMORIG 0x31000000
46 #define IRAMORIG 0x10000000
47 #define IRAMSIZE 0x20000
48 #define FLASHORIG 0x00010000
49 #define FLASHSIZE 4M
50 #elif CONFIG_CPU == PP5020
51 #define DRAMORIG 0x10000000
52 #define IRAMORIG 0x40000000
53 #define IRAMSIZE 0x18000
54 #define FLASHORIG 0x001f0000
55 #define FLASHSIZE 2M
56 #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024)
57 #define DRAMORIG 0x10000000
58 #ifndef IRAMORIG
59 #define IRAMORIG 0x40000000
60 #endif
61 #define IRAMSIZE 0x20000
62 #define FLASHORIG 0x001f0000
63 #define FLASHSIZE 2M
64 #elif CONFIG_CPU == S3C2440
65 #define DRAMORIG 0x30000000
66 #define IRAMORIG 0x40000000
67 #define IRAMSIZE 4K
68 #define FLASHORIG 0x0000000
69 #define FLASHSIZE 1M
70 #elif CONFIG_CPU == DM320
71 #define DRAMORIG 0x00900000
72 #define IRAMORIG 0x00000000
73 #define IRAMSIZE 16K
74 #define FLASHORIG 0x00100000
75 #define FLASHSIZE 8M
76 #elif CONFIG_CPU == PP5002
77 #define DRAMORIG 0x28000000
78 #define IRAMORIG 0x40000000
79 #define IRAMSIZE 0x18000
80 #define FLASHORIG 0x001f0000
81 #define FLASHSIZE 2M
82 #elif CONFIG_CPU == IMX31L
83 #define DRAMORIG (0x02000000-0x00100000)
84 #undef  DRAMSIZE
85 #define DRAMSIZE (1 << 20) /* Limit 1 MB for bootloader */
86 #define IRAM DRAM
87 #define IRAMORIG 0x1FFFC000
88 #define IRAMSIZE 16K
89 #define FLASHORIG 0x0000000
90 #define FLASHSIZE 1M
91 #elif defined(CPU_TCC77X)
92 #define DRAMORIG 0x20000000
93 #define IRAMORIG 0x00000000
94 #define IRAMSIZE 64K
95 #define FLASHORIG 0x0000000
96 #define FLASHSIZE 1M
97 #elif defined(CPU_TCC780X)
98 #define DRAMORIG 0x20000000
99 #define IRAMORIG 0x00000000
100 #define IRAMSIZE 4K
101 #define FLASHORIG 0x0000000
102 #define FLASHSIZE 1M
103 #else
104 #define DRAMORIG 0x09000000
105 #define IRAMORIG 0x0f000000
106 #define IRAMSIZE 0x1000
107 #define FLASHORIG 0x02000000 + ROM_START
108 #define FLASHSIZE 256K - ROM_START
109 #endif
111 #if defined(CPU_TCC77X) || defined(CPU_TCC780X)
112 MEMORY
114 #ifdef TCCBOOT
115    DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
116 #else
117    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
118 #endif
119    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
121 #elif CONFIG_CPU == IMX31L
122 MEMORY
124    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
126 #elif !defined(CPU_PP) && (CONFIG_CPU!=S3C2440)
127 MEMORY
129    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
130    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
131    FLASH : ORIGIN = FLASHORIG, LENGTH = FLASHSIZE
133 #endif
135 SECTIONS
136 #ifdef CPU_PP
138   . = IRAMORIG;
140   .text : {
141     *(.init.text)
142     *(.text*)
143   }
145   .data : {
146     *(.icode)
147     *(.irodata)
148     *(.idata)
149     *(.data*)
150     _dataend = . ;
151    }
153   .stack :
154   {
155      *(.stack)
156      _stackbegin = .;
157      stackbegin = .;
158      . += 0x2000;
159      _stackend = .;
160      stackend = .;
161   }
163   /* The bss section is too large for IRAM - we just move it 16MB into the
164      DRAM */
166   . = (DRAMORIG+16*1024*1024);
167   .bss : {
168      _edata = .;
169      *(.bss*);
170      *(.ibss);
171      _end = .;
172    }
174 #elif (CONFIG_CPU==S3C2440)
176     . = DRAMORIG + 0x1000000;
178     .text : {
179         *(.init.text)
180         *(.text*)
181     }
183     .data : {
184         *(.icode)
185         *(.irodata)
186         *(.idata)
187         *(.data*)
188         . = ALIGN(0x4);
189         _dataend = . ;
190      }
192     .stack :
193     {
194          *(.stack)
195          _stackbegin = .;
196          stackbegin = .;
197          . += 0x2000;
198          _stackend = .;
199          stackend = .;
200     }
201     .bss : {
202          _edata = .;
203          *(.bss*);
204          *(.ibss);
205          *(COMMON)
206          _end = .;
207      }
209 #elif defined(CPU_TCC77X) || defined(CPU_TCC780X)
211     .text : {
212         *(.init.text)
213         *(.text)
214         *(.text*)
215         *(.glue_7)
216         *(.glue_7t)
217    } > DRAM
219     .data : {
220         *(.icode)
221         *(.irodata)
222         *(.idata)
223         *(.data*)
224         *(.rodata.*)
225         . = ALIGN(0x4);
226         _dataend = . ;
227     } > DRAM
229     .stack :
230     {
231          *(.stack)
232          _stackbegin = .;
233          stackbegin = .;
234          . += 0x2000;
235          _stackend = .;
236          stackend = .;
237     } > DRAM
238     .bss : {
239          _edata = .;
240          *(.bss*);
241          *(.ibss);
242          *(COMMON)
243          _end = .;
244      } > DRAM
246 #elif (CONFIG_CPU==DM320)
248     . = DRAMORIG + 0x1000000;
250     .text : {
251         loadaddress = .;
252         _loadaddress = .;
253         *(.init.text)
254         *(.text*)
255         *(.glue_7)
256         *(.glue_7t)
257         . = ALIGN(0x4);
258     } > DRAM
260     .rodata :
261     {
262         *(.rodata)  /* problems without this, dunno why */
263         *(.rodata*)
264         *(.rodata.str1.1)
265         *(.rodata.str1.4)
266         . = ALIGN(0x4);
268         /* Pseudo-allocate the copies of the data sections */
269         _datacopy = .;
270     } > DRAM
272     .data : {
273         *(.icode)
274         *(.irodata)
275         *(.idata)
276         *(.data*)
277         . = ALIGN(0x4);
278         _dataend = . ;
279     } > DRAM
281     .stack :
282     {
283          *(.stack)
284          _stackbegin = .;
285          stackbegin = .;
286          . += 0x2000;
287          _stackend = .;
288          stackend = .;
289     } > DRAM
291     .bss :
292     {
293          _edata = .;
294          *(.bss*);
295          *(.ibss);
296          *(COMMON)
297          _end = .;
298     } > DRAM
300     .vectors IRAMORIG :
301     {
302         _vectorsstart = .;
303         KEEP(*(.resetvectors));
304         *(.resetvectors);
305         KEEP(*(.vectors));
306         *(.vectors);
307         _vectorsend = .;
308     } AT > DRAM
309     _vectorscopy = LOADADDR(.vectors);
311 #elif (CONFIG_CPU==IMX31L)
313     . = DRAMORIG;
315     .text :
316     {
317         *(.init.text)
318         *(.text*)
319         *(.icode)
320         *(.glue_7)
321         *(.glue_7t)
322         . = ALIGN(0x4);
323     } > DRAM
325     .rodata :
326     {
327         *(.rodata)  /* problems without this, dunno why */
328         *(.rodata*)
329         *(.rodata.str1.1)
330         *(.rodata.str1.4)
331         . = ALIGN(0x4);
333         /* Pseudo-allocate the copies of the data sections */
334         _datacopy = .;
335     } > DRAM
337     .data :
338     {
339         *(.irodata)
340         *(.idata)
341         *(.data*)
342         . = ALIGN(0x4);
343         _dataend = . ;
344     } > DRAM
346     .stack :
347     {
348         *(.stack)
349         _stackbegin = .;
350         stackbegin = .;
351         . += 0x2000;
352         _stackend = .;
353         stackend = .;
354     } > IRAM
356     .bss :
357     {
358          _edata = .;
359          *(.bss*);
360          *(.ibss);
361          *(COMMON)
362          _end = .;
363     } > DRAM
365     .vectors 0x0 :
366     {
367         _vectorsstart = .;
368         *(.vectors);
369         KEEP(*(.vectors));
370         _vectorsend = .;
371     } AT > DRAM
372     _vectorscopy = LOADADDR(.vectors);
374 #else
376     .vectors :
377     {
378 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
379         *(.init.text)
380 #endif
381         _datacopy = .;
382     } > FLASH
384     .data : AT ( _datacopy )
385     {
386         _datastart = .;
387         KEEP(*(.resetvectors));
388         *(.resetvectors);
389         KEEP(*(.vectors));
390         *(.vectors);
391         . = ALIGN(0x200);
392         *(.icode)
393         *(.irodata)
394         *(.idata)
395         *(.data*)
396         . = ALIGN(0x4);
397         _dataend = .;
398         . = ALIGN(0x10);  /* Maintain proper alignment for .text section */
399     } > IRAM
401     /* TRICK ALERT! Newer versions of the linker don't allow output sections
402        to overlap even if one of them is empty, so advance the location pointer
403        "by hand" */
404     .text LOADADDR(.data) + SIZEOF(.data) :
405     {
406         *(.init.text)
407         *(.text*)
408         . = ALIGN(0x4);
409     } > FLASH
411     .rodata :
412     {
413         *(.rodata*)
414         . = ALIGN(0x4);
415         _iramcopy = .;
416     } > FLASH
418     .stack :
419     {
420        *(.stack)
421        _stackbegin = .;
422        stackbegin = .;
423        . += 0x2000;
424        _stackend = .;
425        stackend = .;
426     } > IRAM
428 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
429  || defined(IAUDIO_X5) || defined(IAUDIO_M5)
430     .bss DRAMORIG+0x800000:
431 #else
432     .bss :
433 #endif
434     {
435        _edata = .;
436         *(.ibss)
437         *(.bss*)
438         *(COMMON)
439        _end = .;
440 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
441  || defined(IAUDIO_X5) || defined(IAUDIO_M5)
442     } > DRAM
443 #else
444     } > IRAM
445 #endif
448 #endif