]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/calmrisc32/core/v2_0/src/calm32_core.ld
Initial revision
[karo-tx-redboot.git] / packages / hal / calmrisc32 / core / v2_0 / src / calm32_core.ld
1 //===========================================================================
2 //
3 // MLT linker script for CalmRISC32 Core
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("elf64-calmrisc32", "elf64-calmrisc32",
43               "elf64-calmrisc32")
44
45 OUTPUT_ARCH(calmrisc32)
46
47 STARTUP(vectors.o)
48 ENTRY(reset_vector)
49 #ifdef EXTRAS
50 INPUT(extras.o)
51 #endif
52 #if (__GNUC__ >= 3)
53 GROUP(libtarget.a libgcc.a libsupc++.a)
54 #else
55 GROUP(libtarget.a libgcc.a)
56 #endif
57
58 #define ALIGN_LMA 0x40
59 #define FOLLOWING(_section_) AT ((LOADADDR (_section_) + SIZEOF (_section_) + ALIGN_LMA - 1) & ~ (ALIGN_LMA - 1))
60 #define LMA_EQ_VMA
61 #define FORCE_OUTPUT . = .
62
63 #define SECTIONS_BEGIN
64
65 #if defined(CYG_HAL_STARTUP_RAM)
66
67 /* this version for RAM startup */
68 #define SECTION_vectors(_region_, _vma_, _lma_) \
69     .vectors _vma_ : _lma_ \
70     { KEEP (*(.vectors)) } \
71     > _region_
72
73 #elif defined(CYG_HAL_STARTUP_ROM)
74
75 /* this version for ROM startup */
76 #define SECTION_vectors(_region_, _vma_, _lma_) \
77     .vectors _vma_ : _lma_ \
78     { KEEP (*(.vectors)) } > _region_
79
80 #endif /* ROM startup version of ROM vectors */
81
82 #define SECTION_ROMISC(_region_, _vma_, _lma_)                                 \
83   .interp _vma_  : _lma_ { *(.interp)                            } > _region_  \
84   .hash          : FOLLOWING(.interp)        { *(.hash)          } > _region_  \
85   .dynsym        : FOLLOWING(.hash)          { *(.dynsym)        } > _region_  \
86   .dynstr        : FOLLOWING(.dynsym)        { *(.dynstr)        } > _region_  \
87   .gnu.version   : FOLLOWING(.dynstr)        { *(.gnu.version)   } > _region_  \
88   .gnu.version_d : FOLLOWING(.gnu.version)   { *(.gnu.version_d) } > _region_  \
89   .gnu.version_r : FOLLOWING(.gnu.version_d) { *(.gnu.version_r) } > _region_
90
91 #define SECTION_RELOCS(_region_, _vma_, _lma_)                              \
92   .rel.text      :                                                          \
93     {                                                                       \
94       *(.rel.text)                                                          \
95       *(.rel.text.*)                                                        \
96       *(.rel.gnu.linkonce.t*)                                               \
97     } > _region_                                                            \
98   .rela.text     :                                                          \
99     {                                                                       \
100       *(.rela.text)                                                         \
101       *(.rela.text.*)                                                       \
102       *(.rela.gnu.linkonce.t*)                                              \
103     } > _region_                                                            \
104   .rel.data      :                                                          \
105     {                                                                       \
106       *(.rel.data)                                                          \
107       *(.rel.data.*)                                                        \
108       *(.rel.gnu.linkonce.d*)                                               \
109     } > _region_                                                            \
110   .rela.data     :                                                          \
111     {                                                                       \
112       *(.rela.data)                                                         \
113       *(.rela.data.*)                                                       \
114       *(.rela.gnu.linkonce.d*)                                              \
115     } > _region_                                                            \
116   .rel.rodata    :                                                          \
117     {                                                                       \
118       *(.rel.rodata)                                                        \
119       *(.rel.rodata.*)                                                      \
120       *(.rel.gnu.linkonce.r*)                                               \
121     } > _region_                                                            \
122   .rela.rodata   :                                                          \
123     {                                                                       \
124       *(.rela.rodata)                                                       \
125       *(.rela.rodata.*)                                                     \
126       *(.rela.gnu.linkonce.r*)                                              \
127     } > _region_                                                            \
128   .rel.got       :   { *(.rel.got)    } > _region_                          \
129   .rela.got      :   { *(.rela.got)   } > _region_                          \
130   .rel.ctors     :   { *(.rel.ctors)  } > _region_                          \
131   .rela.ctors    :   { *(.rela.ctors) } > _region_                          \
132   .rel.dtors     :   { *(.rel.dtors)  } > _region_                          \
133   .rela.dtors    :   { *(.rela.dtors) } > _region_                          \
134   .rel.init      :   { *(.rel.init)   } > _region_                          \
135   .rela.init     :   { *(.rela.init)  } > _region_                          \
136   .rel.fini      :   { *(.rel.fini)   } > _region_                          \
137   .rela.fini     :   { *(.rela.fini)  } > _region_                          \
138   .rel.bss       :   { *(.rel.bss)    } > _region_                          \
139   .rela.bss      :   { *(.rela.bss)   } > _region_                          \
140   .rel.plt       :   { *(.rel.plt)    } > _region_                          \
141   .rela.plt      :   { *(.rela.plt)   } > _region_                          \
142   .rel.dyn       :   { *(.rel.dyn)    } > _region_
143
144 #define SECTION_init(_region_, _vma_, _lma_)   \
145   .init _vma_ : _lma_                          \
146     {                                          \
147       FORCE_OUTPUT; KEEP (*(.init))            \
148     } > _region_ =0x9e90
149
150 #define SECTION_text(_region_, _vma_, _lma_)   \
151   .text _vma_ : _lma_                          \
152     {                                          \
153       _stext = .; _ftext = . ;                 \
154       *(.text)                                 \
155       *(.text.*)                               \
156       *(.stub)                                 \
157       *(.gnu.warning)                          \
158       *(.gnu.linkonce.t*)                      \
159     } > _region_ =0x9e90                       \
160   _etext = .; PROVIDE (etext = .);
161
162 #define SECTION_fini(_region_, _vma_, _lma_)   \
163   .fini _vma_ : _lma_                          \
164     {                                          \
165       FORCE_OUTPUT; KEEP (*(.fini))                   \
166     } > _region_ =0x9e90
167
168 #define SECTION_rodata(_region_, _vma_, _lma_)        \
169   .rodata _vma_ : _lma_                               \
170     {                                                 \
171       FORCE_OUTPUT; *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*)    \
172     } > _region_
173
174 #define SECTION_rodata1(_region_, _vma_, _lma_)       \
175   .rodata1 _vma_ : _lma_                              \
176     {                                                 \
177      FORCE_OUTPUT; *(.rodata1) *(.rodata1.*)          \
178     } > _region_
179
180 #define SECTION_vsr_table(_region_, _vma_, _lma_)     \
181   .vsr_table _vma_ : _lma_                            \
182     {                                                 \
183       FORCE_OUTPUT; *(.vsr_table)                     \
184     } > _region_
185
186 #define SECTION_data(_region_, _vma_, _lma_)          \
187   .data _vma_ : _lma_                                 \
188     {                                                 \
189       __ram_data_start = ABSOLUTE (.); _fdata = . ;   \
190       *(.data) *(.data.*) *(.gnu.linkonce.d*)         \
191     . = ALIGN (8);                                    \
192     SORT(CONSTRUCTORS)                                \
193     } > _region_                                      \
194     __rom_data_start = LOADADDR(.data);
195
196 #define SECTION_data1(_region_, _vma_, _lma_)         \
197   .data1 _vma_ : _lma_                                \
198     {                                                 \
199        FORCE_OUTPUT; *(.data1) *(.data1.*)            \
200     } > _region_
201
202 #define SECTION_eh_frame(_region_, _vma_, _lma_)      \
203   .eh_frame _vma_ : _lma_                             \
204     {                                                 \
205        FORCE_OUTPUT; *(.eh_frame)                     \
206     } > _region_
207
208 #define SECTION_gcc_except_table(_region_, _vma_, _lma_) \
209   .gcc_except_table _vma_ : _lma_                        \
210     {                                                    \
211       FORCE_OUTPUT; *(.gcc_except_table)                 \
212     } > _region_
213
214
215     /* gcc uses crtbegin.o to find the start of
216        the constructors, so we make sure it is
217        first.  Because this is a wildcard, it
218        doesn't matter if the user does not
219        actually link against crtbegin.o; the
220        linker won't look for a file to match a
221        wildcard.  The wildcard also means that it
222        doesn't matter which directory crtbegin.o
223        is in.  */
224
225     /* We don't want to include the .ctors section from
226        the crtend.o file until after the sorted ctors.
227        The .ctor section from the crtend file contains the
228        end of ctors marker and it must be last */
229
230 /* FIXME: We shouldn't need to define __CTOR_LIST__/__CTOR_END__
231    and __DTOR_LIST__/__DTOR_END__ except by the PROVIDE lines.
232    However this doesn't work for old (99r1-era) toolchains, so
233    leave it for now. */
234
235 #define SECTION_ctors(_region_, _vma_, _lma_)     \
236   .ctors _vma_ : _lma_                            \
237     {                                             \
238       FORCE_OUTPUT;                               \
239       KEEP (*crtbegin.o(.ctors))                  \
240       __CTOR_LIST__ = .;                \
241       PROVIDE (__CTOR_LIST__ = .);                \
242       KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))   \
243       KEEP (*(SORT(.ctors.*)))                    \
244       KEEP (*(.ctors))                            \
245       __CTOR_END__ = .;                 \
246       PROVIDE (__CTOR_END__ = .);                 \
247     } > _region_
248
249 #define SECTION_dtors(_region_, _vma_, _lma_)     \
250   .dtors _vma_ : _lma_                            \
251     {                                             \
252       FORCE_OUTPUT;                               \
253       KEEP (*crtbegin.o(.dtors))                  \
254       __DTOR_LIST__ = .;                \
255       PROVIDE (__DTOR_LIST__ = .);                \
256       KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))   \
257       KEEP (*(SORT(.dtors.*)))                    \
258       KEEP (*(.dtors))                            \
259       __DTOR_END__ = .;                 \
260       PROVIDE (__DTOR_END__ = .);                 \
261     } > _region_
262
263 #define SECTION_devtab(_region_, _vma_, _lma_)    \
264   .devtab _vma_ : _lma_                           \
265     {                                             \
266       FORCE_OUTPUT;                               \
267       KEEP(*( SORT (.ecos.table.*))) ;            \
268     } > _region_
269
270 #define SECTION_got(_region_, _vma_, _lma_)     \
271   _gp = ALIGN(16) + 0x7ff0;                     \
272   .got _vma_ : _lma_                            \
273     {                                           \
274       FORCE_OUTPUT; *(.got.plt) *(.got)         \
275     } > _region_
276
277 #define SECTION_dynamic(_region_, _vma_, _lma_) \
278   .dynamic _vma_ : _lma_                        \
279     {                                           \
280       FORCE_OUTPUT; *(.dynamic)                 \
281     } > _region_
282
283   /* We want the small data sections together, so single-instruction offsets
284      can access them all, and initialized data all before uninitialized, so
285      we can shorten the on-disk segment size.  */
286
287 #define SECTION_sdata(_region_, _vma_, _lma_)                 \
288   .sdata _vma_ : _lma_                                        \
289     {                                                         \
290       FORCE_OUTPUT; *(.sdata) *(.sdata.*) *(.gnu.linkonce.s*) \
291     } > _region_
292
293 #define SECTION_lit8(_region_, _vma_, _lma_)    \
294   .lit8 _vma_ : _lma_                           \
295     {                                           \
296       FORCE_OUTPUT; *(.lit8)                    \
297     } > _region_
298
299 #define SECTION_lit4(_region_, _vma_, _lma_)    \
300   .lit4 : FOLLOWING(.lit8)                      \
301     {                                           \
302       FORCE_OUTPUT; *(.lit4)                    \
303     } > _region_                                \
304   __ram_data_end = .; _edata = . ;              \
305   PROVIDE (edata = .);
306
307 #define SECTION_sbss(_region_, _vma_, _lma_)                    \
308   __bss_start = .; _fbss = .;                                   \
309   .sbss _vma_ : _lma_                                           \
310     {                                                           \
311       FORCE_OUTPUT; *(.dynsbss) *(.sbss) *(.sbss.*) *(.gnu.linkonce.sb.*) *(.scommon) \
312     } > _region_
313
314 #define SECTION_bss(_region_, _vma_, _lma_)       \
315   .bss _vma_ : _lma_                              \
316     {                                             \
317       *(.dynbss) *(.bss) *(.bss.*) *(.gnu.linkonce.b.*) *(COMMON)      \
318     } > _region_                                  \
319   __bss_end = .;
320
321 /* The /DISCARD/ section ensures that the output will not contain a
322  * .mdebug section as it confuses GDB. This is a workaround for CR 100804.
323  */
324
325 #define SECTIONS_END . = ALIGN(4); _end = .; PROVIDE (end = .); \
326   /* Stabs debugging sections.  */                              \
327   .stab          0 : { *(.stab) }                               \
328   .stabstr       0 : { *(.stabstr) }                            \
329   .stab.excl     0 : { *(.stab.excl) }                          \
330   .stab.exclstr  0 : { *(.stab.exclstr) }                       \
331   .stab.index    0 : { *(.stab.index) }                         \
332   .stab.indexstr 0 : { *(.stab.indexstr) }                      \
333   .comment       0 : { *(.comment) }                            \
334   /* DWARF debug sections.                                      \
335      Symbols in the DWARF debugging sections are relative to    \
336      the beginning of the section so we begin them at 0.  */    \
337   /* DWARF 1 */                                                 \
338   .debug          0 : { *(.debug) }                             \
339   .line           0 : { *(.line) }                              \
340   /* GNU DWARF 1 extensions */                                  \
341   .debug_srcinfo  0 : { *(.debug_srcinfo) }                     \
342   .debug_sfnames  0 : { *(.debug_sfnames) }                     \
343   /* DWARF 1.1 and DWARF 2 */                                   \
344   .debug_aranges  0 : { *(.debug_aranges) }                     \
345   .debug_pubnames 0 : { *(.debug_pubnames) }                    \
346   /* DWARF 2 */                                                 \
347   .debug_info     0 : { *(.debug_info) }                        \
348   .debug_abbrev   0 : { *(.debug_abbrev) }                      \
349   .debug_line     0 : { *(.debug_line) }                        \
350   .debug_frame    0 : { *(.debug_frame) }                       \
351   .debug_str      0 : { *(.debug_str) }                         \
352   .debug_loc      0 : { *(.debug_loc) }                         \
353   .debug_macinfo  0 : { *(.debug_macinfo) }                     \
354   /* SGI/MIPS DWARF 2 extensions */                             \
355   .debug_weaknames 0 : { *(.debug_weaknames) }                  \
356   .debug_funcnames 0 : { *(.debug_funcnames) }                  \
357   .debug_typenames 0 : { *(.debug_typenames) }                  \
358   .debug_varnames  0 : { *(.debug_varnames) }                   \
359   /* These must appear regardless of  .  */                     \
360   .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }             \
361   .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }                \
362   /DISCARD/        0 : { *(.mdebug) }
363
364 #include CYGHWR_MEMORY_LAYOUT_LDI
365
366 _hal_vsr_table = 0x0;
367 _hal_virtual_vector_table = 0x100;