source: rtems/c/src/lib/libbsp/i386/pc386/startup/linkcmds @ 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: 8.9 KB
Line 
1/*
2 *  Copy of default "default linker script, for normal executables"
3 *  provided with binutils 2.18 with minor modifications for use
4 *  as pc386 linkcmds.  These changes include:
5 *
6 *    + sections commented out marked with "XXX commented out --joel"
7 *    + addition of m_hdr section
8 *    + addition of FreeBSD sysctl sections
9 */
10
11/*
12 * XXX commented out --joel
13OUTPUT_FORMAT("elf32-i386", "elf32-i386",
14              "elf32-i386")
15OUTPUT_ARCH(i386)
16ENTRY(_start)
17*/
18HeapSize = DEFINED(HeapSize) ? HeapSize :
19          DEFINED(_HeapSize) ? _HeapSize : 0x0;
20RamSize = DEFINED(RamSize) ? RamSize    :
21          DEFINED(_RamSize) ? _RamSize : 0xFFFFFFFF;
22
23SECTIONS
24{
25  /* Read-only sections, merged into text segment: */
26/*
27 * XXX commented out --joel
28  PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
29*/
30  .interp         : { *(.interp) }
31  .note.gnu.build-id : { *(.note.gnu.build-id) }
32  .hash           : { *(.hash) }
33  .gnu.hash       : { *(.gnu.hash) }
34  .dynsym         : { *(.dynsym) }
35  .dynstr         : { *(.dynstr) }
36  .gnu.version    : { *(.gnu.version) }
37  .gnu.version_d  : { *(.gnu.version_d) }
38  .gnu.version_r  : { *(.gnu.version_r) }
39  .rel.init       : { *(.rel.init) }
40  .rela.init      : { *(.rela.init) }
41  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
42  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
43  .rel.fini       : { *(.rel.fini) }
44  .rela.fini      : { *(.rela.fini) }
45  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
46  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
47  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
48  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
49  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
50  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
51  .rel.tdata      : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
52  .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
53  .rel.tbss       : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
54  .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
55  .rel.ctors      : { *(.rel.ctors) }
56  .rela.ctors     : { *(.rela.ctors) }
57  .rel.dtors      : { *(.rel.dtors) }
58  .rela.dtors     : { *(.rela.dtors) }
59  .rel.got        : { *(.rel.got) }
60  .rela.got       : { *(.rela.got) }
61  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
62  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
63  .rel.plt        : { *(.rel.plt) }
64  .rela.plt       : { *(.rela.plt) }
65  .plt            : { *(.plt) }
66  .text           :
67  {
68   *(.m_hdr)
69    *(.text .stub .text.* .gnu.linkonce.t.*)
70    KEEP (*(.text.*personality*))
71    /* .gnu.warning sections are handled specially by elf32.em.  */
72    *(.gnu.warning)
73
74  } =0x90909090
75
76  .rtemsroset : {
77    /* for pre rtems-libbsd FreeBSD code */
78    __start_set_sysctl_set = .;
79    *(set_sysctl_*);
80    __stop_set_sysctl_set = .;
81    *(set_domain_*);
82    *(set_pseudo_*);
83
84    KEEP (*(SORT(.rtemsroset.*)))
85  } =0x90909090
86
87  .init           :
88  {
89    KEEP (*(.init))
90  } =0x90909090
91  .fini           :
92  {
93    KEEP (*(.fini))
94  } =0x90909090
95  PROVIDE (__etext = .);
96  PROVIDE (_etext = .);
97  PROVIDE (etext = .);
98  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
99  .rodata1        : { *(.rodata1) }
100  .tdata : {
101    _TLS_Data_begin = .;
102    *(.tdata .tdata.* .gnu.linkonce.td.*)
103    _TLS_Data_end = .;
104  }
105  .tbss : {
106    _TLS_BSS_begin = .;
107    *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
108    _TLS_BSS_end = .;
109  }
110  _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
111  _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
112  _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
113  _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
114  _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
115  _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
116  .eh_frame_hdr : { *(.eh_frame_hdr) }
117  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
118  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
119  /* Adjust the address for the data segment.  We want to adjust up to
120     the same address within the page on the next page up.  */
121  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
122  /* Exception handling  */
123  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
124  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
125  /* Thread Local Storage sections  */
126  .tdata          : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
127  .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
128  .preinit_array     :
129  {
130    PROVIDE_HIDDEN (__preinit_array_start = .);
131    KEEP (*(.preinit_array))
132    PROVIDE_HIDDEN (__preinit_array_end = .);
133  }
134  .init_array     :
135  {
136     PROVIDE_HIDDEN (__init_array_start = .);
137     KEEP (*(SORT(.init_array.*)))
138     KEEP (*(.init_array))
139     PROVIDE_HIDDEN (__init_array_end = .);
140  }
141  .fini_array     :
142  {
143    PROVIDE_HIDDEN (__fini_array_start = .);
144    KEEP (*(.fini_array))
145    KEEP (*(SORT(.fini_array.*)))
146    PROVIDE_HIDDEN (__fini_array_end = .);
147  }
148  .ctors          :
149  {
150    /* gcc uses crtbegin.o to find the start of
151       the constructors, so we make sure it is
152       first.  Because this is a wildcard, it
153       doesn't matter if the user does not
154       actually link against crtbegin.o; the
155       linker won't look for a file to match a
156       wildcard.  The wildcard also means that it
157       doesn't matter which directory crtbegin.o
158       is in.  */
159    KEEP (*crtbegin.o(.ctors))
160    KEEP (*crtbegin?.o(.ctors))
161    /* We don't want to include the .ctor section from
162       the crtend.o file until after the sorted ctors.
163       The .ctor section from the crtend file contains the
164       end of ctors marker and it must be last */
165    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
166    KEEP (*(SORT(.ctors.*)))
167    KEEP (*(.ctors))
168  }
169  .dtors          :
170  {
171    KEEP (*crtbegin.o(.dtors))
172    KEEP (*crtbegin?.o(.dtors))
173    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
174    KEEP (*(SORT(.dtors.*)))
175    KEEP (*(.dtors))
176  }
177  .jcr            : { KEEP (*(.jcr)) }
178  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
179  .dynamic        : { *(.dynamic) }
180  .got            : { *(.got) }
181  . = DATA_SEGMENT_RELRO_END (12, .);
182  .got.plt        : { *(.got.plt) }
183  .data           :
184  {
185    *(.data .data.* .gnu.linkonce.d.*)
186    KEEP (*(.gnu.linkonce.d.*personality*))
187    SORT(CONSTRUCTORS)
188  }
189  .data1          : { *(.data1) }
190  .rtemsrwset     : { KEEP (*(SORT(.rtemsrwset.*))) }
191  _edata = .; PROVIDE (edata = .);
192  __bss_start = .;
193  .bss            :
194  {
195   *(.dynbss)
196   *(.bss .bss.* .gnu.linkonce.b.*)
197   *(COMMON)
198   /* Align here to ensure that the .bss section occupies space up to
199      _end.  Align after .bss to ensure correct alignment even if the
200      .bss section disappears because there are no input sections.
201      FIXME: Why do we need it? When there is no .bss section, we don't
202      pad the .data section.  */
203   . = ALIGN(. != 0 ? 32 / 8 : 1);
204  }
205  . = ALIGN(32 / 8);
206  . = ALIGN(32 / 8);
207  _end = .; PROVIDE (end = .);
208  . = ALIGN(0x10);
209  WorkAreaBase = .;
210  . = DATA_SEGMENT_END (.);
211
212  /* Stabs debugging sections.  */
213  .stab          0 : { *(.stab) }
214  .stabstr       0 : { *(.stabstr) }
215  .stab.excl     0 : { *(.stab.excl) }
216  .stab.exclstr  0 : { *(.stab.exclstr) }
217  .stab.index    0 : { *(.stab.index) }
218  .stab.indexstr 0 : { *(.stab.indexstr) }
219  .comment       0 : { *(.comment) }
220  /* DWARF debug sections.
221     Symbols in the DWARF debugging sections are relative to the beginning
222     of the section so we begin them at 0.  */
223  /* DWARF 1 */
224  .debug          0 : { *(.debug) }
225  .line           0 : { *(.line) }
226  /* GNU DWARF 1 extensions */
227  .debug_srcinfo  0 : { *(.debug_srcinfo) }
228  .debug_sfnames  0 : { *(.debug_sfnames) }
229  /* DWARF 1.1 and DWARF 2 */
230  .debug_aranges  0 : { *(.debug_aranges) }
231  .debug_pubnames 0 : { *(.debug_pubnames) }
232  /* DWARF 2 */
233  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
234  .debug_abbrev   0 : { *(.debug_abbrev) }
235  .debug_line     0 : { *(.debug_line) }
236  .debug_frame    0 : { *(.debug_frame) }
237  .debug_str      0 : { *(.debug_str) }
238  .debug_loc      0 : { *(.debug_loc) }
239  .debug_macinfo  0 : { *(.debug_macinfo) }
240  /* SGI/MIPS DWARF 2 extensions */
241  .debug_weaknames 0 : { *(.debug_weaknames) }
242  .debug_funcnames 0 : { *(.debug_funcnames) }
243  .debug_typenames 0 : { *(.debug_typenames) }
244  .debug_varnames  0 : { *(.debug_varnames) }
245  /* DWARF 3 */
246  .debug_pubtypes 0 : { *(.debug_pubtypes) }
247  .debug_ranges   0 : { *(.debug_ranges) }
248  /* DWARF extension */
249  .debug_macro    0 : { *(.debug_macro) }
250  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
251  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
252}
Note: See TracBrowser for help on using the repository browser.