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

4.115
Last change on this file since d60e760 was d60e760, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/14 at 07:45:39

bsps: Fix TLS support in linker command files

The TLS section symbols had wrong values in case of an empty TLS data
section and a nonempty TLS BSS section.

  • Property mode set to 100644
File size: 15.6 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.org/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 AT > 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 AT > 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                _TLS_Data_begin = .;
126                *(.tdata .tdata.* .gnu.linkonce.td.*)
127                _TLS_Data_end = .;
128        } > REGION_RODATA AT > REGION_RODATA_LOAD
129        .tbss : ALIGN_WITH_INPUT {
130                _TLS_BSS_begin = .;
131                *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
132                _TLS_BSS_end = .;
133        } > REGION_RODATA AT > REGION_RODATA_LOAD
134        _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
135        _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
136        _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
137        _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
138        _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
139        _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
140        .preinit_array : ALIGN_WITH_INPUT {
141                PROVIDE_HIDDEN (__preinit_array_start = .);
142                KEEP (*(.preinit_array))
143                PROVIDE_HIDDEN (__preinit_array_end = .);
144        } > REGION_RODATA AT > REGION_RODATA_LOAD
145        .init_array : ALIGN_WITH_INPUT {
146                PROVIDE_HIDDEN (__init_array_start = .);
147                KEEP (*(SORT(.init_array.*)))
148                KEEP (*(.init_array))
149                PROVIDE_HIDDEN (__init_array_end = .);
150        } > REGION_RODATA AT > REGION_RODATA_LOAD
151        .fini_array : ALIGN_WITH_INPUT {
152                PROVIDE_HIDDEN (__fini_array_start = .);
153                KEEP (*(.fini_array))
154                KEEP (*(SORT(.fini_array.*)))
155                PROVIDE_HIDDEN (__fini_array_end = .);
156        } > REGION_RODATA AT > REGION_RODATA_LOAD
157        .ctors : ALIGN_WITH_INPUT {
158                /* gcc uses crtbegin.o to find the start of
159                   the constructors, so we make sure it is
160                   first.  Because this is a wildcard, it
161                   doesn't matter if the user does not
162                   actually link against crtbegin.o; the
163                   linker won't look for a file to match a
164                   wildcard.  The wildcard also means that it
165                   doesn't matter which directory crtbegin.o
166                   is in.  */
167                KEEP (*crtbegin.o(.ctors))
168                KEEP (*crtbegin?.o(.ctors))
169                /* We don't want to include the .ctor section from
170                   the crtend.o file until after the sorted ctors.
171                   The .ctor section from the crtend file contains the
172                   end of ctors marker and it must be last */
173                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
174                KEEP (*(SORT(.ctors.*)))
175                KEEP (*(.ctors))
176        } > REGION_RODATA AT > REGION_RODATA_LOAD
177        .dtors : ALIGN_WITH_INPUT {
178                KEEP (*crtbegin.o(.dtors))
179                KEEP (*crtbegin?.o(.dtors))
180                KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
181                KEEP (*(SORT(.dtors.*)))
182                KEEP (*(.dtors))
183        } > REGION_RODATA AT > REGION_RODATA_LOAD
184        .data.rel.ro : ALIGN_WITH_INPUT {
185                *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
186                *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*)
187        } > REGION_RODATA AT > REGION_RODATA_LOAD
188        .jcr : ALIGN_WITH_INPUT {
189                KEEP (*(.jcr))
190        } > REGION_RODATA AT > REGION_RODATA_LOAD
191        .interp : ALIGN_WITH_INPUT {
192                *(.interp)
193        } > REGION_RODATA AT > REGION_RODATA_LOAD
194        .note.gnu.build-id : ALIGN_WITH_INPUT {
195                *(.note.gnu.build-id)
196        } > REGION_RODATA AT > REGION_RODATA_LOAD
197        .hash : ALIGN_WITH_INPUT {
198                *(.hash)
199        } > REGION_RODATA AT > REGION_RODATA_LOAD
200        .gnu.hash : ALIGN_WITH_INPUT {
201                *(.gnu.hash)
202        } > REGION_RODATA AT > REGION_RODATA_LOAD
203        .dynsym : ALIGN_WITH_INPUT {
204                *(.dynsym)
205        } > REGION_RODATA AT > REGION_RODATA_LOAD
206        .dynstr : ALIGN_WITH_INPUT {
207                *(.dynstr)
208        } > REGION_RODATA AT > REGION_RODATA_LOAD
209        .gnu.version : ALIGN_WITH_INPUT {
210                *(.gnu.version)
211        } > REGION_RODATA AT > REGION_RODATA_LOAD
212        .gnu.version_d : ALIGN_WITH_INPUT {
213                *(.gnu.version_d)
214        } > REGION_RODATA AT > REGION_RODATA_LOAD
215        .gnu.version_r : ALIGN_WITH_INPUT {
216                *(.gnu.version_r)
217        } > REGION_RODATA AT > REGION_RODATA_LOAD
218        .rel.dyn : ALIGN_WITH_INPUT {
219                *(.rel.init)
220                *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
221                *(.rel.fini)
222                *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
223                *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
224                *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
225                *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
226                *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
227                *(.rel.ctors)
228                *(.rel.dtors)
229                *(.rel.got)
230                *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
231                PROVIDE_HIDDEN (__rel_iplt_start = .);
232                *(.rel.iplt)
233                PROVIDE_HIDDEN (__rel_iplt_end = .);
234                PROVIDE_HIDDEN (__rela_iplt_start = .);
235                PROVIDE_HIDDEN (__rela_iplt_end = .);
236        } > REGION_RODATA AT > REGION_RODATA_LOAD
237        .rela.dyn : ALIGN_WITH_INPUT {
238                *(.rela.init)
239                *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
240                *(.rela.fini)
241                *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
242                *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
243                *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
244                *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
245                *(.rela.ctors)
246                *(.rela.dtors)
247                *(.rela.got)
248                *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
249                PROVIDE_HIDDEN (__rel_iplt_start = .);
250                PROVIDE_HIDDEN (__rel_iplt_end = .);
251                PROVIDE_HIDDEN (__rela_iplt_start = .);
252                *(.rela.iplt)
253                PROVIDE_HIDDEN (__rela_iplt_end = .);
254        } > REGION_RODATA AT > REGION_RODATA_LOAD
255        .rel.plt : ALIGN_WITH_INPUT {
256                *(.rel.plt)
257        } > REGION_RODATA AT > REGION_RODATA_LOAD
258        .rela.plt : ALIGN_WITH_INPUT {
259                *(.rela.plt)
260        } > REGION_RODATA AT > REGION_RODATA_LOAD
261        .plt : ALIGN_WITH_INPUT {
262                *(.plt)
263        } > REGION_RODATA AT > REGION_RODATA_LOAD
264        .iplt : ALIGN_WITH_INPUT {
265                *(.iplt)
266        } > REGION_RODATA AT > REGION_RODATA_LOAD
267        .dynamic : ALIGN_WITH_INPUT {
268                *(.dynamic)
269        } > REGION_RODATA AT > REGION_RODATA_LOAD
270        .got : ALIGN_WITH_INPUT {
271                *(.got.plt) *(.igot.plt) *(.got) *(.igot)
272        } > REGION_RODATA AT > REGION_RODATA_LOAD
273        .rtemsroset : ALIGN_WITH_INPUT {
274                /* Special FreeBSD linker set sections */
275                __start_set_sysctl_set = .;
276                *(set_sysctl_*);
277                __stop_set_sysctl_set = .;
278                *(set_domain_*);
279                *(set_pseudo_*);
280
281                KEEP (*(SORT(.rtemsroset.*)))
282                bsp_section_rodata_end = .;
283        } > REGION_RODATA AT > REGION_RODATA_LOAD
284        bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
285        bsp_section_rodata_load_begin = LOADADDR (.rodata);
286        bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
287
288        .rwbarrier : ALIGN_WITH_INPUT {
289                . = ALIGN (bsp_section_rwbarrier_align);
290        } > REGION_DATA AT > REGION_DATA
291
292        .vector : ALIGN_WITH_INPUT {
293                bsp_section_vector_begin = .;
294
295                . = . + DEFINED (bsp_vector_table_in_start_section) ? 0 : bsp_vector_table_size;
296
297                . = ALIGN (bsp_stack_align);
298
299                bsp_stack_abt_begin = .;
300                . = . + bsp_stack_abt_size;
301                bsp_stack_abt_end = .;
302
303                bsp_stack_fiq_begin = .;
304                . = . + bsp_stack_fiq_size;
305                bsp_stack_fiq_end = .;
306
307                bsp_stack_irq_begin = .;
308                . = . + bsp_stack_irq_size;
309                bsp_stack_irq_end = .;
310
311                bsp_stack_svc_begin = .;
312                . = . + bsp_stack_svc_size;
313                bsp_stack_svc_end = .;
314
315                bsp_stack_und_begin = .;
316                . = . + bsp_stack_und_size;
317                bsp_stack_und_end = .;
318
319                bsp_stack_main_begin = .;
320                . = . + bsp_stack_main_size;
321                bsp_stack_main_end = .;
322
323                bsp_stack_secondary_processors_begin = .;
324                . = . + (bsp_processor_count - 1) * bsp_stack_all_size;
325                bsp_stack_secondary_processors_end = .;
326
327                *(.bsp_vector)
328                bsp_section_vector_end = .;
329        } > REGION_VECTOR AT > REGION_VECTOR
330        bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;
331        bsp_vector_table_begin = DEFINED (bsp_vector_table_in_start_section) ? bsp_section_start_begin : bsp_section_vector_begin;
332        bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;
333
334        .fast_text : ALIGN_WITH_INPUT {
335                bsp_section_fast_text_begin = .;
336                *(.bsp_fast_text)
337                bsp_section_fast_text_end = .;
338        } > REGION_FAST_TEXT AT > REGION_FAST_TEXT_LOAD
339        bsp_section_fast_text_size = bsp_section_fast_text_end - bsp_section_fast_text_begin;
340        bsp_section_fast_text_load_begin = LOADADDR (.fast_text);
341        bsp_section_fast_text_load_end = bsp_section_fast_text_load_begin + bsp_section_fast_text_size;
342
343        .fast_data : ALIGN_WITH_INPUT {
344                bsp_section_fast_data_begin = .;
345                *(.bsp_fast_data)
346                bsp_section_fast_data_end = .;
347        } > REGION_FAST_DATA AT > REGION_FAST_DATA_LOAD
348        bsp_section_fast_data_size = bsp_section_fast_data_end - bsp_section_fast_data_begin;
349        bsp_section_fast_data_load_begin = LOADADDR (.fast_data);
350        bsp_section_fast_data_load_end = bsp_section_fast_data_load_begin + bsp_section_fast_data_size;
351
352        .data : ALIGN_WITH_INPUT {
353                bsp_section_data_begin = .;
354                *(.data .data.* .gnu.linkonce.d.*)
355                SORT(CONSTRUCTORS)
356        } > REGION_DATA AT > REGION_DATA_LOAD
357        .data1 : ALIGN_WITH_INPUT {
358                *(.data1)
359        } > REGION_DATA AT > REGION_DATA_LOAD
360        .rtemsrwset : ALIGN_WITH_INPUT {
361                KEEP (*(SORT(.rtemsrwset.*)))
362                bsp_section_data_end = .;
363        } > REGION_DATA AT > REGION_DATA_LOAD
364        bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
365        bsp_section_data_load_begin = LOADADDR (.data);
366        bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
367
368        .bss : ALIGN_WITH_INPUT {
369                bsp_section_bss_begin = .;
370                *(.dynbss)
371                *(.bss .bss.* .gnu.linkonce.b.*)
372                *(COMMON)
373                bsp_section_bss_end = .;
374        } > REGION_BSS AT > REGION_BSS
375        bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
376
377        .work : ALIGN_WITH_INPUT {
378                /*
379                 * The work section will occupy the remaining REGION_WORK region and
380                 * contains the RTEMS work space and heap.
381                 */
382                bsp_section_work_begin = .;
383                . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
384                bsp_section_work_end = .;
385        } > REGION_WORK AT > REGION_WORK
386        bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
387
388        .stack : ALIGN_WITH_INPUT {
389                /*
390                 * The stack section will occupy the remaining REGION_STACK region and may
391                 * contain the task stacks.  Depending on the region distribution this
392                 * section may be of zero size.
393                 */
394                bsp_section_stack_begin = .;
395                . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);
396                bsp_section_stack_end = .;
397        } > REGION_STACK AT > REGION_STACK
398        bsp_section_stack_size = bsp_section_stack_end - bsp_section_stack_begin;
399
400        /* FIXME */
401        RamBase = ORIGIN (REGION_WORK);
402        RamSize = LENGTH (REGION_WORK);
403        WorkAreaBase = bsp_section_work_begin;
404        HeapSize = 0;
405
406        /* Stabs debugging sections.  */
407        .stab          0 : { *(.stab) }
408        .stabstr       0 : { *(.stabstr) }
409        .stab.excl     0 : { *(.stab.excl) }
410        .stab.exclstr  0 : { *(.stab.exclstr) }
411        .stab.index    0 : { *(.stab.index) }
412        .stab.indexstr 0 : { *(.stab.indexstr) }
413        .comment       0 : { *(.comment) }
414        /* DWARF debug sections.
415           Symbols in the DWARF debugging sections are relative to the beginning
416           of the section so we begin them at 0.  */
417        /* DWARF 1 */
418        .debug          0 : { *(.debug) }
419        .line           0 : { *(.line) }
420        /* GNU DWARF 1 extensions */
421        .debug_srcinfo  0 : { *(.debug_srcinfo) }
422        .debug_sfnames  0 : { *(.debug_sfnames) }
423        /* DWARF 1.1 and DWARF 2 */
424        .debug_aranges  0 : { *(.debug_aranges) }
425        .debug_pubnames 0 : { *(.debug_pubnames) }
426        /* DWARF 2 */
427        .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
428        .debug_abbrev   0 : { *(.debug_abbrev) }
429        .debug_line     0 : { *(.debug_line) }
430        .debug_frame    0 : { *(.debug_frame) }
431        .debug_str      0 : { *(.debug_str) }
432        .debug_loc      0 : { *(.debug_loc) }
433        .debug_macinfo  0 : { *(.debug_macinfo) }
434        /* SGI/MIPS DWARF 2 extensions */
435        .debug_weaknames 0 : { *(.debug_weaknames) }
436        .debug_funcnames 0 : { *(.debug_funcnames) }
437        .debug_typenames 0 : { *(.debug_typenames) }
438        .debug_varnames  0 : { *(.debug_varnames) }
439        /* DWARF 3 */
440        .debug_pubtypes 0 : { *(.debug_pubtypes) }
441        .debug_ranges   0 : { *(.debug_ranges) }
442        /* DWARF extension */
443        .debug_macro    0 : { *(.debug_macro) }
444        .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
445        .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
446        /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
447
448        /*
449         * This is a RTEMS specific section to catch all unexpected input
450         * sections.  In case you get an error like
451         *   "section `.unexpected_sections' will not fit in region
452         *   `UNEXPECTED_SECTIONS'"
453         * you have to figure out the offending input section and add it to the
454         * appropriate output section definition above.
455         */
456        .unexpected_sections : { *(*) } > UNEXPECTED_SECTIONS
457}
Note: See TracBrowser for help on using the repository browser.