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