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