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