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