source: rtems/c/src/lib/libbsp/arm/shared/startup/linkcmds.base @ eba0626

4.115
Last change on this file since eba0626 was 4ec210fe, checked in by Sebastian Huber <sebastian.huber@…>, on 01/13/14 at 12:18:26

bsps/arm: Use ALIGN_WITH_INPUT

The ALIGN_WITH_INPUT helps to make this linker script more reliable.
See also:

https://sourceware.org/ml/binutils/2013-06/msg00246.html

https://sourceware.org/binutils/docs-2.24/ld/Forced-Output-Alignment.html#Forced-Output-Alignment

This reverts commit 4a9e52eefc510d7022ddc61c4ecde8db6b9a0217.

This reverts commit 1ab4f76900d012b5a9dbce2851add060f11ce13a.

  • Property mode set to 100644
File size: 15.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_linker
5 *
6 * @brief Linker command base file.
7 */
8
9/*
10 * Copyright (c) 2008-2013 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
24
25OUTPUT_ARCH (arm)
26
27ENTRY (_start)
28
29/*
30 * Global symbols that may be defined externally
31 */
32
33bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64;
34
35bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1;
36bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
37bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
38
39bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8;
40
41bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 0;
42bsp_stack_abt_size = ALIGN (bsp_stack_abt_size, bsp_stack_align);
43
44bsp_stack_fiq_size = DEFINED (bsp_stack_fiq_size) ? bsp_stack_fiq_size : 0;
45bsp_stack_fiq_size = ALIGN (bsp_stack_fiq_size, bsp_stack_align);
46
47bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 0;
48bsp_stack_irq_size = ALIGN (bsp_stack_irq_size, bsp_stack_align);
49
50bsp_stack_svc_size = DEFINED (bsp_stack_svc_size) ? bsp_stack_svc_size : 0;
51bsp_stack_svc_size = ALIGN (bsp_stack_svc_size, bsp_stack_align);
52
53bsp_stack_und_size = DEFINED (bsp_stack_und_size) ? bsp_stack_und_size : 0;
54bsp_stack_und_size = ALIGN (bsp_stack_und_size, bsp_stack_align);
55
56bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 0;
57bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
58
59bsp_stack_all_size = bsp_stack_abt_size + bsp_stack_fiq_size + bsp_stack_irq_size + bsp_stack_svc_size + bsp_stack_und_size + bsp_stack_main_size;
60
61bsp_processor_count = DEFINED (bsp_processor_count) ? bsp_processor_count : 1;
62
63MEMORY {
64        UNEXPECTED_SECTIONS : ORIGIN = 0xffffffff, LENGTH = 0
65}
66
67SECTIONS {
68        .start : ALIGN_WITH_INPUT {
69                bsp_section_start_begin = .;
70                KEEP (*(.bsp_start_text))
71                KEEP (*(.bsp_start_data))
72                bsp_section_start_end = .;
73        } > REGION_START AT > REGION_START
74        bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;
75
76        .xbarrier : ALIGN_WITH_INPUT {
77                . = ALIGN (bsp_section_xbarrier_align);
78        } > REGION_VECTOR
79
80        .text : ALIGN_WITH_INPUT {
81                bsp_section_text_begin = .;
82                *(.text.unlikely .text.*_unlikely)
83                *(.text .stub .text.* .gnu.linkonce.t.*)
84                /* .gnu.warning sections are handled specially by elf32.em.  */
85                *(.gnu.warning)
86                *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
87        } > REGION_TEXT AT > REGION_TEXT_LOAD
88        .init : ALIGN_WITH_INPUT {
89                KEEP (*(.init))
90        } > REGION_TEXT AT > REGION_TEXT_LOAD
91        .fini : ALIGN_WITH_INPUT {
92                KEEP (*(.fini))
93                bsp_section_text_end = .;
94        } > REGION_TEXT AT > REGION_TEXT_LOAD
95        bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
96        bsp_section_text_load_begin = LOADADDR (.text);
97        bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;
98
99        .robarrier : ALIGN_WITH_INPUT {
100                . = ALIGN (bsp_section_robarrier_align);
101        } > REGION_RODATA
102
103        .rodata : ALIGN_WITH_INPUT {
104                bsp_section_rodata_begin = .;
105                *(.rodata .rodata.* .gnu.linkonce.r.*)
106        } > REGION_RODATA AT > REGION_RODATA_LOAD
107        .rodata1 : ALIGN_WITH_INPUT {
108                *(.rodata1)
109        } > REGION_RODATA AT > REGION_RODATA_LOAD
110        .ARM.extab : ALIGN_WITH_INPUT {
111                *(.ARM.extab* .gnu.linkonce.armextab.*)
112        } > REGION_RODATA AT > REGION_RODATA_LOAD
113        .ARM.exidx : ALIGN_WITH_INPUT {
114                __exidx_start = .;
115                *(.ARM.exidx* .gnu.linkonce.armexidx.*)
116                __exidx_end = .;
117        } > REGION_RODATA AT > REGION_RODATA_LOAD
118        .eh_frame : ALIGN_WITH_INPUT {
119                KEEP (*(.eh_frame))
120        } > REGION_RODATA AT > REGION_RODATA_LOAD
121        .gcc_except_table : ALIGN_WITH_INPUT {
122                *(.gcc_except_table .gcc_except_table.*)
123        } > REGION_RODATA AT > REGION_RODATA_LOAD
124        .tdata : ALIGN_WITH_INPUT {
125                *(.tdata .tdata.* .gnu.linkonce.td.*)
126        } > REGION_RODATA AT > REGION_RODATA_LOAD
127        .tbss : ALIGN_WITH_INPUT {
128                *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
129        } > REGION_RODATA AT > REGION_RODATA_LOAD
130        .preinit_array : ALIGN_WITH_INPUT {
131                PROVIDE_HIDDEN (__preinit_array_start = .);
132                KEEP (*(.preinit_array))
133                PROVIDE_HIDDEN (__preinit_array_end = .);
134        } > REGION_RODATA AT > REGION_RODATA_LOAD
135        .init_array : ALIGN_WITH_INPUT {
136                PROVIDE_HIDDEN (__init_array_start = .);
137                KEEP (*(SORT(.init_array.*)))
138                KEEP (*(.init_array))
139                PROVIDE_HIDDEN (__init_array_end = .);
140        } > REGION_RODATA AT > REGION_RODATA_LOAD
141        .fini_array : ALIGN_WITH_INPUT {
142                PROVIDE_HIDDEN (__fini_array_start = .);
143                KEEP (*(.fini_array))
144                KEEP (*(SORT(.fini_array.*)))
145                PROVIDE_HIDDEN (__fini_array_end = .);
146        } > REGION_RODATA AT > REGION_RODATA_LOAD
147        .ctors : ALIGN_WITH_INPUT {
148                /* gcc uses crtbegin.o to find the start of
149                   the constructors, so we make sure it is
150                   first.  Because this is a wildcard, it
151                   doesn't matter if the user does not
152                   actually link against crtbegin.o; the
153                   linker won't look for a file to match a
154                   wildcard.  The wildcard also means that it
155                   doesn't matter which directory crtbegin.o
156                   is in.  */
157                KEEP (*crtbegin.o(.ctors))
158                KEEP (*crtbegin?.o(.ctors))
159                /* We don't want to include the .ctor section from
160                   the crtend.o file until after the sorted ctors.
161                   The .ctor section from the crtend file contains the
162                   end of ctors marker and it must be last */
163                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
164                KEEP (*(SORT(.ctors.*)))
165                KEEP (*(.ctors))
166        } > REGION_RODATA AT > REGION_RODATA_LOAD
167        .dtors : ALIGN_WITH_INPUT {
168                KEEP (*crtbegin.o(.dtors))
169                KEEP (*crtbegin?.o(.dtors))
170                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
171                KEEP (*(SORT(.dtors.*)))
172                KEEP (*(.dtors))
173        } > REGION_RODATA AT > REGION_RODATA_LOAD
174        .data.rel.ro : ALIGN_WITH_INPUT {
175                *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
176                *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*)
177        } > REGION_RODATA AT > REGION_RODATA_LOAD
178        .jcr : ALIGN_WITH_INPUT {
179                KEEP (*(.jcr))
180        } > REGION_RODATA AT > REGION_RODATA_LOAD
181        .interp : ALIGN_WITH_INPUT {
182                *(.interp)
183        } > REGION_RODATA AT > REGION_RODATA_LOAD
184        .note.gnu.build-id : ALIGN_WITH_INPUT {
185                *(.note.gnu.build-id)
186        } > REGION_RODATA AT > REGION_RODATA_LOAD
187        .hash : ALIGN_WITH_INPUT {
188                *(.hash)
189        } > REGION_RODATA AT > REGION_RODATA_LOAD
190        .gnu.hash : ALIGN_WITH_INPUT {
191                *(.gnu.hash)
192        } > REGION_RODATA AT > REGION_RODATA_LOAD
193        .dynsym : ALIGN_WITH_INPUT {
194                *(.dynsym)
195        } > REGION_RODATA AT > REGION_RODATA_LOAD
196        .dynstr : ALIGN_WITH_INPUT {
197                *(.dynstr)
198        } > REGION_RODATA AT > REGION_RODATA_LOAD
199        .gnu.version : ALIGN_WITH_INPUT {
200                *(.gnu.version)
201        } > REGION_RODATA AT > REGION_RODATA_LOAD
202        .gnu.version_d : ALIGN_WITH_INPUT {
203                *(.gnu.version_d)
204        } > REGION_RODATA AT > REGION_RODATA_LOAD
205        .gnu.version_r : ALIGN_WITH_INPUT {
206                *(.gnu.version_r)
207        } > REGION_RODATA AT > REGION_RODATA_LOAD
208        .rel.dyn : ALIGN_WITH_INPUT {
209                *(.rel.init)
210                *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
211                *(.rel.fini)
212                *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
213                *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
214                *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
215                *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
216                *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
217                *(.rel.ctors)
218                *(.rel.dtors)
219                *(.rel.got)
220                *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
221                PROVIDE_HIDDEN (__rel_iplt_start = .);
222                *(.rel.iplt)
223                PROVIDE_HIDDEN (__rel_iplt_end = .);
224                PROVIDE_HIDDEN (__rela_iplt_start = .);
225                PROVIDE_HIDDEN (__rela_iplt_end = .);
226        } > REGION_RODATA AT > REGION_RODATA_LOAD
227        .rela.dyn : ALIGN_WITH_INPUT {
228                *(.rela.init)
229                *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
230                *(.rela.fini)
231                *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
232                *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
233                *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
234                *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
235                *(.rela.ctors)
236                *(.rela.dtors)
237                *(.rela.got)
238                *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
239                PROVIDE_HIDDEN (__rel_iplt_start = .);
240                PROVIDE_HIDDEN (__rel_iplt_end = .);
241                PROVIDE_HIDDEN (__rela_iplt_start = .);
242                *(.rela.iplt)
243                PROVIDE_HIDDEN (__rela_iplt_end = .);
244        } > REGION_RODATA AT > REGION_RODATA_LOAD
245        .rel.plt : ALIGN_WITH_INPUT {
246                *(.rel.plt)
247        } > REGION_RODATA AT > REGION_RODATA_LOAD
248        .rela.plt : ALIGN_WITH_INPUT {
249                *(.rela.plt)
250        } > REGION_RODATA AT > REGION_RODATA_LOAD
251        .plt : ALIGN_WITH_INPUT {
252                *(.plt)
253        } > REGION_RODATA AT > REGION_RODATA_LOAD
254        .iplt : ALIGN_WITH_INPUT {
255                *(.iplt)
256        } > REGION_RODATA AT > REGION_RODATA_LOAD
257        .dynamic : ALIGN_WITH_INPUT {
258                *(.dynamic)
259        } > REGION_RODATA AT > REGION_RODATA_LOAD
260        .got : ALIGN_WITH_INPUT {
261                *(.got.plt) *(.igot.plt) *(.got) *(.igot)
262        } > REGION_RODATA AT > REGION_RODATA_LOAD
263        .rtemsroset : ALIGN_WITH_INPUT {
264                /* Special FreeBSD linker set sections */
265                __start_set_sysctl_set = .;
266                *(set_sysctl_*);
267                __stop_set_sysctl_set = .;
268                *(set_domain_*);
269                *(set_pseudo_*);
270
271                KEEP (*(SORT(.rtemsroset.*)))
272                bsp_section_rodata_end = .;
273        } > REGION_RODATA AT > REGION_RODATA_LOAD
274        bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
275        bsp_section_rodata_load_begin = LOADADDR (.rodata);
276        bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
277
278        .rwbarrier : ALIGN_WITH_INPUT {
279                . = ALIGN (bsp_section_rwbarrier_align);
280        } > REGION_DATA
281
282        .vector : ALIGN_WITH_INPUT {
283                bsp_section_vector_begin = .;
284
285                . = . + DEFINED (bsp_vector_table_in_start_section) ? 0 : bsp_vector_table_size;
286
287                . = ALIGN (bsp_stack_align);
288
289                bsp_stack_abt_begin = .;
290                . = . + bsp_stack_abt_size;
291                bsp_stack_abt_end = .;
292
293                bsp_stack_fiq_begin = .;
294                . = . + bsp_stack_fiq_size;
295                bsp_stack_fiq_end = .;
296
297                bsp_stack_irq_begin = .;
298                . = . + bsp_stack_irq_size;
299                bsp_stack_irq_end = .;
300
301                bsp_stack_svc_begin = .;
302                . = . + bsp_stack_svc_size;
303                bsp_stack_svc_end = .;
304
305                bsp_stack_und_begin = .;
306                . = . + bsp_stack_und_size;
307                bsp_stack_und_end = .;
308
309                bsp_stack_main_begin = .;
310                . = . + bsp_stack_main_size;
311                bsp_stack_main_end = .;
312
313                bsp_stack_secondary_processors_begin = .;
314                . = . + (bsp_processor_count - 1) * bsp_stack_all_size;
315                bsp_stack_secondary_processors_end = .;
316
317                *(.bsp_vector)
318                bsp_section_vector_end = .;
319        } > REGION_VECTOR AT > REGION_VECTOR
320        bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;
321        bsp_vector_table_begin = DEFINED (bsp_vector_table_in_start_section) ? bsp_section_start_begin : bsp_section_vector_begin;
322        bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;
323
324        .fast_text : ALIGN_WITH_INPUT {
325                bsp_section_fast_text_begin = .;
326                *(.bsp_fast_text)
327                bsp_section_fast_text_end = .;
328        } > REGION_FAST_TEXT AT > REGION_FAST_TEXT_LOAD
329        bsp_section_fast_text_size = bsp_section_fast_text_end - bsp_section_fast_text_begin;
330        bsp_section_fast_text_load_begin = LOADADDR (.fast_text);
331        bsp_section_fast_text_load_end = bsp_section_fast_text_load_begin + bsp_section_fast_text_size;
332
333        .fast_data : ALIGN_WITH_INPUT {
334                bsp_section_fast_data_begin = .;
335                *(.bsp_fast_data)
336                bsp_section_fast_data_end = .;
337        } > REGION_FAST_DATA AT > REGION_FAST_DATA_LOAD
338        bsp_section_fast_data_size = bsp_section_fast_data_end - bsp_section_fast_data_begin;
339        bsp_section_fast_data_load_begin = LOADADDR (.fast_data);
340        bsp_section_fast_data_load_end = bsp_section_fast_data_load_begin + bsp_section_fast_data_size;
341
342        .data : ALIGN_WITH_INPUT {
343                bsp_section_data_begin = .;
344                *(.data .data.* .gnu.linkonce.d.*)
345                SORT(CONSTRUCTORS)
346        } > REGION_DATA AT > REGION_DATA_LOAD
347        .data1 : ALIGN_WITH_INPUT {
348                *(.data1)
349        } > REGION_DATA AT > REGION_DATA_LOAD
350        .rtemsrwset : ALIGN_WITH_INPUT {
351                KEEP (*(SORT(.rtemsrwset.*)))
352                bsp_section_data_end = .;
353        } > REGION_DATA AT > REGION_DATA_LOAD
354        bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
355        bsp_section_data_load_begin = LOADADDR (.data);
356        bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
357
358        .bss : ALIGN_WITH_INPUT {
359                bsp_section_bss_begin = .;
360                *(.dynbss)
361                *(.bss .bss.* .gnu.linkonce.b.*)
362                *(COMMON)
363                bsp_section_bss_end = .;
364        } > REGION_BSS AT > REGION_BSS
365        bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
366
367        .work : ALIGN_WITH_INPUT {
368                /*
369                 * The work section will occupy the remaining REGION_WORK region and
370                 * contains the RTEMS work space and heap.
371                 */
372                bsp_section_work_begin = .;
373                . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
374                bsp_section_work_end = .;
375        } > REGION_WORK AT > REGION_WORK
376        bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
377
378        .stack : ALIGN_WITH_INPUT {
379                /*
380                 * The stack section will occupy the remaining REGION_STACK region and may
381                 * contain the task stacks.  Depending on the region distribution this
382                 * section may be of zero size.
383                 */
384                bsp_section_stack_begin = .;
385                . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);
386                bsp_section_stack_end = .;
387        } > REGION_STACK AT > REGION_STACK
388        bsp_section_stack_size = bsp_section_stack_end - bsp_section_stack_begin;
389
390        /* FIXME */
391        RamBase = ORIGIN (REGION_WORK);
392        RamSize = LENGTH (REGION_WORK);
393        WorkAreaBase = bsp_section_work_begin;
394        HeapSize = 0;
395
396        /* Stabs debugging sections.  */
397        .stab          0 : { *(.stab) }
398        .stabstr       0 : { *(.stabstr) }
399        .stab.excl     0 : { *(.stab.excl) }
400        .stab.exclstr  0 : { *(.stab.exclstr) }
401        .stab.index    0 : { *(.stab.index) }
402        .stab.indexstr 0 : { *(.stab.indexstr) }
403        .comment       0 : { *(.comment) }
404        /* DWARF debug sections.
405           Symbols in the DWARF debugging sections are relative to the beginning
406           of the section so we begin them at 0.  */
407        /* DWARF 1 */
408        .debug          0 : { *(.debug) }
409        .line           0 : { *(.line) }
410        /* GNU DWARF 1 extensions */
411        .debug_srcinfo  0 : { *(.debug_srcinfo) }
412        .debug_sfnames  0 : { *(.debug_sfnames) }
413        /* DWARF 1.1 and DWARF 2 */
414        .debug_aranges  0 : { *(.debug_aranges) }
415        .debug_pubnames 0 : { *(.debug_pubnames) }
416        /* DWARF 2 */
417        .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
418        .debug_abbrev   0 : { *(.debug_abbrev) }
419        .debug_line     0 : { *(.debug_line) }
420        .debug_frame    0 : { *(.debug_frame) }
421        .debug_str      0 : { *(.debug_str) }
422        .debug_loc      0 : { *(.debug_loc) }
423        .debug_macinfo  0 : { *(.debug_macinfo) }
424        /* SGI/MIPS DWARF 2 extensions */
425        .debug_weaknames 0 : { *(.debug_weaknames) }
426        .debug_funcnames 0 : { *(.debug_funcnames) }
427        .debug_typenames 0 : { *(.debug_typenames) }
428        .debug_varnames  0 : { *(.debug_varnames) }
429        /* DWARF 3 */
430        .debug_pubtypes 0 : { *(.debug_pubtypes) }
431        .debug_ranges   0 : { *(.debug_ranges) }
432        /* DWARF extension */
433        .debug_macro    0 : { *(.debug_macro) }
434        .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
435        .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
436        /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
437
438        /*
439         * This is a RTEMS specific section to catch all unexpected input
440         * sections.  In case you get an error like
441         *   "section `.unexpected_sections' will not fit in region
442         *   `UNEXPECTED_SECTIONS'"
443         * you have to figure out the offending input section and add it to the
444         * appropriate output section definition above.
445         */
446        .unexpected_sections : { *(*) } > UNEXPECTED_SECTIONS
447}
Note: See TracBrowser for help on using the repository browser.