]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/hal/mips/mips64/v2_0/src/mips_mips64.ld
Initial revision
[karo-tx-redboot.git] / packages / hal / mips / mips64 / v2_0 / src / mips_mips64.ld
1 //===========================================================================
2 //
3 // MLT linker script for MIPS64
4 //
5 //===========================================================================
6 //####ECOSGPLCOPYRIGHTBEGIN####
7 // -------------------------------------------
8 // This file is part of eCos, the Embedded Configurable Operating System.
9 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
10 //
11 // eCos is free software; you can redistribute it and/or modify it under
12 // the terms of the GNU General Public License as published by the Free
13 // Software Foundation; either version 2 or (at your option) any later version.
14 //
15 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18 // for more details.
19 //
20 // You should have received a copy of the GNU General Public License along
21 // with eCos; if not, write to the Free Software Foundation, Inc.,
22 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 //
24 // As a special exception, if other files instantiate templates or use macros
25 // or inline functions from this file, or you compile this file and link it
26 // with other works to produce a work based on this file, this file does not
27 // by itself cause the resulting work to be covered by the GNU General Public
28 // License. However the source code for this file must still be made available
29 // in accordance with section (3) of the GNU General Public License.
30 //
31 // This exception does not invalidate any other reasons why a work based on
32 // this file might be covered by the GNU General Public License.
33 //
34 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35 // at http://sources.redhat.com/ecos/ecos-license/
36 // -------------------------------------------
37 //####ECOSGPLCOPYRIGHTEND####
38 //===========================================================================
39
40 #include <pkgconf/system.h>
41
42 OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips",
43               "elf32-littlemips")
44 /* The preprocessor defines mips, but we know we're mips :-) */
45 #undef mips
46 OUTPUT_ARCH(mips:isa64)
47
48 STARTUP(vectors.o)
49 ENTRY(reset_vector)
50 #ifdef EXTRAS
51 INPUT(extras.o)
52 #endif
53 #if (__GNUC__ >= 3)
54 GROUP(libtarget.a libgcc.a libsupc++.a)
55 #else
56 GROUP(libtarget.a libgcc.a)
57 #endif
58
59 /* FIXME: The MLT should pass in the required alignment since it must be
60  * the same as the VMA's alignment. As a result of this bug, all the MIPS64
61  * ROM mlt files have alignment 8, when some should have alignment 4
62  * (902557-CR)
63  */
64 #define ALIGN_LMA 0x40
65 #define FOLLOWING(_section_) AT ((LOADADDR (_section_) + SIZEOF (_section_) + ALIGN_LMA - 1) & ~ (ALIGN_LMA - 1))
66 #define LMA_EQ_VMA
67 #define FORCE_OUTPUT . = .
68
69 #define SECTIONS_BEGIN
70
71 #if defined(CYG_HAL_STARTUP_RAM)
72
73 /* this version for RAM startup */
74 #define SECTION_rom_vectors(_region_, _vma_, _lma_) \
75     .rom_vectors _vma_ : _lma_ \
76     { KEEP (*(.utlb_vector)) \
77     . = ALIGN(0x80); KEEP(*(.other_vector)) \
78         /* debug and reset vector not used in RAM version */ \
79         KEEP(*(.debug_vector)) \
80         KEEP (*(.reset_vector)) } \
81     > _region_
82
83 #elif defined(CYG_HAL_STARTUP_ROM)
84
85 /* this version for ROM startup */
86 #define SECTION_rom_vectors(_region_, _vma_, _lma_) \
87     .rom_vectors _vma_ : _lma_ \
88     { KEEP (*(.reset_vector)) \
89     . = ALIGN(0x200); KEEP (*(.utlb_vector)) \
90     . = . + 0x100; \
91     . = ALIGN(0x80); KEEP(*(.other_vector)) \
92     . = . + 0x80; \
93     . = ALIGN(0x80); KEEP(*(.debug_vector)) } \
94     > _region_
95
96 #endif /* ROM startup version of ROM vectors */
97
98 #define SECTION_ROMISC(_region_, _vma_, _lma_)                                 \
99   .interp _vma_  : _lma_ { *(.interp)                            } > _region_  \
100   .hash          : FOLLOWING(.interp)        { *(.hash)          } > _region_  \
101   .dynsym        : FOLLOWING(.hash)          { *(.dynsym)        } > _region_  \
102   .dynstr        : FOLLOWING(.dynsym)        { *(.dynstr)        } > _region_  \
103   .gnu.version   : FOLLOWING(.dynstr)        { *(.gnu.version)   } > _region_  \
104   .gnu.version_d : FOLLOWING(.gnu.version)   { *(.gnu.version_d) } > _region_  \
105   .gnu.version_r : FOLLOWING(.gnu.version_d) { *(.gnu.version_r) } > _region_  \
106   .plt           : FOLLOWING(.gnu.version_r) { *(.plt)           } > _region_
107
108 #define SECTION_RELOCS(_region_, _vma_, _lma_)                              \
109   .rel.text      :                                                          \
110     {                                                                       \
111       *(.rel.text)                                                          \
112       *(.rel.text.*)                                                        \
113       *(.rel.gnu.linkonce.t*)                                               \
114     } > _region_                                                            \
115   .rela.text     :                                                          \
116     {                                                                       \
117       *(.rela.text)                                                         \
118       *(.rela.text.*)                                                       \
119       *(.rela.gnu.linkonce.t*)                                              \
120     } > _region_                                                            \
121   .rel.data      :                                                          \
122     {                                                                       \
123       *(.rel.data)                                                          \
124       *(.rel.data.*)                                                        \
125       *(.rel.gnu.linkonce.d*)                                               \
126     } > _region_                                                            \
127   .rela.data     :                                                          \
128     {                                                                       \
129       *(.rela.data)                                                         \
130       *(.rela.data.*)                                                       \
131       *(.rela.gnu.linkonce.d*)                                              \
132     } > _region_                                                            \
133   .rel.rodata    :                                                          \
134     {                                                                       \
135       *(.rel.rodata)                                                        \
136       *(.rel.rodata.*)                                                      \
137       *(.rel.gnu.linkonce.r*)                                               \
138     } > _region_                                                            \
139   .rela.rodata   :                                                          \
140     {                                                                       \
141       *(.rela.rodata)                                                       \
142       *(.rela.rodata.*)                                                     \
143       *(.rela.gnu.linkonce.r*)                                              \
144     } > _region_                                                            \
145   .rel.got       :   { *(.rel.got)    } > _region_                          \
146   .rela.got      :   { *(.rela.got)   } > _region_                          \
147   .rel.ctors     :   { *(.rel.ctors)  } > _region_                          \
148   .rela.ctors    :   { *(.rela.ctors) } > _region_                          \
149   .rel.dtors     :   { *(.rel.dtors)  } > _region_                          \
150   .rela.dtors    :   { *(.rela.dtors) } > _region_                          \
151   .rel.init      :   { *(.rel.init)   } > _region_                          \
152   .rela.init     :   { *(.rela.init)  } > _region_                          \
153   .rel.fini      :   { *(.rel.fini)   } > _region_                          \
154   .rela.fini     :   { *(.rela.fini)  } > _region_                          \
155   .rel.bss       :   { *(.rel.bss)    } > _region_                          \
156   .rela.bss      :   { *(.rela.bss)   } > _region_                          \
157   .rel.plt       :   { *(.rel.plt)    } > _region_                          \
158   .rela.plt      :   { *(.rela.plt)   } > _region_                          \
159   .rel.dyn       :   { *(.rel.dyn)    } > _region_
160
161 #define SECTION_init(_region_, _vma_, _lma_)   \
162   .init _vma_ : _lma_                          \
163     {                                          \
164       FORCE_OUTPUT; KEEP (*(.init))            \
165     } > _region_ =0
166
167 #define SECTION_text(_region_, _vma_, _lma_)   \
168   .text _vma_ : _lma_                          \
169     {                                          \
170       _stext = .; _ftext = . ;                 \
171       *(.text)                                 \
172       *(.text.*)                               \
173       *(.stub)                                 \
174       *(.gnu.warning)                          \
175       *(.gnu.linkonce.t*)                      \
176       *(.mips16.fn.*) *(.mips16.call.*)        \
177     } > _region_ =0                            \
178   _etext = .; PROVIDE (etext = .);
179
180 #define SECTION_fini(_region_, _vma_, _lma_)   \
181   .fini _vma_ : _lma_                          \
182     {                                          \
183       FORCE_OUTPUT; KEEP (*(.fini))                   \
184     } > _region_ =0
185
186 #define SECTION_rodata(_region_, _vma_, _lma_)        \
187   .rodata _vma_ : _lma_                               \
188     {                                                 \
189       FORCE_OUTPUT; *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*)    \
190     } > _region_
191
192 #define SECTION_rodata1(_region_, _vma_, _lma_)       \
193   .rodata1 _vma_ : _lma_                              \
194     {                                                 \
195      FORCE_OUTPUT; *(.rodata1) *(.rodata1.*)          \
196     } > _region_
197
198 #define SECTION_vsr_table(_region_, _vma_, _lma_)     \
199   .vsr_table _vma_ : _lma_                            \
200     {                                                 \
201       FORCE_OUTPUT; *(.vsr_table)                     \
202     } > _region_
203
204 #define SECTION_data(_region_, _vma_, _lma_)          \
205   .data _vma_ : _lma_                                 \
206     {                                                 \
207       __ram_data_start = ABSOLUTE (.); _fdata = . ;   \
208       *(.data) *(.data.*) *(.gnu.linkonce.d*)         \
209       *( .2ram.*)                                     \
210     . = ALIGN (8);                                    \
211     SORT(CONSTRUCTORS)                                \
212     } > _region_                                      \
213     __rom_data_start = LOADADDR(.data);
214
215 #define SECTION_data1(_region_, _vma_, _lma_)         \
216   .data1 _vma_ : _lma_                                \
217     {                                                 \
218        FORCE_OUTPUT; *(.data1) *(.data1.*)            \
219     } > _region_
220
221 #define SECTION_eh_frame(_region_, _vma_, _lma_)      \
222   .eh_frame _vma_ : _lma_                             \
223     {                                                 \
224        FORCE_OUTPUT; *(.eh_frame)                     \
225     } > _region_
226
227 #define SECTION_gcc_except_table(_region_, _vma_, _lma_) \
228   .gcc_except_table _vma_ : _lma_                        \
229     {                                                    \
230       FORCE_OUTPUT; *(.gcc_except_table)                 \
231     } > _region_
232
233
234     /* gcc uses crtbegin.o to find the start of
235        the constructors, so we make sure it is
236        first.  Because this is a wildcard, it
237        doesn't matter if the user does not
238        actually link against crtbegin.o; the
239        linker won't look for a file to match a
240        wildcard.  The wildcard also means that it
241        doesn't matter which directory crtbegin.o
242        is in.  */
243
244     /* We don't want to include the .ctors section from
245        the crtend.o file until after the sorted ctors.
246        The .ctor section from the crtend file contains the
247        end of ctors marker and it must be last */
248
249 /* FIXME: We shouldn't need to define __CTOR_LIST__/__CTOR_END__
250    and __DTOR_LIST__/__DTOR_END__ except by the PROVIDE lines.
251    However this doesn't work for old (99r1-era) toolchains, so
252    leave it for now. */
253
254 #define SECTION_ctors(_region_, _vma_, _lma_)     \
255   .ctors _vma_ : _lma_                            \
256     {                                             \
257       FORCE_OUTPUT;                               \
258       KEEP (*crtbegin.o(.ctors))                  \
259       __CTOR_LIST__ = .;                \
260       PROVIDE (__CTOR_LIST__ = .);                \
261       KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))   \
262       KEEP (*(SORT(.ctors.*)))                    \
263       KEEP (*(.ctors))                            \
264       __CTOR_END__ = .;                 \
265       PROVIDE (__CTOR_END__ = .);                 \
266     } > _region_
267
268 #define SECTION_dtors(_region_, _vma_, _lma_)     \
269   .dtors _vma_ : _lma_                            \
270     {                                             \
271       FORCE_OUTPUT;                               \
272       KEEP (*crtbegin.o(.dtors))                  \
273       __DTOR_LIST__ = .;                \
274       PROVIDE (__DTOR_LIST__ = .);                \
275       KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))   \
276       KEEP (*(SORT(.dtors.*)))                    \
277       KEEP (*(.dtors))                            \
278       __DTOR_END__ = .;                 \
279       PROVIDE (__DTOR_END__ = .);                 \
280     } > _region_
281
282 #define SECTION_devtab(_region_, _vma_, _lma_)    \
283   .devtab _vma_ : _lma_                           \
284     {                                             \
285       FORCE_OUTPUT;                               \
286       KEEP(*( SORT (.ecos.table.*))) ;            \
287     } > _region_
288
289 #define SECTION_got(_region_, _vma_, _lma_)     \
290   _gp = ALIGN(16) + 0x7ff0;                     \
291   .got _vma_ : _lma_                            \
292     {                                           \
293       FORCE_OUTPUT; *(.got.plt) *(.got)         \
294     } > _region_
295
296 #define SECTION_dynamic(_region_, _vma_, _lma_) \
297   .dynamic _vma_ : _lma_                        \
298     {                                           \
299       FORCE_OUTPUT; *(.dynamic)                 \
300     } > _region_
301
302   /* We want the small data sections together, so single-instruction offsets
303      can access them all, and initialized data all before uninitialized, so
304      we can shorten the on-disk segment size.  */
305
306 #define SECTION_sdata(_region_, _vma_, _lma_)                 \
307   .sdata _vma_ : _lma_                                        \
308     {                                                         \
309       FORCE_OUTPUT; *(.sdata) *(.sdata.*) *(.gnu.linkonce.s*) \
310     } > _region_
311
312 #define SECTION_lit8(_region_, _vma_, _lma_)    \
313   .lit8 _vma_ : _lma_                           \
314     {                                           \
315       FORCE_OUTPUT; *(.lit8)                    \
316     } > _region_
317
318 #define SECTION_lit4(_region_, _vma_, _lma_)    \
319   .lit4 : FOLLOWING(.lit8)                      \
320     {                                           \
321       FORCE_OUTPUT; *(.lit4)                    \
322     } > _region_                                \
323   __ram_data_end = .; _edata = . ;              \
324   PROVIDE (edata = .);
325
326 #define SECTION_sbss(_region_, _vma_, _lma_)                    \
327   __bss_start = .; _fbss = .;                                   \
328   .sbss _vma_ : _lma_                                           \
329     {                                                           \
330       FORCE_OUTPUT; *(.dynsbss) *(.sbss) *(.sbss.*) *(.scommon) \
331     } > _region_
332
333 #define SECTION_bss(_region_, _vma_, _lma_)       \
334   .bss _vma_ : _lma_                              \
335     {                                             \
336       *(.dynbss) *(.bss) *(.bss.*) *(COMMON)      \
337     } > _region_                                  \
338   __bss_end = .;
339
340 /* The /DISCARD/ section ensures that the output will not contain a
341  * .mdebug section as it confuses GDB. This is a workaround for CR 100804.
342  */
343
344 #define SECTIONS_END . = ALIGN(4); _end = .; PROVIDE (end = .); \
345   /* Stabs debugging sections.  */                              \
346   .stab          0 : { *(.stab) }                               \
347   .stabstr       0 : { *(.stabstr) }                            \
348   .stab.excl     0 : { *(.stab.excl) }                          \
349   .stab.exclstr  0 : { *(.stab.exclstr) }                       \
350   .stab.index    0 : { *(.stab.index) }                         \
351   .stab.indexstr 0 : { *(.stab.indexstr) }                      \
352   .comment       0 : { *(.comment) }                            \
353   /* DWARF debug sections.                                      \
354      Symbols in the DWARF debugging sections are relative to    \
355      the beginning of the section so we begin them at 0.  */    \
356   /* DWARF 1 */                                                 \
357   .debug          0 : { *(.debug) }                             \
358   .line           0 : { *(.line) }                              \
359   /* GNU DWARF 1 extensions */                                  \
360   .debug_srcinfo  0 : { *(.debug_srcinfo) }                     \
361   .debug_sfnames  0 : { *(.debug_sfnames) }                     \
362   /* DWARF 1.1 and DWARF 2 */                                   \
363   .debug_aranges  0 : { *(.debug_aranges) }                     \
364   .debug_pubnames 0 : { *(.debug_pubnames) }                    \
365   /* DWARF 2 */                                                 \
366   .debug_info     0 : { *(.debug_info) }                        \
367   .debug_abbrev   0 : { *(.debug_abbrev) }                      \
368   .debug_line     0 : { *(.debug_line) }                        \
369   .debug_frame    0 : { *(.debug_frame) }                       \
370   .debug_str      0 : { *(.debug_str) }                         \
371   .debug_loc      0 : { *(.debug_loc) }                         \
372   .debug_macinfo  0 : { *(.debug_macinfo) }                     \
373   /* SGI/MIPS DWARF 2 extensions */                             \
374   .debug_weaknames 0 : { *(.debug_weaknames) }                  \
375   .debug_funcnames 0 : { *(.debug_funcnames) }                  \
376   .debug_typenames 0 : { *(.debug_typenames) }                  \
377   .debug_varnames  0 : { *(.debug_varnames) }                   \
378   /* These must appear regardless of  .  */                     \
379   .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }             \
380   .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }                \
381   /DISCARD/        0 : { *(.mdebug) }
382
383 #include CYGHWR_MEMORY_LAYOUT_LDI
384
385 hal_vsr_table = 0x80000200;
386 hal_virtual_vector_table = 0x80000300;