Commit | Line | Data |
---|---|---|
252b5132 | 1 | # Linker script for PE. |
985743c7 | 2 | # |
2571583a | 3 | # Copyright (C) 2014-2017 Free Software Foundation, Inc. |
985743c7 NC |
4 | # |
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. | |
252b5132 RH |
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$*)) | |
24 | *(.rdata) | |
25 | *(SORT(.rdata$*))' | |
26 | R_RDATA='' | |
27 | else | |
28 | R_DATA='*(SORT(.data$*))' | |
29 | R_RDATA='*(.rdata) | |
30 | *(SORT(.rdata$*))' | |
31 | fi | |
d4874973 | 32 | R_IDATA234=' |
0f088b2a KT |
33 | KEEP (SORT(*)(.idata$2)) |
34 | KEEP (SORT(*)(.idata$3)) | |
252b5132 RH |
35 | /* These zeroes mark the end of the import list. */ |
36 | LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); | |
0f088b2a KT |
37 | KEEP (SORT(*)(.idata$4))' |
38 | R_IDATA5='KEEP (SORT(*)(.idata$5))' | |
d4874973 | 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 */' | |
ca6dee30 | 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$*))' | |
252b5132 RH |
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)' |
252b5132 RH |
70 | fi |
71 | ||
72 | cat <<EOF | |
2571583a | 73 | /* Copyright (C) 2014-2017 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 | ||
252b5132 RH |
79 | ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} |
80 | ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} | |
c6c37250 | 81 | ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} |
252b5132 RH |
82 | |
83 | ${LIB_SEARCH_DIRS} | |
84 | ||
252b5132 RH |
85 | SECTIONS |
86 | { | |
03098a9a CF |
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__ )} : |
252b5132 | 92 | { |
0f088b2a | 93 | ${RELOCATING+ KEEP(*(.init))} |
252b5132 RH |
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)} | |
ca6f2be7 NC |
100 | ${CONSTRUCTING+ |
101 | PROVIDE(___CTOR_LIST__ = .); | |
102 | PROVIDE(__CTOR_LIST__ = .); | |
103 | LONG (-1); | |
104 | KEEP(*(.ctors)); | |
105 | KEEP(*(.ctor)); | |
106 | KEEP(*(SORT_BY_NAME(.ctors.*))); | |
107 | LONG (0); | |
108 | } | |
109 | ${CONSTRUCTING+ | |
110 | PROVIDE(___DTOR_LIST__ = .); | |
111 | PROVIDE(__DTOR_LIST__ = .); | |
112 | LONG (-1); | |
113 | KEEP(*(.dtors)); | |
114 | KEEP(*(.dtor)); | |
115 | KEEP(*(SORT_BY_NAME(.dtors.*))); | |
116 | LONG (0); | |
117 | } | |
aa785360 | 118 | ${RELOCATING+ KEEP (*(.fini))} |
252b5132 RH |
119 | /* ??? Why is .gcc_exc here? */ |
120 | ${RELOCATING+ *(.gcc_exc)} | |
15c9f673 | 121 | ${RELOCATING+PROVIDE (etext = .);} |
ee8206a9 | 122 | ${RELOCATING+PROVIDE (_etext = .);} |
aa785360 | 123 | ${RELOCATING+ KEEP (*(.gcc_except_table))} |
252b5132 RH |
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__. */ |
252b5132 | 131 | |
5063daf7 | 132 | .data ${RELOCATING+BLOCK(__section_alignment__)} : |
252b5132 RH |
133 | { |
134 | ${RELOCATING+__data_start__ = . ;} | |
135 | *(.data) | |
c48cfedd | 136 | ${RELOCATING+*(.data2)} |
252b5132 | 137 | ${R_DATA} |
0f088b2a | 138 | KEEP(*(.jcr)) |
252b5132 RH |
139 | ${RELOCATING+__data_end__ = . ;} |
140 | ${RELOCATING+*(.data_cygwin_nocopy)} | |
141 | } | |
142 | ||
be4514d3 ILT |
143 | .rdata ${RELOCATING+BLOCK(__section_alignment__)} : |
144 | { | |
be4514d3 | 145 | ${R_RDATA} |
730035f7 | 146 | ${RELOCATING+__rt_psrelocs_start = .;} |
c48cfedd | 147 | ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))} |
730035f7 | 148 | ${RELOCATING+__rt_psrelocs_end = .;} |
be4514d3 | 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;} | |
be4514d3 | 155 | |
27505b5d TG |
156 | .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : |
157 | { | |
c48cfedd | 158 | KEEP(*(.eh_frame${RELOCATING+*})) |
27505b5d TG |
159 | } |
160 | ||
344a211f NC |
161 | .pdata ${RELOCATING+BLOCK(__section_alignment__)} : |
162 | { | |
c48cfedd | 163 | KEEP(*(.pdata${RELOCATING+*})) |
344a211f NC |
164 | } |
165 | ||
252b5132 RH |
166 | .bss ${RELOCATING+BLOCK(__section_alignment__)} : |
167 | { | |
168 | ${RELOCATING+__bss_start__ = . ;} | |
169 | *(.bss) | |
170 | *(COMMON) | |
171 | ${RELOCATING+__bss_end__ = . ;} | |
172 | } | |
173 | ||
252b5132 RH |
174 | .edata ${RELOCATING+BLOCK(__section_alignment__)} : |
175 | { | |
176 | *(.edata) | |
177 | } | |
178 | ||
179 | /DISCARD/ : | |
180 | { | |
181 | *(.debug\$S) | |
182 | *(.debug\$T) | |
183 | *(.debug\$F) | |
184 | *(.drectve) | |
fecc36fd KT |
185 | ${RELOCATING+ *(.note.GNU-stack)} |
186 | ${RELOCATING+ *(.gnu.lto_*)} | |
252b5132 RH |
187 | } |
188 | ||
189 | .idata ${RELOCATING+BLOCK(__section_alignment__)} : | |
190 | { | |
191 | /* This cannot currently be handled with grouped sections. | |
192 | See pe.em:sort_sections. */ | |
d4874973 KT |
193 | ${R_IDATA234} |
194 | ${RELOCATING+__IAT_start__ = .;} | |
195 | ${R_IDATA5} | |
196 | ${RELOCATING+__IAT_end__ = .;} | |
197 | ${R_IDATA67} | |
252b5132 RH |
198 | } |
199 | .CRT ${RELOCATING+BLOCK(__section_alignment__)} : | |
200 | { | |
552f8272 CF |
201 | ${RELOCATING+___crt_xc_start__ = . ;} |
202 | ${R_CRT_XC} | |
203 | ${RELOCATING+___crt_xc_end__ = . ;} | |
204 | ${RELOCATING+___crt_xi_start__ = . ;} | |
205 | ${R_CRT_XI} | |
206 | ${RELOCATING+___crt_xi_end__ = . ;} | |
207 | ${RELOCATING+___crt_xl_start__ = . ;} | |
208 | ${R_CRT_XL} | |
209 | /* ___crt_xl_end__ is defined in the TLS Directory support code */ | |
210 | ${RELOCATING+___crt_xp_start__ = . ;} | |
211 | ${R_CRT_XP} | |
212 | ${RELOCATING+___crt_xp_end__ = . ;} | |
213 | ${RELOCATING+___crt_xt_start__ = . ;} | |
214 | ${R_CRT_XT} | |
215 | ${RELOCATING+___crt_xt_end__ = . ;} | |
252b5132 RH |
216 | } |
217 | ||
a988325c NC |
218 | /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be |
219 | at the end of section. This is important because _tls_start MUST | |
220 | be at the beginning of the section to enable SECREL32 relocations with TLS | |
221 | data. */ | |
ca6dee30 NC |
222 | .tls ${RELOCATING+BLOCK(__section_alignment__)} : |
223 | { | |
552f8272 | 224 | ${RELOCATING+___tls_start__ = . ;} |
ca6dee30 | 225 | ${R_TLS} |
552f8272 | 226 | ${RELOCATING+___tls_end__ = . ;} |
ca6dee30 NC |
227 | } |
228 | ||
252b5132 RH |
229 | .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : |
230 | { | |
231 | /* end is deprecated, don't use it */ | |
15c9f673 CF |
232 | ${RELOCATING+PROVIDE (end = .);} |
233 | ${RELOCATING+PROVIDE ( _end = .);} | |
252b5132 RH |
234 | ${RELOCATING+ __end__ = .;} |
235 | } | |
236 | ||
1d63324c | 237 | .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4) |
5063daf7 | 238 | { |
252b5132 RH |
239 | ${R_RSRC} |
240 | } | |
241 | ||
be4514d3 | 242 | .reloc ${RELOCATING+BLOCK(__section_alignment__)} : |
5063daf7 | 243 | { |
be4514d3 ILT |
244 | *(.reloc) |
245 | } | |
246 | ||
252b5132 RH |
247 | .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
248 | { | |
8a7140c3 | 249 | *(.stab) |
252b5132 RH |
250 | } |
251 | ||
252 | .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
253 | { | |
8a7140c3 | 254 | *(.stabstr) |
252b5132 RH |
255 | } |
256 | ||
8a7140c3 NC |
257 | /* DWARF debug sections. |
258 | Symbols in the DWARF debugging sections are relative to the beginning | |
259 | of the section. Unlike other targets that fake this by putting the | |
260 | section VMA at 0, the PE format will not allow it. */ | |
5063daf7 | 261 | |
8a7140c3 NC |
262 | /* DWARF 1.1 and DWARF 2. */ |
263 | .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
264 | { | |
265 | *(.debug_aranges) | |
266 | } | |
a29a8af8 KT |
267 | .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
268 | { | |
269 | *(.zdebug_aranges) | |
270 | } | |
8a7140c3 NC |
271 | |
272 | .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
273 | { | |
274 | *(.debug_pubnames) | |
275 | } | |
a29a8af8 KT |
276 | .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
277 | { | |
278 | *(.zdebug_pubnames) | |
279 | } | |
8a7140c3 | 280 | |
22418005 | 281 | .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
a626fe20 KT |
282 | { |
283 | *(.debug_pubtypes) | |
284 | } | |
a29a8af8 KT |
285 | .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
286 | { | |
287 | *(.zdebug_pubtypes) | |
288 | } | |
a626fe20 | 289 | |
8a7140c3 NC |
290 | /* DWARF 2. */ |
291 | .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
292 | { | |
ebe9c501 | 293 | *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) |
8a7140c3 | 294 | } |
a29a8af8 KT |
295 | .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
296 | { | |
297 | *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*}) | |
298 | } | |
8a7140c3 NC |
299 | |
300 | .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
301 | { | |
302 | *(.debug_abbrev) | |
303 | } | |
a29a8af8 KT |
304 | .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
305 | { | |
306 | *(.zdebug_abbrev) | |
307 | } | |
8a7140c3 NC |
308 | |
309 | .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
310 | { | |
311 | *(.debug_line) | |
312 | } | |
a29a8af8 KT |
313 | .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
314 | { | |
315 | *(.zdebug_line) | |
316 | } | |
8a7140c3 NC |
317 | |
318 | .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
319 | { | |
72b016b4 | 320 | *(.debug_frame*) |
8a7140c3 | 321 | } |
a29a8af8 KT |
322 | .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
323 | { | |
324 | *(.zdebug_frame*) | |
325 | } | |
8a7140c3 NC |
326 | |
327 | .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
328 | { | |
329 | *(.debug_str) | |
330 | } | |
a29a8af8 KT |
331 | .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
332 | { | |
333 | *(.zdebug_str) | |
334 | } | |
8a7140c3 NC |
335 | |
336 | .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
337 | { | |
338 | *(.debug_loc) | |
339 | } | |
a29a8af8 KT |
340 | .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
341 | { | |
342 | *(.zdebug_loc) | |
343 | } | |
8a7140c3 NC |
344 | |
345 | .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
346 | { | |
347 | *(.debug_macinfo) | |
348 | } | |
a29a8af8 KT |
349 | .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
350 | { | |
351 | *(.zdebug_macinfo) | |
352 | } | |
8a7140c3 NC |
353 | |
354 | /* SGI/MIPS DWARF 2 extensions. */ | |
355 | .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
356 | { | |
357 | *(.debug_weaknames) | |
358 | } | |
a29a8af8 KT |
359 | .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
360 | { | |
361 | *(.zdebug_weaknames) | |
362 | } | |
8a7140c3 NC |
363 | |
364 | .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
365 | { | |
366 | *(.debug_funcnames) | |
367 | } | |
a29a8af8 KT |
368 | .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
369 | { | |
370 | *(.zdebug_funcnames) | |
371 | } | |
8a7140c3 NC |
372 | |
373 | .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
374 | { | |
375 | *(.debug_typenames) | |
376 | } | |
a29a8af8 KT |
377 | .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
378 | { | |
379 | *(.zdebug_typenames) | |
380 | } | |
8a7140c3 NC |
381 | |
382 | .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
383 | { | |
384 | *(.debug_varnames) | |
385 | } | |
a29a8af8 KT |
386 | .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
387 | { | |
388 | *(.zdebug_varnames) | |
389 | } | |
8a7140c3 | 390 | |
b990ad61 KT |
391 | .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
392 | { | |
393 | *(.debug_macro) | |
394 | } | |
a29a8af8 KT |
395 | .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
396 | { | |
397 | *(.zdebug_macro) | |
398 | } | |
b990ad61 | 399 | |
8a7140c3 NC |
400 | /* DWARF 3. */ |
401 | .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
402 | { | |
403 | *(.debug_ranges) | |
404 | } | |
a29a8af8 KT |
405 | .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
406 | { | |
407 | *(.zdebug_ranges) | |
408 | } | |
802d4822 KT |
409 | |
410 | /* DWARF 4. */ | |
411 | .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
412 | { | |
ebe9c501 | 413 | *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*}) |
802d4822 | 414 | } |
a29a8af8 KT |
415 | .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
416 | { | |
417 | *(.zdebug_types${RELOCATING+ .gnu.linkonce.wt.*}) | |
418 | } | |
786e3eba NC |
419 | |
420 | /* For Go and Rust. */ | |
421 | .debug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
422 | { | |
423 | *(.debug_gdb_scripts) | |
424 | } | |
425 | .zdebug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
426 | { | |
427 | *(.zdebug_gdb_scripts) | |
428 | } | |
252b5132 RH |
429 | } |
430 | EOF |