blob: de12b00e19f4e325c2cc2da11ac3a801bb69b43f [file] [log] [blame]
Andrew Hsieh35659b62013-09-22 14:07:09 +08001/* Script for -n: mix text and data on same page */
2OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips",
3 "elf64-tradlittlemips")
4OUTPUT_ARCH(mips)
5ENTRY(__start)
6SECTIONS
7{
8 /* Read-only sections, merged into text segment: */
9 PROVIDE (__executable_start = 0x120000000); . = 0x120000000 + SIZEOF_HEADERS;
10 .MIPS.options : { *(.MIPS.options) }
11 .note.gnu.build-id : { *(.note.gnu.build-id) }
12 .dynamic : { *(.dynamic) }
13 .hash : { *(.hash) }
14 .gnu.hash : { *(.gnu.hash) }
15 .dynsym : { *(.dynsym) }
16 .dynstr : { *(.dynstr) }
17 .gnu.version : { *(.gnu.version) }
18 .gnu.version_d : { *(.gnu.version_d) }
19 .gnu.version_r : { *(.gnu.version_r) }
20 .rel.init : { *(.rel.init) }
21 .rela.init : { *(.rela.init) }
22 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
23 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
24 .rel.fini : { *(.rel.fini) }
25 .rela.fini : { *(.rela.fini) }
26 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
27 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
28 .rel.data.rel.ro : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
29 .rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
30 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
31 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
32 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
33 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
34 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
35 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
36 .rel.ctors : { *(.rel.ctors) }
37 .rela.ctors : { *(.rela.ctors) }
38 .rel.dtors : { *(.rel.dtors) }
39 .rela.dtors : { *(.rela.dtors) }
40 .rel.got : { *(.rel.got) }
41 .rela.got : { *(.rela.got) }
42 .rel.dyn : { *(.rel.dyn) }
43 .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
44 .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
45 .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
46 .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
47 .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
48 .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
49 .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
50 .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
51 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
52 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
53 .rel.iplt :
54 {
55 PROVIDE_HIDDEN (__rel_iplt_start = .);
56 *(.rel.iplt)
57 PROVIDE_HIDDEN (__rel_iplt_end = .);
58 }
59 .rela.iplt :
60 {
61 PROVIDE_HIDDEN (__rela_iplt_start = .);
62 *(.rela.iplt)
63 PROVIDE_HIDDEN (__rela_iplt_end = .);
64 }
65 .rel.plt :
66 {
67 *(.rel.plt)
68 }
69 .rela.plt :
70 {
71 *(.rela.plt)
72 }
73 .init :
74 {
75 KEEP (*(SORT_NONE(.init)))
76 }
77 .plt : { *(.plt) }
78 .iplt : { *(.iplt) }
79 .text :
80 {
81 _ftext = . ;
Andrew Hsieh98557ce2014-04-26 20:01:20 -070082 *(.text.unlikely .text.*_unlikely .text.unlikely.*)
Andrew Hsieh35659b62013-09-22 14:07:09 +080083 *(.text.exit .text.exit.*)
84 *(.text.startup .text.startup.*)
85 *(.text.hot .text.hot.*)
86 *(.text .stub .text.* .gnu.linkonce.t.*)
87 /* .gnu.warning sections are handled specially by elf32.em. */
88 *(.gnu.warning)
89 *(.mips16.fn.*) *(.mips16.call.*)
90 }
91 .fini :
92 {
93 KEEP (*(SORT_NONE(.fini)))
94 }
95 PROVIDE (__etext = .);
96 PROVIDE (_etext = .);
97 PROVIDE (etext = .);
98 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
99 .rodata1 : { *(.rodata1) }
100 .sdata2 :
101 {
102 *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
103 }
104 .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
105 .eh_frame_hdr : { *(.eh_frame_hdr) }
106 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
107 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
108 .gcc_except_table.*) }
109 /* These sections are generated by the Sun/Oracle C++ compiler. */
110 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
111 .exception_ranges*) }
Andrew Hsieh98557ce2014-04-26 20:01:20 -0700112 /* Adjust the address for the data segment. For 32 bits we want to align
113 at exactly a page boundary to make life easier for apriori. */
114 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
Andrew Hsieh35659b62013-09-22 14:07:09 +0800115 /* Exception handling */
116 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
117 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
118 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
119 /* Thread Local Storage sections */
120 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
121 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
122 /* Ensure the __preinit_array_start label is properly aligned. We
123 could instead move the label definition inside the section, but
124 the linker would then create the section even if it turns out to
125 be empty, which isn't pretty. */
126 . = ALIGN(32 / 8);
127 PROVIDE_HIDDEN (__preinit_array_start = .);
128 .preinit_array :
129 {
130 KEEP (*(.preinit_array))
131 }
132 PROVIDE_HIDDEN (__preinit_array_end = .);
133 PROVIDE_HIDDEN (__init_array_start = .);
134 .init_array :
135 {
136 KEEP (*crtbegin*.o(.init_array))
137 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
Andrew Hsieh98557ce2014-04-26 20:01:20 -0700138 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .ctors))
Andrew Hsieh35659b62013-09-22 14:07:09 +0800139 }
140 PROVIDE_HIDDEN (__init_array_end = .);
141 PROVIDE_HIDDEN (__fini_array_start = .);
142 .fini_array :
143 {
144 KEEP (*crtbegin*.o(.fini_array))
145 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
Andrew Hsieh98557ce2014-04-26 20:01:20 -0700146 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .dtors))
Andrew Hsieh35659b62013-09-22 14:07:09 +0800147 }
148 PROVIDE_HIDDEN (__fini_array_end = .);
149 .ctors :
150 {
151 /* gcc uses crtbegin.o to find the start of
152 the constructors, so we make sure it is
153 first. Because this is a wildcard, it
154 doesn't matter if the user does not
155 actually link against crtbegin.o; the
156 linker won't look for a file to match a
157 wildcard. The wildcard also means that it
158 doesn't matter which directory crtbegin.o
159 is in. */
160 KEEP (*crtbegin.o(.ctors))
161 KEEP (*crtbegin*.o(.ctors))
162 /* We don't want to include the .ctor section from
163 the crtend.o file until after the sorted ctors.
164 The .ctor section from the crtend file contains the
165 end of ctors marker and it must be last */
166 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors))
167 KEEP (*(SORT(.ctors.*)))
168 KEEP (*(.ctors))
169 }
170 .dtors :
171 {
172 KEEP (*crtbegin.o(.dtors))
173 KEEP (*crtbegin*.o(.dtors))
174 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors))
175 KEEP (*(SORT(.dtors.*)))
176 KEEP (*(.dtors))
177 }
178 .jcr : { KEEP (*(.jcr)) }
179 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
180 . = DATA_SEGMENT_RELRO_END (0, .);
181 .data :
182 {
183 _fdata = . ;
184 *(.data .data.* .gnu.linkonce.d.*)
185 SORT(CONSTRUCTORS)
186 }
187 .data1 : { *(.data1) }
188 .got.plt : { *(.got.plt) }
189 . = .;
190 . = .;
191 HIDDEN (_gp = ALIGN (16) + 0x7ff0);
192 .got : { *(.got) }
193 /* We want the small data sections together, so single-instruction offsets
194 can access them all, and initialized data all before uninitialized, so
195 we can shorten the on-disk segment size. */
196 .sdata :
197 {
198 *(.sdata .sdata.* .gnu.linkonce.s.*)
199 }
200 .lit8 : { *(.lit8) }
201 .lit4 : { *(.lit4) }
202 .srdata : { *(.srdata) }
203 _edata = .; PROVIDE (edata = .);
204 . = .;
205 __bss_start = .;
206 _fbss = .;
207 .sbss :
208 {
209 *(.dynsbss)
210 *(.sbss .sbss.* .gnu.linkonce.sb.*)
211 *(.scommon)
212 }
213 .bss :
214 {
215 *(.dynbss)
216 *(.bss .bss.* .gnu.linkonce.b.*)
217 *(COMMON)
218 /* Align here to ensure that the .bss section occupies space up to
219 _end. Align after .bss to ensure correct alignment even if the
220 .bss section disappears because there are no input sections. */
221 . = ALIGN(64 / 8);
222 }
223 . = ALIGN(64 / 8);
Andrew Hsieh98557ce2014-04-26 20:01:20 -0700224 . = SEGMENT_START("ldata-segment", .);
Andrew Hsieh35659b62013-09-22 14:07:09 +0800225 . = ALIGN(64 / 8);
226 _end = .;
227 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
228 PROVIDE (end = .);
229 . = DATA_SEGMENT_END (.);
230 /* Stabs debugging sections. */
231 .stab 0 : { *(.stab) }
232 .stabstr 0 : { *(.stabstr) }
233 .stab.excl 0 : { *(.stab.excl) }
234 .stab.exclstr 0 : { *(.stab.exclstr) }
235 .stab.index 0 : { *(.stab.index) }
236 .stab.indexstr 0 : { *(.stab.indexstr) }
237 .comment 0 : { *(.comment) }
238 /* DWARF debug sections.
239 Symbols in the DWARF debugging sections are relative to the beginning
240 of the section so we begin them at 0. */
241 /* DWARF 1 */
242 .debug 0 : { *(.debug) }
243 .line 0 : { *(.line) }
244 /* GNU DWARF 1 extensions */
245 .debug_srcinfo 0 : { *(.debug_srcinfo) }
246 .debug_sfnames 0 : { *(.debug_sfnames) }
247 /* DWARF 1.1 and DWARF 2 */
248 .debug_aranges 0 : { *(.debug_aranges) }
249 .debug_pubnames 0 : { *(.debug_pubnames) }
250 /* DWARF 2 */
251 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
252 .debug_abbrev 0 : { *(.debug_abbrev) }
Andrew Hsieh98557ce2014-04-26 20:01:20 -0700253 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
Andrew Hsieh35659b62013-09-22 14:07:09 +0800254 .debug_frame 0 : { *(.debug_frame) }
255 .debug_str 0 : { *(.debug_str) }
256 .debug_loc 0 : { *(.debug_loc) }
257 .debug_macinfo 0 : { *(.debug_macinfo) }
258 /* SGI/MIPS DWARF 2 extensions */
259 .debug_weaknames 0 : { *(.debug_weaknames) }
260 .debug_funcnames 0 : { *(.debug_funcnames) }
261 .debug_typenames 0 : { *(.debug_typenames) }
262 .debug_varnames 0 : { *(.debug_varnames) }
263 /* DWARF 3 */
264 .debug_pubtypes 0 : { *(.debug_pubtypes) }
265 .debug_ranges 0 : { *(.debug_ranges) }
266 /* DWARF Extension. */
267 .debug_macro 0 : { *(.debug_macro) }
268 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
269 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
270 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
271 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }
272}