]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/hal/arm/arch/v2_0/src/arm.ld
54252c5e397bf3c1f1edbaf1e8aaa1a1cc36ea67
[karo-tx-redboot.git] / packages / hal / arm / arch / v2_0 / src / arm.ld
1 //=============================================================================
2 //
3 // MLT linker script for ARM
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 STARTUP(vectors.o)
43 ENTRY(reset_vector)
44 INPUT(extras.o)
45 #if (__GNUC__ >= 3)
46 GROUP(libtarget.a libgcc.a libsupc++.a)
47 #else
48 GROUP(libtarget.a libgcc.a)
49 #endif
50
51 #if defined(__ARMEB__)
52 OUTPUT_FORMAT(elf32-bigarm)
53 #endif
54
55 #if defined(CYG_HAL_STARTUP_ROM)    \
56     && defined(CYGPKG_HAL_ARM_PID)  \
57     && defined(__ARMEB__)
58 // Note: This is only needed when the PID board is used in BE mode without
59 //       the proper ROM controller part.
60 //
61 // In big-endian mode, merge .RODATA sections into the .DATA section. This
62 // causes the data in these sections to be copied to RAM. When the CPU
63 // makes byte or halfword access to RAM, A0/A1 are modified correctly.
64 // This does not happen on ROM access (unless the proper ROM controller
65 // is used).
66 //
67 #define MERGE_IN_RODATA *(.rodata*)
68 #define CYGPRI_PID_BE_WORKAROUND
69 #else
70 // Keep RODATA in separate sections.
71 #define MERGE_IN_RODATA
72 #undef  CYGPRI_PID_BE_WORKAROUND
73 #endif
74
75 #define ALIGN_LMA 4
76 #define FOLLOWING(_section_) AT ((LOADADDR (_section_) + SIZEOF (_section_) + ALIGN_LMA - 1) & ~ (ALIGN_LMA - 1))
77 #define LMA_EQ_VMA
78 #define FORCE_OUTPUT . = .
79
80 // Some versions of gcc define "arm" which causes problems with .note.arm.ident
81 #undef arm
82 #define SECTIONS_BEGIN                          \
83   /* Debug information */                       \
84   .debug_aranges  0 : { *(.debug_aranges) }     \
85   .debug_pubnames 0 : { *(.debug_pubnames) }    \
86   .debug_info     0 : { *(.debug_info) }        \
87   .debug_abbrev   0 : { *(.debug_abbrev) }      \
88   .debug_line     0 : { *(.debug_line) }        \
89   .debug_frame    0 : { *(.debug_frame) }       \
90   .debug_str      0 : { *(.debug_str) }         \
91   .debug_loc      0 : { *(.debug_loc) }         \
92   .debug_macinfo  0 : { *(.debug_macinfo) }     \
93   .note.arm.ident 0 : { KEEP (*(.note.arm.ident)) }
94
95 #define SECTION_fixed_vectors(_region_, _vma_, _lma_) \
96     .fixed_vectors _vma_ : _lma_ \
97     { FORCE_OUTPUT; KEEP (*(.fixed_vectors)) } \
98     > _region_
99
100 #define SECTION_rom_vectors(_region_, _vma_, _lma_) \
101     .rom_vectors _vma_ : _lma_ \
102     { __rom_vectors_vma = ABSOLUTE(.); \
103       FORCE_OUTPUT; KEEP (*(.vectors)) } \
104     > _region_ \
105     __rom_vectors_lma = LOADADDR(.rom_vectors);
106
107 #define SECTION_text(_region_, _vma_, _lma_) \
108     .text _vma_ : _lma_ \
109     { _stext = ABSOLUTE(.); \
110     PROVIDE (__stext = ABSOLUTE(.)); \
111     *(.text*) *(.gnu.warning) *(.gnu.linkonce.t.*) *(.init) \
112     *(.glue_7) *(.glue_7t)  \
113     } > _region_ \
114     _etext = .; PROVIDE (__etext = .);
115
116 #define SECTION_fini(_region_, _vma_, _lma_) \
117     .fini _vma_ : _lma_ \
118     { FORCE_OUTPUT; *(.fini) } \
119     > _region_
120
121 #if defined(CYGPRI_PID_BE_WORKAROUND)
122 #define SECTION_rodata(_region_, _vma_, _lma_)
123 #define SECTION_rodata1(_region_, _vma_, _lma_)
124 #else
125 #define SECTION_rodata(_region_, _vma_, _lma_) \
126     .rodata _vma_ : _lma_ \
127     { FORCE_OUTPUT; *(.rodata*) *(.gnu.linkonce.r.*) } \
128     > _region_
129
130 #define SECTION_rodata1(_region_, _vma_, _lma_) \
131     .rodata1 _vma_ : _lma_ \
132     { FORCE_OUTPUT; *(.rodata1) } \
133     > _region_
134 #endif // CYGPRI_PID_BE_WORKAROUND
135
136 #define SECTION_fixup(_region_, _vma_, _lma_) \
137     .fixup _vma_ : _lma_ \
138     { FORCE_OUTPUT; *(.fixup) } \
139     > _region_
140
141 #define SECTION_gcc_except_table(_region_, _vma_, _lma_) \
142     .gcc_except_table _vma_ : _lma_ \
143     { FORCE_OUTPUT; *(.gcc_except_table) } \
144     > _region_
145
146 #define SECTION_eh_frame(_region_, _vma_, _lma_)      \
147   .eh_frame _vma_ : _lma_                             \
148     {                                                 \
149        FORCE_OUTPUT;  __EH_FRAME_BEGIN__ = .;         \
150        KEEP(*(.eh_frame))                             \
151        __FRAME_END__ = .;                             \
152        . = . + 8;                                     \
153     } > _region_ = 0
154
155 #define SECTION_RELOCS(_region_, _vma_, _lma_)                              \
156   .rel.text      :                                                          \
157     {                                                                       \
158       *(.rel.text)                                                          \
159       *(.rel.text.*)                                                        \
160       *(.rel.gnu.linkonce.t*)                                               \
161     } > _region_                                                            \
162   .rela.text     :                                                          \
163     {                                                                       \
164       *(.rela.text)                                                         \
165       *(.rela.text.*)                                                       \
166       *(.rela.gnu.linkonce.t*)                                              \
167     } > _region_                                                            \
168   .rel.data      :                                                          \
169     {                                                                       \
170       *(.rel.data)                                                          \
171       *(.rel.data.*)                                                        \
172       *(.rel.gnu.linkonce.d*)                                               \
173     } > _region_                                                            \
174   .rela.data     :                                                          \
175     {                                                                       \
176       *(.rela.data)                                                         \
177       *(.rela.data.*)                                                       \
178       *(.rela.gnu.linkonce.d*)                                              \
179     } > _region_                                                            \
180   .rel.rodata    :                                                          \
181     {                                                                       \
182       *(.rel.rodata)                                                        \
183       *(.rel.rodata.*)                                                      \
184       *(.rel.gnu.linkonce.r*)                                               \
185     } > _region_                                                            \
186   .rela.rodata   :                                                          \
187     {                                                                       \
188       *(.rela.rodata)                                                       \
189       *(.rela.rodata.*)                                                     \
190       *(.rela.gnu.linkonce.r*)                                              \
191     } > _region_                                                            \
192   .rel.got       :   { *(.rel.got)    } > _region_                          \
193   .rela.got      :   { *(.rela.got)   } > _region_                          \
194   .rel.ctors     :   { *(.rel.ctors)  } > _region_                          \
195   .rela.ctors    :   { *(.rela.ctors) } > _region_                          \
196   .rel.dtors     :   { *(.rel.dtors)  } > _region_                          \
197   .rela.dtors    :   { *(.rela.dtors) } > _region_                          \
198   .rel.init      :   { *(.rel.init)   } > _region_                          \
199   .rela.init     :   { *(.rela.init)  } > _region_                          \
200   .rel.fini      :   { *(.rel.fini)   } > _region_                          \
201   .rela.fini     :   { *(.rela.fini)  } > _region_                          \
202   .rel.bss       :   { *(.rel.bss)    } > _region_                          \
203   .rela.bss      :   { *(.rela.bss)   } > _region_                          \
204   .rel.plt       :   { *(.rel.plt)    } > _region_                          \
205   .rela.plt      :   { *(.rela.plt)   } > _region_                          \
206   .rel.dyn       :   { *(.rel.dyn)    } > _region_
207
208 #define SECTION_got(_region_, _vma_, _lma_)                                 \
209   .got _vma_ : _lma_                                                        \
210     {                                                                       \
211       FORCE_OUTPUT; *(.got.plt) *(.got)                                     \
212       _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.);      \
213       _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.);      \
214     } > _region_
215
216 #define SECTION_mmu_tables(_region_, _vma_, _lma_) \
217     .mmu_tables _vma_ : _lma_ \
218     { FORCE_OUTPUT; *(.mmu_tables) } \
219     > _region_
220
221 #define SECTION_sram(_region_, _vma_, _lma_) \
222     .sram _vma_ : _lma_ \
223     { FORCE_OUTPUT; *(.sram*) } \
224     > _region_
225
226 #define SECTION_data(_region_,  _vma_, _lma_) \
227     .data _vma_ : _lma_ \
228     { __ram_data_start = ABSOLUTE (.); \
229     *(.data*) *(.data1) *(.gnu.linkonce.d.*) MERGE_IN_RODATA \
230     . = ALIGN (4); \
231     KEEP(*( SORT (.ecos.table.*))) ;            \
232     . = ALIGN (4); \
233     __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \
234     __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \
235     *(.dynamic) *(.sdata*) *(.gnu.linkonce.s.*) \
236     . = ALIGN (4); *(.2ram.*) } \
237     > _region_ \
238     __rom_data_start = LOADADDR (.data); \
239     __ram_data_end = .; PROVIDE (__ram_data_end = .); _edata = .; PROVIDE (edata = .); \
240     PROVIDE (__rom_data_end = LOADADDR (.data) + SIZEOF(.data));
241
242 #define SECTION_bss(_region_,  _vma_, _lma_) \
243     .bss _vma_ : _lma_ \
244     { __bss_start = ABSOLUTE (.); \
245     *(.scommon) *(.dynsbss) *(.sbss*) *(.gnu.linkonce.sb.*) \
246     *(.dynbss) *(.bss*) *(.gnu.linkonce.b.*) *(COMMON) \
247     __bss_end = ABSOLUTE (.); } \
248     > _region_
249
250 #define SECTIONS_END . = ALIGN(4); _end = .; PROVIDE (end = .);
251
252 #include <pkgconf/hal_arm.h>
253 #include CYGHWR_MEMORY_LAYOUT_LDI