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