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