Accept FS#8469 by Bryan Childs with a few adjustments: Remove duplicate strip_extensi...
[Rockbox.git] / firmware / boot.lds
blob8d7d55a6078bfef76735c0f5a2f018f68164f0d2
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 0x80000000
84 #define IRAMORIG 0x1FFFC000
85 #define IRAMSIZE 16K
86 #define FLASHORIG 0x0000000
87 #define FLASHSIZE 1M
88 #elif defined(CPU_TCC77X)
89 #define DRAMORIG 0x20000000
90 #define IRAMORIG 0x00000000
91 #define IRAMSIZE 64K
92 #define FLASHORIG 0x0000000
93 #define FLASHSIZE 1M
94 #elif defined(CPU_TCC780X)
95 #define DRAMORIG 0x20000000
96 #define IRAMORIG 0x00000000
97 #define IRAMSIZE 4K
98 #define FLASHORIG 0x0000000
99 #define FLASHSIZE 1M
100 #else
101 #define DRAMORIG 0x09000000
102 #define IRAMORIG 0x0f000000
103 #define IRAMSIZE 0x1000
104 #define FLASHORIG 0x02000000 + ROM_START
105 #define FLASHSIZE 256K - ROM_START
106 #endif
108 #if defined(CPU_TCC77X) || defined(CPU_TCC780X)
109 MEMORY
111 #ifdef TCCBOOT
112    DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
113 #else
114    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
115 #endif
116    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
118 #elif !defined(CPU_PP) && (CONFIG_CPU!=S3C2440) && (CONFIG_CPU!=IMX31L)
119 MEMORY
121    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
122    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
123    FLASH : ORIGIN = FLASHORIG, LENGTH = FLASHSIZE
125 #endif
127 SECTIONS
128 #ifdef CPU_PP
130   . = IRAMORIG;
132   .text : {
133     *(.init.text)
134     *(.text*)
135   }
137   .data : {
138     *(.icode)
139     *(.irodata)
140     *(.idata)
141     *(.data*)
142     _dataend = . ;
143    }
145   .stack :
146   {
147      *(.stack)
148      _stackbegin = .;
149      stackbegin = .;
150      . += 0x2000;
151      _stackend = .;
152      stackend = .;
153   }
155   /* The bss section is too large for IRAM - we just move it 16MB into the
156      DRAM */
158   . = (DRAMORIG+16*1024*1024);
159   .bss : {
160      _edata = .;
161      *(.bss*);
162      *(.ibss);
163      _end = .;
164    }
166 #elif (CONFIG_CPU==S3C2440)
168     . = DRAMORIG + 0x1000000;
170     .text : {
171         *(.init.text)
172         *(.text*)
173     }
175     .data : {
176         *(.icode)
177         *(.irodata)
178         *(.idata)
179         *(.data*)
180         . = ALIGN(0x4);
181         _dataend = . ;
182      }
184     .stack :
185     {
186          *(.stack)
187          _stackbegin = .;
188          stackbegin = .;
189          . += 0x2000;
190          _stackend = .;
191          stackend = .;
192     }
193     .bss : {
194          _edata = .;
195          *(.bss*);
196          *(.ibss);
197          *(COMMON)
198          _end = .;
199      }
201 #elif defined(CPU_TCC77X) || defined(CPU_TCC780X)
203     .text : {
204         *(.init.text)
205         *(.text)
206         *(.text*)
207         *(.glue_7)
208         *(.glue_7t)
209    } > DRAM
211     .data : {
212         *(.icode)
213         *(.irodata)
214         *(.idata)
215         *(.data*)
216         *(.rodata.*)
217         . = ALIGN(0x4);
218         _dataend = . ;
219     } > DRAM
221     .stack :
222     {
223          *(.stack)
224          _stackbegin = .;
225          stackbegin = .;
226          . += 0x2000;
227          _stackend = .;
228          stackend = .;
229     } > DRAM
230     .bss : {
231          _edata = .;
232          *(.bss*);
233          *(.ibss);
234          *(COMMON)
235          _end = .;
236      } > DRAM
238 #elif (CONFIG_CPU==DM320)
240     . = DRAMORIG + 0x1000000;
242     .text : {
243         loadaddress = .;
244         _loadaddress = .;
245         *(.init.text)
246         *(.text*)
247         *(.glue_7)
248         *(.glue_7t)
249         . = ALIGN(0x4);
250     } > DRAM
252     .rodata :
253     {
254         *(.rodata)  /* problems without this, dunno why */
255         *(.rodata*)
256         *(.rodata.str1.1)
257         *(.rodata.str1.4)
258         . = ALIGN(0x4);
260         /* Pseudo-allocate the copies of the data sections */
261         _datacopy = .;
262     } > DRAM
264     .data : {
265         *(.icode)
266         *(.irodata)
267         *(.idata)
268         *(.data*)
269         . = ALIGN(0x4);
270         _dataend = . ;
271     } > DRAM
273     .stack :
274     {
275          *(.stack)
276          _stackbegin = .;
277          stackbegin = .;
278          . += 0x2000;
279          _stackend = .;
280          stackend = .;
281     } > DRAM
283     .bss :
284     {
285          _edata = .;
286          *(.bss*);
287          *(.ibss);
288          *(COMMON)
289          _end = .;
290     } > DRAM
292     .vectors IRAMORIG :
293     {
294         _vectorsstart = .;
295         KEEP(*(.resetvectors));
296         *(.resetvectors);
297         KEEP(*(.vectors));
298         *(.vectors);
299         _vectorsend = .;
300     } AT > DRAM
301     _vectorscopy = LOADADDR(.vectors);
303 #elif (CONFIG_CPU==IMX31L)
305   . = 0x8a000000;
306   .vectors : 
307   {  
308     KEEP(*(.vectors*));
309     *(.vectors*);
310   }  
311   .text : {
312     *(.init.text)
313     *(.text*)
314   }
315   .data : {
316     *(.icode)
317     *(.irodata)
318     *(.idata)
319     *(.data*)
320     _dataend = . ;
321    }
322   .stack :
323   {
324      *(.stack)
325      _stackbegin = .;
326      stackbegin = .;
327      . += 0x2000;
328      _stackend = .;
329      stackend = .;
330   }
331   .bss : {
332      _edata = .;
333      *(.bss*);
334      *(.ibss);
335      _end = .;
336    }
338 #else
340     .vectors :
341     {
342 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
343         *(.init.text)
344 #endif
345         _datacopy = .;
346     } > FLASH
348     .data : AT ( _datacopy )
349     {
350         _datastart = .;
351         KEEP(*(.resetvectors));
352         *(.resetvectors);
353         KEEP(*(.vectors));
354         *(.vectors);
355         . = ALIGN(0x200);
356         *(.icode)
357         *(.irodata)
358         *(.idata)
359         *(.data*)
360         . = ALIGN(0x4);
361         _dataend = .;
362         . = ALIGN(0x10);  /* Maintain proper alignment for .text section */
363     } > IRAM
365     /* TRICK ALERT! Newer versions of the linker don't allow output sections
366        to overlap even if one of them is empty, so advance the location pointer
367        "by hand" */
368     .text LOADADDR(.data) + SIZEOF(.data) :
369     {
370         *(.init.text)
371         *(.text*)
372         . = ALIGN(0x4);
373     } > FLASH
375     .rodata :
376     {
377         *(.rodata*)
378         . = ALIGN(0x4);
379         _iramcopy = .;
380     } > FLASH
382     .stack :
383     {
384        *(.stack)
385        _stackbegin = .;
386        stackbegin = .;
387        . += 0x2000;
388        _stackend = .;
389        stackend = .;
390     } > IRAM
392 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
393  || defined(IAUDIO_X5) || defined(IAUDIO_M5)
394     .bss DRAMORIG+0x800000:
395 #else
396     .bss :
397 #endif
398     {
399        _edata = .;
400         *(.ibss)
401         *(.bss*)
402         *(COMMON)
403        _end = .;
404 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
405  || defined(IAUDIO_X5) || defined(IAUDIO_M5)
406     } > DRAM
407 #else
408     } > IRAM
409 #endif
412 #endif