source: rtems/c/src/lib/libbsp/powerpc/shared/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: 9.7 KB
Line 
1OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
2              "elf32-powerpc")
3OUTPUT_ARCH(powerpc)
4ENTRY(_start)
5/* Do we need any of these for elf?
6   __DYNAMIC = 0;    */
7PROVIDE (__stack = 0);
8MEMORY {
9        VECTORS : ORIGIN = 0x0 ,  LENGTH = 0x3000
10        CODE : ORIGIN = 0x3000 , LENGTH = 32M - 0x3000
11}
12SECTIONS
13{
14  .entry_point_section :
15  {
16        *(.entry_point_section)
17  } > VECTORS
18
19  /*
20   * This section is used only if NO_DYNAMIC_EXCEPTION_VECTOR_INSTALL
21   * is defined in vectors/vectors.S
22   */
23  .vectors :
24  {
25    *(.vectors)
26  } > VECTORS
27
28  /* Read-only sections, merged into text segment: */
29  .interp   : { *(.interp) }    > CODE
30  .hash           : { *(.hash)          }       > CODE
31  .dynsym         : { *(.dynsym)                }       > CODE
32  .dynstr         : { *(.dynstr)                }       > CODE
33  .gnu.version   : { *(.gnu.version)      }     > CODE
34  .gnu.version_d   : { *(.gnu.version_d)  }     > CODE
35  .gnu.version_r   : { *(.gnu.version_r)  }     > CODE
36  .rela.text     :
37    { *(.rela.text) *(.rela.gnu.linkonce.t*) }  > CODE
38  .rela.data     :
39    { *(.rela.data) *(.rela.gnu.linkonce.d*) }  > CODE
40  .rela.rodata   :
41    { *(.rela.rodata*) *(.rela.gnu.linkonce.r*) }       > CODE
42  .rela.got       : { *(.rela.got)      }       > CODE
43  .rela.got1      : { *(.rela.got1)     }       > CODE
44  .rela.got2      : { *(.rela.got2)     }       > CODE
45  .rela.ctors     : { *(.rela.ctors)    }       > CODE
46  .rela.dtors     : { *(.rela.dtors)    }       > CODE
47  .rela.init      : { *(.rela.init)     }       > CODE
48  .rela.fini      : { *(.rela.fini)     }       > CODE
49  .rela.bss       : { *(.rela.bss)      }       > CODE
50  .rela.plt       : { *(.rela.plt)      }       > CODE
51  .rela.sdata     : { *(.rela.sdata)    }       > CODE
52  .rela.sbss      : { *(.rela.sbss)     }       > CODE
53  .rela.sdata2    : { *(.rela.sdata2)   }       > CODE
54  .rela.sbss2     : { *(.rela.sbss2)    }       > CODE
55  .rela.dyn       : { *(.rela.dyn)      }       > CODE
56
57  .init           : { KEEP(*(.init))            } > CODE
58
59  .text      : 
60  {
61    *(.text*)   
62
63    /*
64     * Special FreeBSD sysctl sections.
65     */
66    . = ALIGN (16);
67    __start_set_sysctl_set = .;
68    *(set_sysctl_*);
69    __stop_set_sysctl_set = ABSOLUTE(.);
70    *(set_domain_*);
71    *(set_pseudo_*);
72
73    /* .gnu.warning sections are handled specially by elf32.em.  */
74    *(.gnu.warning)
75    *(.gnu.linkonce.t*)
76  }  > CODE
77
78  .fini           : { _fini = .; KEEP(*(.fini)) } > CODE
79
80  .rodata         : { *(.rodata*) *(.gnu.linkonce.r*) } > CODE
81  .rodata1        : { *(.rodata1) }     > CODE
82
83  .tdata : {
84    _TLS_Data_begin = .;
85    *(.tdata .tdata.* .gnu.linkonce.td.*)
86    _TLS_Data_end = .;
87  } >CODE
88
89  .tbss : {
90    _TLS_BSS_begin = .;
91    *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
92    _TLS_BSS_end = .;
93  } >CODE
94
95  _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
96  _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
97  _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
98  _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
99  _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
100  _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
101
102  /* Adjust the address for the data segment.  We want to adjust up to
103     the same address within the page on the next page up.  */
104  . = ALIGN(0x10000) + (. & (0x10000 - 1));
105  /* Ensure the __preinit_array_start label is properly aligned.  We
106     could instead move the label definition inside the section, but
107     the linker would then create the section even if it turns out to
108     be empty, which isn't pretty.  */
109  . = ALIGN(32 / 8);
110  PROVIDE (__preinit_array_start = .);
111  .preinit_array     : { *(.preinit_array) } >CODE
112  PROVIDE (__preinit_array_end = .);
113  PROVIDE (__init_array_start = .);
114  .init_array     : { *(.init_array) } >CODE
115  PROVIDE (__init_array_end = .);
116  PROVIDE (__fini_array_start = .);
117  .fini_array     : { *(.fini_array) } >CODE
118  PROVIDE (__fini_array_end = .);
119
120  .sdata2         : {PROVIDE (_SDA2_BASE_ = 32768); *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) } >CODE
121  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
122                        /* avoid empty sdata2/sbss2 area -- __eabi would not set up r2
123                         * which may be important if run-time loading is used
124                         */
125                     . += 1;
126                     PROVIDE (__SBSS2_END__ = .);
127                    } >CODE
128  .eh_frame       : { *(.eh_frame)              } >CODE
129
130  /* NOTE: if the BSP uses page tables, the correctness of
131   *       '_etext' (and __DATA_START__) is CRUCIAL - otherwise,
132   *       an invalid mapping may result!!!
133   */
134  _etext = .;
135  PROVIDE (etext = .);
136
137  /* Adjust the address for the data segment.  We want to adjust up to
138     the same address within the page on the next page up.  It would
139     be more correct to do this:
140       . = ALIGN(0x40000) + (ALIGN(8) & (0x40000 - 1));
141     The current expression does not correctly handle the case of a
142     text segment ending precisely at the end of a page; it causes the
143     data segment to skip a page.  The above expression does not have
144     this problem, but it will currently (2/95) cause BFD to allocate
145     a single segment, combining both text and data, for this case.
146     This will prevent the text segment from being shared among
147     multiple executions of the program; I think that is more
148     important than losing a page of the virtual address space (note
149     that no actual memory is lost; the page which is skipped can not
150     be referenced).  */
151  . = ALIGN(0x1000);
152 .data ALIGN(0x1000) :
153  {
154   /* NOTE: if the BSP uses page tables, the correctness of
155    *       '__DATA_START__' (and _etext) is CRUCIAL - otherwise,
156    *       an invalid mapping may result!!!
157    */
158        PROVIDE(__DATA_START__ = ABSOLUTE(.) );
159    *(.data .data.* .gnu.linkonce.d*)   
160    SORT(CONSTRUCTORS)
161  } > CODE
162  .data1   : { *(.data1) }      > CODE
163  PROVIDE (__EXCEPT_START__ = .);
164  .gcc_except_table   : { *(.gcc_except_table*) } > CODE
165  PROVIDE (__EXCEPT_END__ = .);
166  .got1           : { *(.got1) }        > CODE
167  /* Put .ctors and .dtors next to the .got2 section, so that the pointers
168     get relocated with -mrelocatable. Also put in the .fixup pointers.
169     The current compiler no longer needs this, but keep it around for 2.7.2  */
170                PROVIDE (_GOT2_START_ = .);
171  .got2           :  { *(.got2) }       > CODE
172  .dynamic        : { *(.dynamic) }     > CODE
173
174  .ctors          :
175  {
176    /* gcc uses crtbegin.o to find the start of
177       the constructors, so we make sure it is
178       first.  Because this is a wildcard, it
179       doesn't matter if the user does not
180       actually link against crtbegin.o; the
181       linker won't look for a file to match a
182       wildcard.  The wildcard also means that it
183       doesn't matter which directory crtbegin.o
184       is in.  */
185    KEEP (*crtbegin.o(.ctors))
186    /* We don't want to include the .ctor section from
187       from the crtend.o file until after the sorted ctors.
188       The .ctor section from the crtend file contains the
189       end of ctors marker and it must be last */
190    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
191    KEEP (*(SORT(.ctors.*)))
192    KEEP (*(.ctors))
193  } > CODE
194  .dtors          :
195  {
196    KEEP (*crtbegin.o(.dtors))
197    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
198    KEEP (*(SORT(.dtors.*)))
199    KEEP (*(.dtors))
200  } > CODE
201
202
203                PROVIDE (_FIXUP_START_ = .);
204  .fixup          : { *(.fixup) }       > CODE
205                PROVIDE (_FIXUP_END_ = .);
206                PROVIDE (_GOT2_END_ = .);
207                PROVIDE (_GOT_START_ = .);
208
209  .got            : { *(.got) } > CODE
210  .got.plt        : { *(.got.plt) }     > CODE
211
212                PROVIDE (_GOT_END_ = .);
213
214  .jcr            : { KEEP (*(.jcr)) } > CODE
215
216  /* We want the small data sections together, so single-instruction offsets
217     can access them all, and initialized data all before uninitialized, so
218     we can shorten the on-disk segment size.  */
219  .sdata          : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata*) *(.gnu.linkonce.s.*)     } >CODE
220  _edata  =  .;
221  PROVIDE (edata = .);
222  .sbss      :
223  {
224    PROVIDE (__sbss_start = .);
225    *(.dynsbss)
226    *(.sbss* .gnu.linkonce.sb.*)
227    *(.scommon)
228    /* avoid empty sdata/sbss area -- __eabi would not set up r13
229     * which may be important if run-time loading is used
230     */
231    . += 1;
232    PROVIDE (__SBSS_END__ = .);
233    PROVIDE (__sbss_end = .);
234  } > CODE
235  .plt   : { *(.plt) }  > CODE
236  .bss       :
237  {
238   PROVIDE (__bss_start = .);
239   *(.dynbss)
240   *(.bss .bss* .gnu.linkonce.b*)
241   *(COMMON)
242  . = ALIGN(16);
243   PROVIDE (__bss_end = .);
244  } > CODE
245  . = ALIGN(16);
246  . += 0x1000;
247  __stack = .;
248  _end = . ;
249  __rtems_end = . ;
250  PROVIDE (end = .);
251  /DISCARD/ :
252  {
253    *(.comment)
254  }
255
256
257  /* Stabs debugging sections.  */
258  .stab 0 : { *(.stab) }
259  .stabstr 0 : { *(.stabstr) }
260  .stab.excl 0 : { *(.stab.excl) }
261  .stab.exclstr 0 : { *(.stab.exclstr) }
262  .stab.index 0 : { *(.stab.index) }
263  .stab.indexstr 0 : { *(.stab.indexstr) }
264  .comment 0 : { *(.comment) }
265
266  /* DWARF debug sections.
267     Symbols in the DWARF debugging sections are relative to the beginning
268     of the section so we begin them at 0.  */
269  /* DWARF 1 */
270  .debug          0 : { *(.debug) }
271  .line           0 : { *(.line) }
272 
273  /* GNU DWARF 1 extensions */
274  .debug_srcinfo  0 : { *(.debug_srcinfo) }
275  .debug_sfnames  0 : { *(.debug_sfnames) }
276 
277  /* DWARF 1.1 and DWARF 2 */
278  .debug_aranges  0 : { *(.debug_aranges) }
279  .debug_pubnames 0 : { *(.debug_pubnames) }
280 
281  /* DWARF 2 */
282  .debug_info     0 : { *(.debug_info) }
283  .debug_abbrev   0 : { *(.debug_abbrev) }
284  .debug_line     0 : { *(.debug_line) }
285  .debug_frame    0 : { *(.debug_frame) }
286  .debug_str      0 : { *(.debug_str) }
287  .debug_loc      0 : { *(.debug_loc) }
288  .debug_macinfo  0 : { *(.debug_macinfo) }
289 
290  /* SGI/MIPS DWARF 2 extensions */
291  .debug_weaknames 0 : { *(.debug_weaknames) }
292  .debug_funcnames 0 : { *(.debug_funcnames) }
293  .debug_typenames 0 : { *(.debug_typenames) }
294  .debug_varnames  0 : { *(.debug_varnames) }
295  /* These must appear regardless of  .  */
296}
Note: See TracBrowser for help on using the repository browser.