1/* Script for --shared -z combreloc: shared library, combine & sort relocs */
2/* Copyright (C) 2014 Free Software Foundation, Inc.
3   Copying and distribution of this script, with or without modification,
4   are permitted in any medium without royalty provided the copyright
5   notice and this notice are preserved.  */
6
7/* source:
8 *  /opt/CodeSourcery/Sourcery_G++_Lite/mips-sde-elf/lib/ldscripts/elf32ltsmip.xsc
9 */
10#ifdef __mips64
11OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips",
12              "elf64-tradlittlemips")
13#else
14OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips",
15              "elf32-tradlittlemips")
16#endif
17OUTPUT_ARCH(mips)
18ENTRY(__start)
19SECTIONS
20{
21  /* Read-only sections, merged into text segment: */
22  . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS;
23  .MIPS.abiflags   : { *(.MIPS.abiflags) }
24  .MIPS.options : { *(.MIPS.options) }
25  .reginfo         : { *(.reginfo) }
26  .note.gnu.build-id : { *(.note.gnu.build-id) }
27  .dynamic        : { *(.dynamic) }
28  .hash           : { *(.hash) }
29  .gnu.hash       : { *(.gnu.hash) }
30  .dynsym         : { *(.dynsym) }
31  .dynstr         : { *(.dynstr) }
32  .gnu.version    : { *(.gnu.version) }
33  .gnu.version_d  : { *(.gnu.version_d) }
34  .gnu.version_r  : { *(.gnu.version_r) }
35  .rel.init       : { *(.rel.init) }
36  .rela.init      : { *(.rela.init) }
37  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
38  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
39  .rel.fini       : { *(.rel.fini) }
40  .rela.fini      : { *(.rela.fini) }
41  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
42  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
43  .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
44  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
45  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
46  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
47  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
48  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
49  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
50  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
51  .rel.ctors      : { *(.rel.ctors) }
52  .rela.ctors     : { *(.rela.ctors) }
53  .rel.dtors      : { *(.rel.dtors) }
54  .rela.dtors     : { *(.rela.dtors) }
55  .rel.got        : { *(.rel.got) }
56  .rela.got       : { *(.rela.got) }
57  .rel.dyn        : { *(.rel.dyn) }
58  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
59  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
60  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
61  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
62  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
63  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
64  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
65  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
66  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
67  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
68  .rel.iplt       :
69    {
70      *(.rel.iplt)
71    }
72  .rela.iplt      :
73    {
74      *(.rela.iplt)
75    }
76  .rel.plt        :
77    {
78      *(.rel.plt)
79    }
80  .rela.plt       :
81    {
82      *(.rela.plt)
83    }
84  .init           :
85  {
86    KEEP (*(SORT_NONE(.init)))
87  }
88  .plt            : { *(.plt) }
89  .iplt           : { *(.iplt) }
90  .text           :
91  {
92    _ftext = . ;
93    *(.text.unlikely .text.*_unlikely .text.unlikely.*)
94    *(.text.exit .text.exit.*)
95    *(.text.startup .text.startup.*)
96    *(.text.hot .text.hot.*)
97    *(.text .stub .text.* .gnu.linkonce.t.*)
98    /* .gnu.warning sections are handled specially by elf32.em.  */
99    *(.gnu.warning)
100    *(.mips16.fn.*) *(.mips16.call.*)
101  }
102  .fini           :
103  {
104    KEEP (*(SORT_NONE(.fini)))
105  }
106  PROVIDE (__etext = .);
107  PROVIDE (_etext = .);
108  PROVIDE (etext = .);
109  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
110  .rodata1        : { *(.rodata1) }
111  .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
112  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
113  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
114  .gcc_except_table.*) }
115  .gnu_extab   : ONLY_IF_RO { *(.gnu_extab*) }
116  /* These sections are generated by the Sun/Oracle C++ compiler.  */
117  .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
118  .exception_ranges*) }
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  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
122  /* Exception handling  */
123  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
124  .gnu_extab      : ONLY_IF_RW { *(.gnu_extab) }
125  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
126  .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
127  /* Thread Local Storage sections  */
128  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
129  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
130  .preinit_array     :
131  {
132    KEEP (*(.preinit_array))
133  }
134  .init_array     :
135  {
136    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
137    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
138  }
139  .fini_array     :
140  {
141    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
142    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
143  }
144  .ctors          :
145  {
146    /* gcc uses crtbegin.o to find the start of
147       the constructors, so we make sure it is
148       first.  Because this is a wildcard, it
149       doesn't matter if the user does not
150       actually link against crtbegin.o; the
151       linker won't look for a file to match a
152       wildcard.  The wildcard also means that it
153       doesn't matter which directory crtbegin.o
154       is in.  */
155    KEEP (*crtbegin.o(.ctors))
156    KEEP (*crtbegin?.o(.ctors))
157    /* We don't want to include the .ctor section from
158       the crtend.o file until after the sorted ctors.
159       The .ctor section from the crtend file contains the
160       end of ctors marker and it must be last */
161    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
162    KEEP (*(SORT(.ctors.*)))
163    KEEP (*(.ctors))
164  }
165  .dtors          :
166  {
167    KEEP (*crtbegin.o(.dtors))
168    KEEP (*crtbegin?.o(.dtors))
169    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
170    KEEP (*(SORT(.dtors.*)))
171    KEEP (*(.dtors))
172  }
173  .jcr            : { KEEP (*(.jcr)) }
174  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
175  . = DATA_SEGMENT_RELRO_END (0, .);
176  .data           :
177  {
178    _fdata = . ;
179    *(.data .data.* .gnu.linkonce.d.*)
180    SORT(CONSTRUCTORS)
181  }
182  .data1          : { *(.data1) }
183  .got.plt        : { *(.got.plt) }
184  . = .;
185  . = .;
186  HIDDEN (_gp = ALIGN (16) + 0x7ff0);
187  .got            : { *(.got) }
188  /* We want the small data sections together, so single-instruction offsets
189     can access them all, and initialized data all before uninitialized, so
190     we can shorten the on-disk segment size.  */
191  .sdata          :
192  {
193    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
194    *(.sdata .sdata.* .gnu.linkonce.s.*)
195  }
196  .lit8           : { *(.lit8) }
197  .lit4           : { *(.lit4) }
198  .srdata         : { *(.srdata) }
199  _edata = .; PROVIDE (edata = .);
200  . = .;
201  __bss_start = .;
202  _fbss = .;
203  .sbss           :
204  {
205    *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
206    *(.dynsbss)
207    *(.sbss .sbss.* .gnu.linkonce.sb.*)
208    *(.scommon)
209  }
210  .bss            :
211  {
212   *(.dynbss)
213   *(.bss .bss.* .gnu.linkonce.b.*)
214   *(COMMON)
215   /* Align here to ensure that the .bss section occupies space up to
216      _end.  Align after .bss to ensure correct alignment even if the
217      .bss section disappears because there are no input sections.
218      FIXME: Why do we need it? When there is no .bss section, we don't
219      pad the .data section.  */
220   . = ALIGN(. != 0 ? __SIZEOF_LONG__ : 1);
221  }
222  . = ALIGN(__SIZEOF_LONG__);
223  . = SEGMENT_START("ldata-segment", .);
224  . = ALIGN(__SIZEOF_LONG__);
225  _end = .; PROVIDE (end = .);
226  . = DATA_SEGMENT_END (.);
227  /* Stabs debugging sections.  */
228  .stab          0 : { *(.stab) }
229  .stabstr       0 : { *(.stabstr) }
230  .stab.excl     0 : { *(.stab.excl) }
231  .stab.exclstr  0 : { *(.stab.exclstr) }
232  .stab.index    0 : { *(.stab.index) }
233  .stab.indexstr 0 : { *(.stab.indexstr) }
234  .comment       0 : { *(.comment) }
235  /* DWARF debug sections.
236     Symbols in the DWARF debugging sections are relative to the beginning
237     of the section so we begin them at 0.  */
238  /* DWARF 1 */
239  .debug          0 : { *(.debug) }
240  .line           0 : { *(.line) }
241  /* GNU DWARF 1 extensions */
242  .debug_srcinfo  0 : { *(.debug_srcinfo) }
243  .debug_sfnames  0 : { *(.debug_sfnames) }
244  /* DWARF 1.1 and DWARF 2 */
245  .debug_aranges  0 : { *(.debug_aranges) }
246  .debug_pubnames 0 : { *(.debug_pubnames) }
247  /* DWARF 2 */
248  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
249  .debug_abbrev   0 : { *(.debug_abbrev) }
250  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
251  .debug_frame    0 : { *(.debug_frame) }
252  .debug_str      0 : { *(.debug_str) }
253  .debug_loc      0 : { *(.debug_loc) }
254  .debug_macinfo  0 : { *(.debug_macinfo) }
255  /* SGI/MIPS DWARF 2 extensions */
256  .debug_weaknames 0 : { *(.debug_weaknames) }
257  .debug_funcnames 0 : { *(.debug_funcnames) }
258  .debug_typenames 0 : { *(.debug_typenames) }
259  .debug_varnames  0 : { *(.debug_varnames) }
260  /* DWARF 3 */
261  .debug_pubtypes 0 : { *(.debug_pubtypes) }
262  .debug_ranges   0 : { *(.debug_ranges) }
263  /* DWARF Extension.  */
264  .debug_macro    0 : { *(.debug_macro) }
265  .debug_addr     0 : { *(.debug_addr) }
266  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
267  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
268  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
269  .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) }
270  .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) }
271  .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) }
272  .mdebug.abiO64 0 : { KEEP(*(.mdebug.abiO64)) }
273  .mdebug.eabi32 0 : { KEEP(*(.mdebug.eabi32)) }
274  .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) }
275  .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) }
276  .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) }
277  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
278}
279