1 |
786 |
skrzyp |
//=============================================================================
|
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, 2005, 2008 Free Software Foundation, 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
|
14 |
|
|
// version.
|
15 |
|
|
//
|
16 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
17 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
18 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
19 |
|
|
// for more details.
|
20 |
|
|
//
|
21 |
|
|
// You should have received a copy of the GNU General Public License
|
22 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
23 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
24 |
|
|
//
|
25 |
|
|
// As a special exception, if other files instantiate templates or use
|
26 |
|
|
// macros or inline functions from this file, or you compile this file
|
27 |
|
|
// and link it with other works to produce a work based on this file,
|
28 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
29 |
|
|
// the GNU General Public License. However the source code for this file
|
30 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
31 |
|
|
// General Public License v2.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based
|
34 |
|
|
// on this file might be covered by the GNU General Public License.
|
35 |
|
|
// -------------------------------------------
|
36 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
37 |
|
|
//=============================================================================
|
38 |
|
|
|
39 |
|
|
#include
|
40 |
|
|
#include
|
41 |
|
|
|
42 |
|
|
STARTUP(vectors.o)
|
43 |
|
|
ENTRY(reset_vector)
|
44 |
|
|
INPUT(extras.o)
|
45 |
|
|
GROUP( CYGBLD_HAL_LINKER_GROUPED_LIBS )
|
46 |
|
|
|
47 |
|
|
#if defined(__ARMEB__)
|
48 |
|
|
OUTPUT_FORMAT(elf32-bigarm)
|
49 |
|
|
#endif
|
50 |
|
|
|
51 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) \
|
52 |
|
|
&& defined(CYGPKG_HAL_ARM_PID) \
|
53 |
|
|
&& defined(__ARMEB__)
|
54 |
|
|
// Note: This is only needed when the PID board is used in BE mode without
|
55 |
|
|
// the proper ROM controller part.
|
56 |
|
|
//
|
57 |
|
|
// In big-endian mode, merge .RODATA sections into the .DATA section. This
|
58 |
|
|
// causes the data in these sections to be copied to RAM. When the CPU
|
59 |
|
|
// makes byte or halfword access to RAM, A0/A1 are modified correctly.
|
60 |
|
|
// This does not happen on ROM access (unless the proper ROM controller
|
61 |
|
|
// is used).
|
62 |
|
|
//
|
63 |
|
|
#define MERGE_IN_RODATA *(.rodata*)
|
64 |
|
|
#define CYGPRI_PID_BE_WORKAROUND
|
65 |
|
|
#else
|
66 |
|
|
// Keep RODATA in separate sections.
|
67 |
|
|
#define MERGE_IN_RODATA
|
68 |
|
|
#undef CYGPRI_PID_BE_WORKAROUND
|
69 |
|
|
#endif
|
70 |
|
|
|
71 |
|
|
// ALIGN_LMA is 4, but the AAPCS now requires that double word types
|
72 |
|
|
// be aligned to 8, which means some input sections can be marked as needing
|
73 |
|
|
// 8-byte alignment, even text ones (consider literal data).
|
74 |
|
|
// This is quite a big backward-compatibility problem for us as a zillion
|
75 |
|
|
// platform mlt files for ARM assume that 4-byte alignment is adequate. Really
|
76 |
|
|
// this is a bigger problem for the VMA but of course the LMA and VMA have to
|
77 |
|
|
// move in sync, since things like .data are just copied as a block. Still,
|
78 |
|
|
// ALIGN_LMA as 4 is probably best, but there can be problems with this.
|
79 |
|
|
|
80 |
|
|
#define ALIGN_LMA 4
|
81 |
|
|
#define AAPCS_ALIGN 8
|
82 |
|
|
#define FOLLOWING_ALIGNED(_section_, _align_) AT ((LOADADDR (_section_) + SIZEOF (_section_) + (_align_) - 1) & ~ ((_align_) - 1))
|
83 |
|
|
#define FOLLOWING(_section_) FOLLOWING_ALIGNED(_section_, ALIGN_LMA)
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
#define LMA_EQ_VMA
|
87 |
|
|
#define FORCE_OUTPUT . = .
|
88 |
|
|
|
89 |
|
|
// Some versions of gcc define "arm" which causes problems with .note.arm.ident
|
90 |
|
|
#undef arm
|
91 |
|
|
#define SECTIONS_BEGIN \
|
92 |
|
|
/* Debug information */ \
|
93 |
|
|
.debug_aranges 0 : { *(.debug_aranges) } \
|
94 |
|
|
.debug_pubnames 0 : { *(.debug_pubnames) } \
|
95 |
|
|
.debug_info 0 : { *(.debug_info) } \
|
96 |
|
|
.debug_abbrev 0 : { *(.debug_abbrev) } \
|
97 |
|
|
.debug_line 0 : { *(.debug_line) } \
|
98 |
|
|
.debug_frame 0 : { *(.debug_frame) } \
|
99 |
|
|
.debug_str 0 : { *(.debug_str) } \
|
100 |
|
|
.debug_loc 0 : { *(.debug_loc) } \
|
101 |
|
|
.debug_macinfo 0 : { *(.debug_macinfo) } \
|
102 |
|
|
.note.arm.ident 0 : { KEEP (*(.note.arm.ident)) } \
|
103 |
|
|
/DISCARD/ 0 : { *(.fini_array*) }
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
// Following not used unless CYGHWR_HAL_ARM_SEPARATE_VSR_TABLE
|
107 |
|
|
// defined in hal_platform_setup.h. Otherwise vsr table
|
108 |
|
|
// goes in .fixed_vectors.
|
109 |
|
|
#define SECTION_hal_vsr_table(_region_, _vma_, _lma_) \
|
110 |
|
|
.hal_vsr_table _vma_ : _lma_ \
|
111 |
|
|
{ FORCE_OUTPUT; KEEP (*(.hal_vsr_table)) } \
|
112 |
|
|
> _region_
|
113 |
|
|
|
114 |
|
|
#define SECTION_fixed_vectors(_region_, _vma_, _lma_) \
|
115 |
|
|
.fixed_vectors _vma_ : _lma_ \
|
116 |
|
|
{ FORCE_OUTPUT; KEEP (*(.fixed_vectors)) } \
|
117 |
|
|
> _region_
|
118 |
|
|
|
119 |
|
|
#define SECTION_rom_vectors(_region_, _vma_, _lma_) \
|
120 |
|
|
.rom_vectors _vma_ : _lma_ \
|
121 |
|
|
{ __rom_vectors_vma = ABSOLUTE(.); \
|
122 |
|
|
FORCE_OUTPUT; KEEP (*(.vectors)) } \
|
123 |
|
|
> _region_ \
|
124 |
|
|
__rom_vectors_lma = LOADADDR(.rom_vectors);
|
125 |
|
|
|
126 |
|
|
/* The following two sections are used for C++ exception handling
|
127 |
|
|
* only and so can be discarded if not used for that.
|
128 |
|
|
* These are both included directly from the SECTION_text
|
129 |
|
|
* definition and so, for now, are not expected to be listed
|
130 |
|
|
* separately in mlt files.
|
131 |
|
|
*/
|
132 |
|
|
#ifdef CYGPKG_LIBSTDCXX
|
133 |
|
|
#define SECTION_ARM_extab(_region_, _vma_, _lma_) \
|
134 |
|
|
.ARM.extab _vma_ : _lma_ \
|
135 |
|
|
{ PROVIDE (__stext = ABSOLUTE(.)); _stext = ABSOLUTE(.) ; \
|
136 |
|
|
FORCE_OUTPUT; \
|
137 |
|
|
*(.ARM.extab* .gnu.linkonce.armextab.*) } > _region_
|
138 |
|
|
|
139 |
|
|
#define SECTION_ARM_exidx(_region_, _vma_, _lma_) \
|
140 |
|
|
. = _vma_; \
|
141 |
|
|
. = ALIGN(AAPCS_ALIGN); \
|
142 |
|
|
__exidx_start = ABSOLUTE(.); \
|
143 |
|
|
.ARM.exidx ALIGN(AAPCS_ALIGN) : _lma_ { \
|
144 |
|
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*) \
|
145 |
|
|
FORCE_OUTPUT; \
|
146 |
|
|
} > _region_ \
|
147 |
|
|
__exidx_end = ABSOLUTE(.);
|
148 |
|
|
|
149 |
|
|
#else
|
150 |
|
|
#define SECTION_ARM_extab(_region_, _vma_, _lma_) \
|
151 |
|
|
.ARM.extab _vma_ : _lma_ \
|
152 |
|
|
{ PROVIDE (__stext = ABSOLUTE(.)); _stext = ABSOLUTE(.) ; \
|
153 |
|
|
FORCE_OUTPUT; \
|
154 |
|
|
} > _region_ \
|
155 |
|
|
/DISCARD/ 0 : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
|
156 |
|
|
|
157 |
|
|
#define SECTION_ARM_exidx(_region_, _vma_, _lma_) \
|
158 |
|
|
. = _vma_; \
|
159 |
|
|
. = ALIGN(AAPCS_ALIGN); \
|
160 |
|
|
__exidx_start = ABSOLUTE(.); \
|
161 |
|
|
.ARM.exidx ALIGN(AAPCS_ALIGN) : _lma_ { \
|
162 |
|
|
FORCE_OUTPUT; \
|
163 |
|
|
} > _region_ \
|
164 |
|
|
__exidx_end = ABSOLUTE(.); \
|
165 |
|
|
/DISCARD/ 0 : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
|
166 |
|
|
#endif
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
// We slot in the .ARM.extab and .ARM.exidx sections first. They
|
171 |
|
|
// need to be close to .text due to their relocations which may
|
172 |
|
|
// want small offsets - .rodata may be somewhere very different.
|
173 |
|
|
// This approach also allows forward compatibility with targets
|
174 |
|
|
// which haven't used the EABI before (no new SECTION_xxx definition
|
175 |
|
|
// to use).
|
176 |
|
|
// One glitch is that the AAPCS can require up to 8-byte alignment
|
177 |
|
|
// for double word types. For sections after the first (for which we
|
178 |
|
|
// "trust" the MLT files (probably a mistake)), we need to
|
179 |
|
|
// ensure the subsequent sections' VMA and LMA move in sync, which
|
180 |
|
|
// means keeping the same alignment, and thus since for example literal
|
181 |
|
|
// data in .text can require up to 8 byte alignment, the LMA must also
|
182 |
|
|
// be 8 byte aligned.
|
183 |
|
|
|
184 |
|
|
#define SECTION_text(_region_, _vma_, _lma_) \
|
185 |
|
|
SECTION_ARM_extab(_region_, _vma_, _lma_) \
|
186 |
|
|
SECTION_ARM_exidx(_region_, ALIGN(AAPCS_ALIGN), FOLLOWING_ALIGNED(.ARM.extab, AAPCS_ALIGN)) \
|
187 |
|
|
.text ALIGN(AAPCS_ALIGN) : FOLLOWING_ALIGNED(.ARM.exidx, AAPCS_ALIGN) \
|
188 |
|
|
{ \
|
189 |
|
|
*(.text*) *(.gnu.warning) *(.gnu.linkonce.t.*) *(.init) \
|
190 |
|
|
*(.glue_7) *(.glue_7t) \
|
191 |
|
|
__CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \
|
192 |
|
|
__DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \
|
193 |
|
|
} > _region_ \
|
194 |
|
|
_etext = .; PROVIDE (__etext = .);
|
195 |
|
|
|
196 |
|
|
#define SECTION_fini(_region_, _vma_, _lma_) \
|
197 |
|
|
.fini _vma_ : _lma_ \
|
198 |
|
|
{ FORCE_OUTPUT; *(.fini) } \
|
199 |
|
|
> _region_
|
200 |
|
|
|
201 |
|
|
#if defined(CYGPRI_PID_BE_WORKAROUND)
|
202 |
|
|
#define SECTION_rodata(_region_, _vma_, _lma_)
|
203 |
|
|
#define SECTION_rodata1(_region_, _vma_, _lma_)
|
204 |
|
|
#else
|
205 |
|
|
#define SECTION_rodata(_region_, _vma_, _lma_) \
|
206 |
|
|
.rodata _vma_ : _lma_ \
|
207 |
|
|
{ FORCE_OUTPUT; *(.rodata*) *(.gnu.linkonce.r.*) } \
|
208 |
|
|
> _region_
|
209 |
|
|
|
210 |
|
|
#define SECTION_rodata1(_region_, _vma_, _lma_) \
|
211 |
|
|
.rodata1 _vma_ : _lma_ \
|
212 |
|
|
{ FORCE_OUTPUT; *(.rodata1) } \
|
213 |
|
|
> _region_
|
214 |
|
|
#endif // CYGPRI_PID_BE_WORKAROUND
|
215 |
|
|
|
216 |
|
|
#define SECTION_fixup(_region_, _vma_, _lma_) \
|
217 |
|
|
.fixup _vma_ : _lma_ \
|
218 |
|
|
{ FORCE_OUTPUT; *(.fixup) } \
|
219 |
|
|
> _region_
|
220 |
|
|
|
221 |
|
|
#ifdef CYGPKG_LIBSTDCXX
|
222 |
|
|
/* We want to discard C++ exception frame data if we don't have the
|
223 |
|
|
* C++ support to use it. So there are two versions of the section
|
224 |
|
|
* definitions for .gcc_except_table and .eh_frame, one which keeps
|
225 |
|
|
* them, the other discards.
|
226 |
|
|
*/
|
227 |
|
|
#define SECTION_gcc_except_table(_region_, _vma_, _lma_) \
|
228 |
|
|
.gcc_except_table _vma_ : _lma_ \
|
229 |
|
|
{ FORCE_OUTPUT; \
|
230 |
|
|
KEEP(*(.gcc_except_table)) \
|
231 |
|
|
*(.gcc_except_table.*) \
|
232 |
|
|
} > _region_
|
233 |
|
|
|
234 |
|
|
#define SECTION_eh_frame(_region_, _vma_, _lma_) \
|
235 |
|
|
.eh_frame _vma_ : _lma_ \
|
236 |
|
|
{ \
|
237 |
|
|
FORCE_OUTPUT; __EH_FRAME_BEGIN__ = .; \
|
238 |
|
|
KEEP(*(.eh_frame)) \
|
239 |
|
|
__FRAME_END__ = .; \
|
240 |
|
|
. = . + 8; \
|
241 |
|
|
} > _region_ = 0
|
242 |
|
|
#else
|
243 |
|
|
#define SECTION_gcc_except_table(_region_, _vma_, _lma_) \
|
244 |
|
|
.gcc_except_table _vma_ : _lma_ \
|
245 |
|
|
{ FORCE_OUTPUT; \
|
246 |
|
|
} > _region_ \
|
247 |
|
|
/DISCARD/ 0 : { *(.gcc_except_table*) }
|
248 |
|
|
|
249 |
|
|
#define SECTION_eh_frame(_region_, _vma_, _lma_) \
|
250 |
|
|
.eh_frame _vma_ : _lma_ \
|
251 |
|
|
{ \
|
252 |
|
|
FORCE_OUTPUT; __EH_FRAME_BEGIN__ = .; \
|
253 |
|
|
__FRAME_END__ = .; \
|
254 |
|
|
} > _region_ \
|
255 |
|
|
/DISCARD/ 0 : { *(.eh_frame) }
|
256 |
|
|
#endif
|
257 |
|
|
|
258 |
|
|
#define SECTION_RELOCS(_region_, _vma_, _lma_) \
|
259 |
|
|
.rel.text : \
|
260 |
|
|
{ \
|
261 |
|
|
*(.rel.text) \
|
262 |
|
|
*(.rel.text.*) \
|
263 |
|
|
*(.rel.gnu.linkonce.t*) \
|
264 |
|
|
} > _region_ \
|
265 |
|
|
.rela.text : \
|
266 |
|
|
{ \
|
267 |
|
|
*(.rela.text) \
|
268 |
|
|
*(.rela.text.*) \
|
269 |
|
|
*(.rela.gnu.linkonce.t*) \
|
270 |
|
|
} > _region_ \
|
271 |
|
|
.rel.data : \
|
272 |
|
|
{ \
|
273 |
|
|
*(.rel.data) \
|
274 |
|
|
*(.rel.data.*) \
|
275 |
|
|
*(.rel.gnu.linkonce.d*) \
|
276 |
|
|
} > _region_ \
|
277 |
|
|
.rela.data : \
|
278 |
|
|
{ \
|
279 |
|
|
*(.rela.data) \
|
280 |
|
|
*(.rela.data.*) \
|
281 |
|
|
*(.rela.gnu.linkonce.d*) \
|
282 |
|
|
} > _region_ \
|
283 |
|
|
.rel.rodata : \
|
284 |
|
|
{ \
|
285 |
|
|
*(.rel.rodata) \
|
286 |
|
|
*(.rel.rodata.*) \
|
287 |
|
|
*(.rel.gnu.linkonce.r*) \
|
288 |
|
|
} > _region_ \
|
289 |
|
|
.rela.rodata : \
|
290 |
|
|
{ \
|
291 |
|
|
*(.rela.rodata) \
|
292 |
|
|
*(.rela.rodata.*) \
|
293 |
|
|
*(.rela.gnu.linkonce.r*) \
|
294 |
|
|
} > _region_ \
|
295 |
|
|
.rel.got : { *(.rel.got) } > _region_ \
|
296 |
|
|
.rela.got : { *(.rela.got) } > _region_ \
|
297 |
|
|
.rel.ctors : { *(.rel.ctors) } > _region_ \
|
298 |
|
|
.rela.ctors : { *(.rela.ctors) } > _region_ \
|
299 |
|
|
.rel.dtors : { *(.rel.dtors) } > _region_ \
|
300 |
|
|
.rela.dtors : { *(.rela.dtors) } > _region_ \
|
301 |
|
|
.rel.init : { *(.rel.init) } > _region_ \
|
302 |
|
|
.rela.init : { *(.rela.init) } > _region_ \
|
303 |
|
|
.rel.fini : { *(.rel.fini) } > _region_ \
|
304 |
|
|
.rela.fini : { *(.rela.fini) } > _region_ \
|
305 |
|
|
.rel.bss : { *(.rel.bss) } > _region_ \
|
306 |
|
|
.rela.bss : { *(.rela.bss) } > _region_ \
|
307 |
|
|
.rel.plt : { *(.rel.plt) } > _region_ \
|
308 |
|
|
.rela.plt : { *(.rela.plt) } > _region_ \
|
309 |
|
|
.rel.dyn : { *(.rel.dyn) } > _region_
|
310 |
|
|
|
311 |
|
|
#define SECTION_got(_region_, _vma_, _lma_) \
|
312 |
|
|
.got _vma_ : _lma_ \
|
313 |
|
|
{ \
|
314 |
|
|
FORCE_OUTPUT; *(.got.plt) *(.got) \
|
315 |
|
|
_GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \
|
316 |
|
|
_GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \
|
317 |
|
|
} > _region_
|
318 |
|
|
|
319 |
|
|
#define SECTION_mmu_tables(_region_, _vma_, _lma_) \
|
320 |
|
|
.mmu_tables _vma_ : _lma_ \
|
321 |
|
|
{ FORCE_OUTPUT; *(.mmu_tables) } \
|
322 |
|
|
> _region_
|
323 |
|
|
|
324 |
|
|
#define SECTION_sram(_region_, _vma_, _lma_) \
|
325 |
|
|
.sram _vma_ : _lma_ \
|
326 |
|
|
{ FORCE_OUTPUT; *(.sram*) } \
|
327 |
|
|
> _region_
|
328 |
|
|
|
329 |
|
|
#define SECTION_data(_region_, _vma_, _lma_) \
|
330 |
|
|
.data _vma_ : _lma_ \
|
331 |
|
|
{ __ram_data_start = ABSOLUTE (.); \
|
332 |
|
|
*(.data*) *(.data1) *(.gnu.linkonce.d.*) MERGE_IN_RODATA \
|
333 |
|
|
. = ALIGN (4); \
|
334 |
|
|
KEEP(*( SORT (.ecos.table.*))) ; \
|
335 |
|
|
. = ALIGN (4); \
|
336 |
|
|
__init_array_start__ = ABSOLUTE (.); KEEP (*(SORT (.init_array.*))) \
|
337 |
|
|
KEEP (*(SORT (.init_array))) __init_array_end__ = ABSOLUTE (.); \
|
338 |
|
|
*(.dynamic) *(.sdata*) *(.gnu.linkonce.s.*) \
|
339 |
|
|
. = ALIGN (4); *(.2ram.*) } \
|
340 |
|
|
> _region_ \
|
341 |
|
|
__rom_data_start = LOADADDR (.data); \
|
342 |
|
|
__ram_data_end = .; PROVIDE (__ram_data_end = .); _edata = .; PROVIDE (edata = .); \
|
343 |
|
|
PROVIDE (__rom_data_end = LOADADDR (.data) + SIZEOF(.data));
|
344 |
|
|
|
345 |
|
|
#define SECTION_bss(_region_, _vma_, _lma_) \
|
346 |
|
|
.bss _vma_ : _lma_ \
|
347 |
|
|
{ __bss_start = ABSOLUTE (.); \
|
348 |
|
|
*(.scommon) *(.dynsbss) *(.sbss*) *(.gnu.linkonce.sb.*) \
|
349 |
|
|
*(.dynbss) *(.bss*) *(.gnu.linkonce.b.*) *(COMMON) \
|
350 |
|
|
__bss_end = ABSOLUTE (.); } \
|
351 |
|
|
> _region_
|
352 |
|
|
|
353 |
|
|
#define SECTIONS_END . = ALIGN(4); _end = .; PROVIDE (end = .);
|
354 |
|
|
|
355 |
|
|
#include
|
356 |
|
|
#include CYGHWR_MEMORY_LAYOUT_LDI
|