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