]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # Linker script for PE. |
2 | ||
3 | if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then | |
4 | RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
5 | fi | |
6 | ||
7 | # We can't easily and portably get an unquoted $ in a shell | |
8 | # substitution, so we do this instead. | |
9 | # Sorting of the .foo$* sections is required by the definition of | |
10 | # grouped sections in PE. | |
11 | # Sorting of the file names in R_IDATA is required by the | |
12 | # current implementation of dlltool (this could probably be changed to | |
13 | # use grouped sections instead). | |
14 | if test "${RELOCATING}"; then | |
15 | R_TEXT='*(SORT(.text$*))' | |
e2a83dd0 NC |
16 | if test "x$LD_FLAG" = "xauto_import" ; then |
17 | R_DATA='*(SORT(.data$*)) | |
18 | *(.rdata) | |
19 | *(SORT(.rdata$*))' | |
20 | R_RDATA='' | |
21 | else | |
22 | R_DATA='*(SORT(.data$*))' | |
23 | R_RDATA='*(.rdata) | |
24 | *(SORT(.rdata$*))' | |
25 | fi | |
d4874973 | 26 | R_IDATA234=' |
252b5132 RH |
27 | SORT(*)(.idata$2) |
28 | SORT(*)(.idata$3) | |
29 | /* These zeroes mark the end of the import list. */ | |
30 | LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); | |
d4874973 KT |
31 | SORT(*)(.idata$4)' |
32 | R_IDATA5='SORT(*)(.idata$5)' | |
33 | R_IDATA67=' | |
252b5132 RH |
34 | SORT(*)(.idata$6) |
35 | SORT(*)(.idata$7)' | |
552f8272 CF |
36 | R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' |
37 | R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' | |
38 | R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' | |
39 | R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' | |
40 | R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' | |
ca6dee30 | 41 | R_TLS=' |
5063daf7 | 42 | *(.tls$AAA) |
ca6dee30 NC |
43 | *(.tls) |
44 | *(.tls$) | |
a988325c NC |
45 | *(SORT(.tls$*)) |
46 | *(.tls$ZZZ)' | |
5063daf7 NC |
47 | if test -z "$DEFAULT_MANIFEST"; then |
48 | R_RSRC=' | |
49 | *(.rsrc) | |
6caf7111 | 50 | *(.rsrc$*)' |
5063daf7 NC |
51 | else |
52 | R_RSRC=" | |
53 | /* The default manifest contains information necessary for | |
54 | binaries to run under Windows 8 (or later). It is included as | |
55 | the last resource file so that if the application has provided | |
6caf7111 NC |
56 | its own manifest then that one will take precedence. |
57 | ||
58 | Note - the .rsrc section merging code relies upon the fact | |
59 | that the input .rsrc sections are *not* sorted. */ | |
1d63324c | 60 | *(EXCLUDE_FILE (*$DEFAULT_MANIFEST) .rsrc) |
6caf7111 | 61 | *(.rsrc*) |
5063daf7 NC |
62 | KEEP ($DEFAULT_MANIFEST(.rsrc))" |
63 | fi | |
252b5132 RH |
64 | else |
65 | R_TEXT= | |
66 | R_DATA= | |
e2a83dd0 | 67 | R_RDATA='*(.rdata)' |
d4874973 KT |
68 | R_IDATA234= |
69 | R_IDATA5= | |
70 | R_IDATA67= | |
252b5132 | 71 | R_CRT= |
5063daf7 | 72 | R_RSRC='*(.rsrc)' |
252b5132 RH |
73 | fi |
74 | ||
75 | cat <<EOF | |
76 | ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} | |
77 | ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} | |
c6c37250 | 78 | ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} |
252b5132 RH |
79 | |
80 | ${LIB_SEARCH_DIRS} | |
81 | ||
252b5132 RH |
82 | SECTIONS |
83 | { | |
03098a9a CF |
84 | ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} |
85 | ${RELOCATING+ lower than the target page size. */} | |
86 | ${RELOCATING+. = SIZEOF_HEADERS;} | |
87 | ${RELOCATING+. = ALIGN(__section_alignment__);} | |
5063daf7 | 88 | .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : |
252b5132 RH |
89 | { |
90 | ${RELOCATING+ *(.init)} | |
91 | *(.text) | |
92 | ${R_TEXT} | |
032f3e01 | 93 | ${RELOCATING+ *(.text.*)} |
ebe9c501 | 94 | ${RELOCATING+ *(.gnu.linkonce.t.*)} |
252b5132 RH |
95 | *(.glue_7t) |
96 | *(.glue_7) | |
5063daf7 | 97 | ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
3c17e4f7 | 98 | LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); } |
5063daf7 | 99 | ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
3c17e4f7 | 100 | LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); } |
252b5132 RH |
101 | ${RELOCATING+ *(.fini)} |
102 | /* ??? Why is .gcc_exc here? */ | |
103 | ${RELOCATING+ *(.gcc_exc)} | |
15c9f673 | 104 | ${RELOCATING+PROVIDE (etext = .);} |
ee8206a9 | 105 | ${RELOCATING+PROVIDE (_etext = .);} |
5f294ed6 | 106 | ${RELOCATING+ *(.gcc_except_table)} |
252b5132 RH |
107 | } |
108 | ||
109 | /* The Cygwin32 library uses a section to avoid copying certain data | |
110 | on fork. This used to be named ".data$nocopy". The linker used | |
111 | to include this between __data_start__ and __data_end__, but that | |
112 | breaks building the cygwin32 dll. Instead, we name the section | |
cc643b88 | 113 | ".data_cygwin_nocopy" and explicitly include it after __data_end__. */ |
252b5132 | 114 | |
5063daf7 | 115 | .data ${RELOCATING+BLOCK(__section_alignment__)} : |
252b5132 RH |
116 | { |
117 | ${RELOCATING+__data_start__ = . ;} | |
118 | *(.data) | |
119 | *(.data2) | |
120 | ${R_DATA} | |
02f80eef | 121 | *(.jcr) |
252b5132 RH |
122 | ${RELOCATING+__data_end__ = . ;} |
123 | ${RELOCATING+*(.data_cygwin_nocopy)} | |
124 | } | |
125 | ||
be4514d3 ILT |
126 | .rdata ${RELOCATING+BLOCK(__section_alignment__)} : |
127 | { | |
be4514d3 | 128 | ${R_RDATA} |
730035f7 | 129 | ${RELOCATING+__rt_psrelocs_start = .;} |
ad5211be | 130 | *(.rdata_runtime_pseudo_reloc) |
730035f7 | 131 | ${RELOCATING+__rt_psrelocs_end = .;} |
be4514d3 | 132 | } |
730035f7 DK |
133 | ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;} |
134 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
135 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
136 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} | |
137 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} | |
be4514d3 | 138 | |
27505b5d TG |
139 | .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : |
140 | { | |
72b016b4 | 141 | *(.eh_frame*) |
27505b5d TG |
142 | } |
143 | ||
344a211f NC |
144 | .pdata ${RELOCATING+BLOCK(__section_alignment__)} : |
145 | { | |
146 | *(.pdata) | |
147 | } | |
148 | ||
252b5132 RH |
149 | .bss ${RELOCATING+BLOCK(__section_alignment__)} : |
150 | { | |
151 | ${RELOCATING+__bss_start__ = . ;} | |
152 | *(.bss) | |
153 | *(COMMON) | |
154 | ${RELOCATING+__bss_end__ = . ;} | |
155 | } | |
156 | ||
252b5132 RH |
157 | .edata ${RELOCATING+BLOCK(__section_alignment__)} : |
158 | { | |
159 | *(.edata) | |
160 | } | |
161 | ||
162 | /DISCARD/ : | |
163 | { | |
164 | *(.debug\$S) | |
165 | *(.debug\$T) | |
166 | *(.debug\$F) | |
167 | *(.drectve) | |
fecc36fd KT |
168 | ${RELOCATING+ *(.note.GNU-stack)} |
169 | ${RELOCATING+ *(.gnu.lto_*)} | |
252b5132 RH |
170 | } |
171 | ||
172 | .idata ${RELOCATING+BLOCK(__section_alignment__)} : | |
173 | { | |
174 | /* This cannot currently be handled with grouped sections. | |
175 | See pe.em:sort_sections. */ | |
d4874973 KT |
176 | ${R_IDATA234} |
177 | ${RELOCATING+__IAT_start__ = .;} | |
178 | ${R_IDATA5} | |
179 | ${RELOCATING+__IAT_end__ = .;} | |
180 | ${R_IDATA67} | |
252b5132 RH |
181 | } |
182 | .CRT ${RELOCATING+BLOCK(__section_alignment__)} : | |
183 | { | |
552f8272 CF |
184 | ${RELOCATING+___crt_xc_start__ = . ;} |
185 | ${R_CRT_XC} | |
186 | ${RELOCATING+___crt_xc_end__ = . ;} | |
187 | ${RELOCATING+___crt_xi_start__ = . ;} | |
188 | ${R_CRT_XI} | |
189 | ${RELOCATING+___crt_xi_end__ = . ;} | |
190 | ${RELOCATING+___crt_xl_start__ = . ;} | |
191 | ${R_CRT_XL} | |
192 | /* ___crt_xl_end__ is defined in the TLS Directory support code */ | |
193 | ${RELOCATING+___crt_xp_start__ = . ;} | |
194 | ${R_CRT_XP} | |
195 | ${RELOCATING+___crt_xp_end__ = . ;} | |
196 | ${RELOCATING+___crt_xt_start__ = . ;} | |
197 | ${R_CRT_XT} | |
198 | ${RELOCATING+___crt_xt_end__ = . ;} | |
252b5132 RH |
199 | } |
200 | ||
a988325c NC |
201 | /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be |
202 | at the end of section. This is important because _tls_start MUST | |
203 | be at the beginning of the section to enable SECREL32 relocations with TLS | |
204 | data. */ | |
ca6dee30 NC |
205 | .tls ${RELOCATING+BLOCK(__section_alignment__)} : |
206 | { | |
552f8272 | 207 | ${RELOCATING+___tls_start__ = . ;} |
ca6dee30 | 208 | ${R_TLS} |
552f8272 | 209 | ${RELOCATING+___tls_end__ = . ;} |
ca6dee30 NC |
210 | } |
211 | ||
252b5132 RH |
212 | .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : |
213 | { | |
214 | /* end is deprecated, don't use it */ | |
15c9f673 CF |
215 | ${RELOCATING+PROVIDE (end = .);} |
216 | ${RELOCATING+PROVIDE ( _end = .);} | |
252b5132 RH |
217 | ${RELOCATING+ __end__ = .;} |
218 | } | |
219 | ||
1d63324c | 220 | .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4) |
5063daf7 | 221 | { |
252b5132 RH |
222 | ${R_RSRC} |
223 | } | |
224 | ||
be4514d3 | 225 | .reloc ${RELOCATING+BLOCK(__section_alignment__)} : |
5063daf7 | 226 | { |
be4514d3 ILT |
227 | *(.reloc) |
228 | } | |
229 | ||
252b5132 RH |
230 | .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
231 | { | |
8a7140c3 | 232 | *(.stab) |
252b5132 RH |
233 | } |
234 | ||
235 | .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
236 | { | |
8a7140c3 | 237 | *(.stabstr) |
252b5132 RH |
238 | } |
239 | ||
8a7140c3 NC |
240 | /* DWARF debug sections. |
241 | Symbols in the DWARF debugging sections are relative to the beginning | |
242 | of the section. Unlike other targets that fake this by putting the | |
243 | section VMA at 0, the PE format will not allow it. */ | |
5063daf7 | 244 | |
8a7140c3 NC |
245 | /* DWARF 1.1 and DWARF 2. */ |
246 | .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
247 | { | |
248 | *(.debug_aranges) | |
249 | } | |
a29a8af8 KT |
250 | .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
251 | { | |
252 | *(.zdebug_aranges) | |
253 | } | |
8a7140c3 NC |
254 | |
255 | .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
256 | { | |
257 | *(.debug_pubnames) | |
258 | } | |
a29a8af8 KT |
259 | .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
260 | { | |
261 | *(.zdebug_pubnames) | |
262 | } | |
8a7140c3 | 263 | |
22418005 | 264 | .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
a626fe20 KT |
265 | { |
266 | *(.debug_pubtypes) | |
267 | } | |
a29a8af8 KT |
268 | .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
269 | { | |
270 | *(.zdebug_pubtypes) | |
271 | } | |
a626fe20 | 272 | |
8a7140c3 NC |
273 | /* DWARF 2. */ |
274 | .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
275 | { | |
ebe9c501 | 276 | *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) |
8a7140c3 | 277 | } |
a29a8af8 KT |
278 | .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
279 | { | |
280 | *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*}) | |
281 | } | |
8a7140c3 NC |
282 | |
283 | .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
284 | { | |
285 | *(.debug_abbrev) | |
286 | } | |
a29a8af8 KT |
287 | .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
288 | { | |
289 | *(.zdebug_abbrev) | |
290 | } | |
8a7140c3 NC |
291 | |
292 | .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
293 | { | |
294 | *(.debug_line) | |
295 | } | |
a29a8af8 KT |
296 | .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
297 | { | |
298 | *(.zdebug_line) | |
299 | } | |
8a7140c3 NC |
300 | |
301 | .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
302 | { | |
72b016b4 | 303 | *(.debug_frame*) |
8a7140c3 | 304 | } |
a29a8af8 KT |
305 | .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
306 | { | |
307 | *(.zdebug_frame*) | |
308 | } | |
8a7140c3 NC |
309 | |
310 | .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
311 | { | |
312 | *(.debug_str) | |
313 | } | |
a29a8af8 KT |
314 | .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
315 | { | |
316 | *(.zdebug_str) | |
317 | } | |
8a7140c3 NC |
318 | |
319 | .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
320 | { | |
321 | *(.debug_loc) | |
322 | } | |
a29a8af8 KT |
323 | .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
324 | { | |
325 | *(.zdebug_loc) | |
326 | } | |
8a7140c3 NC |
327 | |
328 | .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
329 | { | |
330 | *(.debug_macinfo) | |
331 | } | |
a29a8af8 KT |
332 | .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
333 | { | |
334 | *(.zdebug_macinfo) | |
335 | } | |
8a7140c3 NC |
336 | |
337 | /* SGI/MIPS DWARF 2 extensions. */ | |
338 | .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
339 | { | |
340 | *(.debug_weaknames) | |
341 | } | |
a29a8af8 KT |
342 | .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
343 | { | |
344 | *(.zdebug_weaknames) | |
345 | } | |
8a7140c3 NC |
346 | |
347 | .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
348 | { | |
349 | *(.debug_funcnames) | |
350 | } | |
a29a8af8 KT |
351 | .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
352 | { | |
353 | *(.zdebug_funcnames) | |
354 | } | |
8a7140c3 NC |
355 | |
356 | .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
357 | { | |
358 | *(.debug_typenames) | |
359 | } | |
a29a8af8 KT |
360 | .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
361 | { | |
362 | *(.zdebug_typenames) | |
363 | } | |
8a7140c3 NC |
364 | |
365 | .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
366 | { | |
367 | *(.debug_varnames) | |
368 | } | |
a29a8af8 KT |
369 | .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
370 | { | |
371 | *(.zdebug_varnames) | |
372 | } | |
8a7140c3 | 373 | |
b990ad61 KT |
374 | .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
375 | { | |
376 | *(.debug_macro) | |
377 | } | |
a29a8af8 KT |
378 | .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
379 | { | |
380 | *(.zdebug_macro) | |
381 | } | |
b990ad61 | 382 | |
8a7140c3 NC |
383 | /* DWARF 3. */ |
384 | .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
385 | { | |
386 | *(.debug_ranges) | |
387 | } | |
a29a8af8 KT |
388 | .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
389 | { | |
390 | *(.zdebug_ranges) | |
391 | } | |
802d4822 KT |
392 | |
393 | /* DWARF 4. */ | |
394 | .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
395 | { | |
ebe9c501 | 396 | *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*}) |
802d4822 | 397 | } |
a29a8af8 KT |
398 | .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
399 | { | |
400 | *(.zdebug_types${RELOCATING+ .gnu.linkonce.wt.*}) | |
401 | } | |
252b5132 RH |
402 | } |
403 | EOF |