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