source: rtems/c/src/lib/libbsp/sh/gensh4/startup/linkcmds.rom @ 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: 6.7 KB
Line 
1/*
2 * This file contains GNU linker directives for an general SH4
3 * board.
4 *
5 * Variations in memory size and allocation can be made by
6 * overriding some values with linker command-line arguments.
7 *
8 * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
9 * Author: Victor V. Vengerov <vvv@oktet.ru>
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 *
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17
18OUTPUT_FORMAT("elf32-shl", "elf32-shl",
19              "elf32-shl")
20OUTPUT_ARCH(sh)
21ENTRY(_start)
22/* Do we need any of these for elf?
23   __DYNAMIC = 0;    */
24
25_RamBase = DEFINED(_RamBase) ? _RamBase : 0x88000000;
26_RamSize = DEFINED(_RamSize) ? _RamSize : 8M;
27_HeapSize = DEFINED(_HeapSize) ? _HeapSize : (2 * 1024 * 1024);
28
29/*
30 * Area assignments:
31 *     Area 0: Flash memory, SRAM interface
32 *     Area 1: GDC
33 *     Area 2: SDRAM
34 *     Area 3-6: unused
35 */
36MEMORY
37{
38/*
39 * Real values
40 */
41  ram           : o = 0x88000000, l = 8M
42  rom           : o = 0x80000000, l = 4M
43/*
44 * Fake values to test from gdb
45 */
46/*
47  ram           : o = 0x88100000, l = 4M
48  rom           : o = 0x88500000, l = 3M
49*/
50}
51
52SECTIONS
53{
54  /* Read-only sections, merged into text segment: */
55  .init          :
56  {
57    KEEP (*(.init))
58  } =0
59  .text      :
60  {
61    *(.text*)
62
63    /*
64     * Special FreeBSD sysctl sections.
65     */
66    . = ALIGN (16);
67    ___start_set_sysctl_set = .;
68    *(set_sysc*);   /* set_sysctl_* but name is truncated by SH-coff */
69    ___stop_set_sysctl_set = ABSOLUTE(.);
70    *(set_doma*);   /* set_domain_* but name is truncated by SH-coff */
71    *(set_pseudo_*);
72
73    /* .gnu.warning sections are handled specially by elf32.em.  */
74    *(.gnu.warning)
75    *(.gnu.linkonce.t*)
76  } > rom
77  _etext = .;
78  PROVIDE (etext = .);
79  .rela.dyn       :
80    {
81      *(.rela.init)
82      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
83      *(.rela.fini)
84      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
85      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
86      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
87      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
88      *(.rela.ctors)
89      *(.rela.dtors)
90      *(.rela.got)
91      *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
92      *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
93      *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
94      *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
95      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
96    } >ram
97  .fini      :
98  {
99    KEEP (*(.fini))
100  } =0
101  .rodata   :
102  {
103    *(.rodata)
104    *(.rodata.*)
105    *(.gnu.linkonce.r*)
106    . = ALIGN(32);
107  } > rom
108  .tdata : {
109    __TLS_Data_begin = .;
110    *(.tdata .tdata.* .gnu.linkonce.td.*)
111    __TLS_Data_end = .;
112  } > rom
113  .tbss : {
114    __TLS_BSS_begin = .;
115    *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
116    __TLS_BSS_end = .;
117  } > rom
118  __TLS_Data_size = __TLS_Data_end - __TLS_Data_begin;
119  __TLS_Data_begin = __TLS_Data_size != 0 ? __TLS_Data_begin : __TLS_BSS_begin;
120  __TLS_Data_end = __TLS_Data_size != 0 ? __TLS_Data_end : __TLS_BSS_begin;
121  __TLS_BSS_size = __TLS_BSS_end - __TLS_BSS_begin;
122  __TLS_Size = __TLS_BSS_end - __TLS_Data_begin;
123  __TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
124  .ctors   :
125  {
126    ___ctors = .;
127    /* gcc uses crtbegin.o to find the start of
128       the constructors, so we make sure it is
129       first.  Because this is a wildcard, it
130       doesn't matter if the user does not
131       actually link against crtbegin.o; the
132       linker won't look for a file to match a
133       wildcard.  The wildcard also means that it
134       doesn't matter which directory crtbegin.o
135       is in.  */
136    KEEP (*crtbegin.o(.ctors))
137    /* We don't want to include the .ctor section from
138       from the crtend.o file until after the sorted ctors.
139       The .ctor section from the crtend file contains the
140       end of ctors marker and it must be last */
141    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
142    KEEP (*(SORT(.ctors.*)))
143    KEEP (*(.ctors))
144    ___ctors_end = .;
145  } > rom
146   .dtors         :
147  {
148    ___dtors = .;
149    KEEP (*crtbegin.o(.dtors))
150    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
151    KEEP (*(SORT(.dtors.*)))
152    KEEP (*(.dtors))
153    ___dtors_end = .;
154    copy_start_in_rom = .;
155  } > rom
156
157  /* Adjust the address for the data segment.  We want to adjust up to
158     the same address within the page on the next page up.  */
159  . = ALIGN(128) + (. & (128 - 1));
160  .data     : AT(LOADADDR(.dtors) + SIZEOF(.dtors))
161  {
162    copy_start = .;
163    *(.data)
164    *(.data.*)
165    *(.gnu.linkonce.d*)
166    SORT(CONSTRUCTORS)
167    copy_end = .;
168  } > ram
169  .eh_frame : { *(.eh_frame) } > ram
170  /* We want the small data sections together, so single-instruction offsets
171     can access them all, and initialized data all before uninitialized, so
172     we can shorten the on-disk segment size.  */
173  .bss       :
174  {
175   __bss_start = .;
176   *(.dynbss)
177   *(.bss .bss* .gnu.linkonce.b*)
178   *(COMMON)
179   /* Align here to ensure that the .bss section occupies space up to
180      _end.  Align after .bss to ensure correct alignment even if the
181      .bss section disappears because there are no input sections.  */
182   . = ALIGN(32 / 8);
183   __bss_end = .;
184  } > ram
185
186  . = ALIGN(16);
187  _WorkAreaBase = . ;
188
189  . = ALIGN(16);
190  .stack . : {
191     stack_start = .;
192     . = . + 4096;
193     stack_end = .;
194  }
195
196  . = ALIGN(16);
197  _CPU_Interrupt_stack_low  = . ;
198  _CPU_Interrupt_stack_high = _CPU_Interrupt_stack_low + 4096 ;
199
200  /* Stabs debugging sections.  */
201  .stab 0 : { *(.stab) }
202  .stabstr 0 : { *(.stabstr) }
203  .stab.excl 0 : { *(.stab.excl) }
204  .stab.exclstr 0 : { *(.stab.exclstr) }
205  .stab.index 0 : { *(.stab.index) }
206  .stab.indexstr 0 : { *(.stab.indexstr) }
207  .comment 0 : { *(.comment) }
208  /* DWARF debug sections.
209     Symbols in the DWARF debugging sections are relative to the beginning
210     of the section so we begin them at 0.  */
211  /* DWARF 1 */
212  .debug          0 : { *(.debug) }
213  .line           0 : { *(.line) }
214  /* GNU DWARF 1 extensions */
215  .debug_srcinfo  0 : { *(.debug_srcinfo) }
216  .debug_sfnames  0 : { *(.debug_sfnames) }
217  /* DWARF 1.1 and DWARF 2 */
218  .debug_aranges  0 : { *(.debug_aranges) }
219  .debug_pubnames 0 : { *(.debug_pubnames) }
220  /* DWARF 2 */
221  .debug_info     0 : { *(.debug_info) }
222  .debug_abbrev   0 : { *(.debug_abbrev) }
223  .debug_line     0 : { *(.debug_line) }
224  .debug_frame    0 : { *(.debug_frame) }
225  .debug_str      0 : { *(.debug_str) }
226  .debug_loc      0 : { *(.debug_loc) }
227  .debug_macinfo  0 : { *(.debug_macinfo) }
228  /* SGI/MIPS DWARF 2 extensions */
229  .debug_weaknames 0 : { *(.debug_weaknames) }
230  .debug_funcnames 0 : { *(.debug_funcnames) }
231  .debug_typenames 0 : { *(.debug_typenames) }
232  .debug_varnames  0 : { *(.debug_varnames) }
233  .stack : { _stack = .; *(.stack) }
234  /* These must appear regardless of  .  */
235}
Note: See TracBrowser for help on using the repository browser.