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