Rename remaining members of buildsym_compunit to start with "m_"
[deliverable/binutils-gdb.git] / ld / scripttempl / pe.sc
CommitLineData
252b5132 1# Linker script for PE.
985743c7 2#
219d1afa 3# Copyright (C) 2014-2018 Free Software Foundation, Inc.
6c19b93b 4#
985743c7
NC
5# Copying and distribution of this file, with or without modification,
6# are permitted in any medium without royalty provided the copyright
7# notice and this notice are preserved.
252b5132
RH
8
9if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
10 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
11fi
12
13# We can't easily and portably get an unquoted $ in a shell
14# substitution, so we do this instead.
15# Sorting of the .foo$* sections is required by the definition of
16# grouped sections in PE.
17# Sorting of the file names in R_IDATA is required by the
18# current implementation of dlltool (this could probably be changed to
19# use grouped sections instead).
20if test "${RELOCATING}"; then
21 R_TEXT='*(SORT(.text$*))'
e2a83dd0
NC
22 if test "x$LD_FLAG" = "xauto_import" ; then
23 R_DATA='*(SORT(.data$*))
6c19b93b 24 *(.rdata)
e2a83dd0
NC
25 *(SORT(.rdata$*))'
26 R_RDATA=''
27 else
28 R_DATA='*(SORT(.data$*))'
29 R_RDATA='*(.rdata)
6c19b93b 30 *(SORT(.rdata$*))'
e2a83dd0 31 fi
d4874973 32 R_IDATA234='
0f088b2a
KT
33 KEEP (SORT(*)(.idata$2))
34 KEEP (SORT(*)(.idata$3))
252b5132
RH
35 /* These zeroes mark the end of the import list. */
36 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
0f088b2a
KT
37 KEEP (SORT(*)(.idata$4))'
38 R_IDATA5='KEEP (SORT(*)(.idata$5))'
d4874973 39 R_IDATA67='
0f088b2a
KT
40 KEEP (SORT(*)(.idata$6))
41 KEEP (SORT(*)(.idata$7))'
42 R_CRT_XC='KEEP (*(SORT(.CRT$XC*))) /* C initialization */'
43 R_CRT_XI='KEEP (*(SORT(.CRT$XI*))) /* C++ initialization */'
44 R_CRT_XL='KEEP (*(SORT(.CRT$XL*))) /* TLS callbacks */'
45 R_CRT_XP='KEEP (*(SORT(.CRT$XP*))) /* Pre-termination */'
46 R_CRT_XT='KEEP (*(SORT(.CRT$XT*))) /* Termination */'
ca6dee30 47 R_TLS='
0f088b2a
KT
48 KEEP (*(.tls$AAA))
49 KEEP (*(.tls))
50 KEEP (*(.tls$))
51 KEEP (*(SORT(.tls$*)))
52 KEEP (*(.tls$ZZZ))'
6c1799ad 53 R_RSRC='
0f088b2a
KT
54 KEEP (*(.rsrc))
55 KEEP (*(.rsrc$*))'
252b5132
RH
56else
57 R_TEXT=
58 R_DATA=
e2a83dd0 59 R_RDATA='*(.rdata)'
d4874973
KT
60 R_IDATA234=
61 R_IDATA5=
62 R_IDATA67=
c48cfedd
AM
63 R_CRT_XC=
64 R_CRT_XI=
65 R_CRT_XL=
66 R_CRT_XP=
67 R_CRT_XT=
68 R_TLS='*(.tls)'
5063daf7 69 R_RSRC='*(.rsrc)'
252b5132
RH
70fi
71
72cat <<EOF
219d1afa 73/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
985743c7
NC
74
75 Copying and distribution of this script, with or without modification,
76 are permitted in any medium without royalty provided the copyright
77 notice and this notice are preserved. */
78
252b5132
RH
79${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
80${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
c6c37250 81${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
252b5132
RH
82
83${LIB_SEARCH_DIRS}
84
252b5132
RH
85SECTIONS
86{
03098a9a
CF
87 ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is}
88 ${RELOCATING+ lower than the target page size. */}
89 ${RELOCATING+. = SIZEOF_HEADERS;}
90 ${RELOCATING+. = ALIGN(__section_alignment__);}
5063daf7 91 .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
252b5132 92 {
0f088b2a 93 ${RELOCATING+ KEEP(*(.init))}
252b5132
RH
94 *(.text)
95 ${R_TEXT}
032f3e01 96 ${RELOCATING+ *(.text.*)}
ebe9c501 97 ${RELOCATING+ *(.gnu.linkonce.t.*)}
c48cfedd
AM
98 ${RELOCATING+*(.glue_7t)}
99 ${RELOCATING+*(.glue_7)}
ca6f2be7 100 ${CONSTRUCTING+
b0daac83
NC
101 /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
102 we do not PROVIDE them. This is because the ctors.o startup
103 code in libgcc defines them as common symbols, with the
104 expectation that they will be overridden by the definitions
105 here. If we PROVIDE the symbols then they will not be
106 overridden and global constructors will not be run.
107
108 This does mean that it is not possible for a user to define
109 their own __CTOR_LIST__ and __DTOR_LIST__ symbols. If that
110 ability is needed a custom linker script will have to be
111 used. (The custom script can just be a copy of this script
112 with the PROVIDE() qualifiers added).
113
114 See PR 22762 for more details. */
115 ___CTOR_LIST__ = .;
116 __CTOR_LIST__ = .;
ca6f2be7
NC
117 LONG (-1);
118 KEEP(*(.ctors));
119 KEEP(*(.ctor));
120 KEEP(*(SORT_BY_NAME(.ctors.*)));
121 LONG (0);
122 }
123 ${CONSTRUCTING+
b0daac83
NC
124 /* See comment about __CTOR_LIST__ above. The same reasoning
125 applies here too. */
126 ___DTOR_LIST__ = .;
127 __DTOR_LIST__ = .;
ca6f2be7
NC
128 LONG (-1);
129 KEEP(*(.dtors));
130 KEEP(*(.dtor));
131 KEEP(*(SORT_BY_NAME(.dtors.*)));
132 LONG (0);
133 }
aa785360 134 ${RELOCATING+ KEEP (*(.fini))}
252b5132
RH
135 /* ??? Why is .gcc_exc here? */
136 ${RELOCATING+ *(.gcc_exc)}
15c9f673 137 ${RELOCATING+PROVIDE (etext = .);}
ee8206a9 138 ${RELOCATING+PROVIDE (_etext = .);}
aa785360 139 ${RELOCATING+ KEEP (*(.gcc_except_table))}
252b5132
RH
140 }
141
142 /* The Cygwin32 library uses a section to avoid copying certain data
143 on fork. This used to be named ".data$nocopy". The linker used
144 to include this between __data_start__ and __data_end__, but that
145 breaks building the cygwin32 dll. Instead, we name the section
cc643b88 146 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
252b5132 147
5063daf7 148 .data ${RELOCATING+BLOCK(__section_alignment__)} :
252b5132
RH
149 {
150 ${RELOCATING+__data_start__ = . ;}
151 *(.data)
c48cfedd 152 ${RELOCATING+*(.data2)}
252b5132 153 ${R_DATA}
0f088b2a 154 KEEP(*(.jcr))
252b5132
RH
155 ${RELOCATING+__data_end__ = . ;}
156 ${RELOCATING+*(.data_cygwin_nocopy)}
157 }
158
be4514d3
ILT
159 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
160 {
be4514d3 161 ${R_RDATA}
730035f7 162 ${RELOCATING+__rt_psrelocs_start = .;}
c48cfedd 163 ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))}
730035f7 164 ${RELOCATING+__rt_psrelocs_end = .;}
be4514d3 165 }
730035f7
DK
166 ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
167 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
168 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
169 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
170 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
be4514d3 171
27505b5d
TG
172 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
173 {
c48cfedd 174 KEEP(*(.eh_frame${RELOCATING+*}))
27505b5d
TG
175 }
176
344a211f
NC
177 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
178 {
c48cfedd 179 KEEP(*(.pdata${RELOCATING+*}))
344a211f
NC
180 }
181
252b5132
RH
182 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
183 {
184 ${RELOCATING+__bss_start__ = . ;}
185 *(.bss)
186 *(COMMON)
187 ${RELOCATING+__bss_end__ = . ;}
188 }
189
252b5132
RH
190 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
191 {
192 *(.edata)
193 }
194
195 /DISCARD/ :
196 {
197 *(.debug\$S)
198 *(.debug\$T)
199 *(.debug\$F)
200 *(.drectve)
fecc36fd
KT
201 ${RELOCATING+ *(.note.GNU-stack)}
202 ${RELOCATING+ *(.gnu.lto_*)}
252b5132
RH
203 }
204
205 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
206 {
207 /* This cannot currently be handled with grouped sections.
208 See pe.em:sort_sections. */
d4874973
KT
209 ${R_IDATA234}
210 ${RELOCATING+__IAT_start__ = .;}
211 ${R_IDATA5}
212 ${RELOCATING+__IAT_end__ = .;}
213 ${R_IDATA67}
252b5132
RH
214 }
215 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
6c19b93b 216 {
552f8272
CF
217 ${RELOCATING+___crt_xc_start__ = . ;}
218 ${R_CRT_XC}
219 ${RELOCATING+___crt_xc_end__ = . ;}
220 ${RELOCATING+___crt_xi_start__ = . ;}
221 ${R_CRT_XI}
222 ${RELOCATING+___crt_xi_end__ = . ;}
223 ${RELOCATING+___crt_xl_start__ = . ;}
224 ${R_CRT_XL}
225 /* ___crt_xl_end__ is defined in the TLS Directory support code */
226 ${RELOCATING+___crt_xp_start__ = . ;}
227 ${R_CRT_XP}
228 ${RELOCATING+___crt_xp_end__ = . ;}
229 ${RELOCATING+___crt_xt_start__ = . ;}
230 ${R_CRT_XT}
231 ${RELOCATING+___crt_xt_end__ = . ;}
252b5132
RH
232 }
233
a988325c
NC
234 /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
235 at the end of section. This is important because _tls_start MUST
236 be at the beginning of the section to enable SECREL32 relocations with TLS
237 data. */
ca6dee30 238 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
6c19b93b 239 {
552f8272 240 ${RELOCATING+___tls_start__ = . ;}
ca6dee30 241 ${R_TLS}
552f8272 242 ${RELOCATING+___tls_end__ = . ;}
ca6dee30
NC
243 }
244
252b5132
RH
245 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
246 {
247 /* end is deprecated, don't use it */
15c9f673
CF
248 ${RELOCATING+PROVIDE (end = .);}
249 ${RELOCATING+PROVIDE ( _end = .);}
252b5132
RH
250 ${RELOCATING+ __end__ = .;}
251 }
252
1d63324c 253 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4)
5063daf7 254 {
252b5132
RH
255 ${R_RSRC}
256 }
257
be4514d3 258 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
5063daf7 259 {
be4514d3
ILT
260 *(.reloc)
261 }
262
252b5132
RH
263 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
264 {
8a7140c3 265 *(.stab)
252b5132
RH
266 }
267
268 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
269 {
8a7140c3 270 *(.stabstr)
252b5132
RH
271 }
272
8a7140c3
NC
273 /* DWARF debug sections.
274 Symbols in the DWARF debugging sections are relative to the beginning
275 of the section. Unlike other targets that fake this by putting the
276 section VMA at 0, the PE format will not allow it. */
5063daf7 277
8a7140c3
NC
278 /* DWARF 1.1 and DWARF 2. */
279 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
280 {
281 *(.debug_aranges)
282 }
a29a8af8
KT
283 .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
284 {
285 *(.zdebug_aranges)
286 }
8a7140c3
NC
287
288 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
289 {
290 *(.debug_pubnames)
291 }
a29a8af8
KT
292 .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
293 {
294 *(.zdebug_pubnames)
295 }
8a7140c3 296
22418005 297 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
a626fe20
KT
298 {
299 *(.debug_pubtypes)
300 }
a29a8af8
KT
301 .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
302 {
303 *(.zdebug_pubtypes)
304 }
a626fe20 305
8a7140c3
NC
306 /* DWARF 2. */
307 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
308 {
ebe9c501 309 *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
8a7140c3 310 }
a29a8af8
KT
311 .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
312 {
313 *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*})
314 }
8a7140c3
NC
315
316 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
317 {
318 *(.debug_abbrev)
319 }
a29a8af8
KT
320 .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
321 {
322 *(.zdebug_abbrev)
323 }
8a7140c3
NC
324
325 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
326 {
327 *(.debug_line)
328 }
a29a8af8
KT
329 .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
330 {
331 *(.zdebug_line)
332 }
8a7140c3
NC
333
334 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
335 {
72b016b4 336 *(.debug_frame*)
8a7140c3 337 }
a29a8af8
KT
338 .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
339 {
340 *(.zdebug_frame*)
341 }
8a7140c3
NC
342
343 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
344 {
345 *(.debug_str)
346 }
a29a8af8
KT
347 .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
348 {
349 *(.zdebug_str)
350 }
8a7140c3
NC
351
352 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
353 {
354 *(.debug_loc)
355 }
a29a8af8
KT
356 .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
357 {
358 *(.zdebug_loc)
359 }
8a7140c3
NC
360
361 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
362 {
363 *(.debug_macinfo)
364 }
a29a8af8
KT
365 .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
366 {
367 *(.zdebug_macinfo)
368 }
8a7140c3
NC
369
370 /* SGI/MIPS DWARF 2 extensions. */
371 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
372 {
373 *(.debug_weaknames)
374 }
a29a8af8
KT
375 .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
376 {
377 *(.zdebug_weaknames)
378 }
8a7140c3
NC
379
380 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
381 {
382 *(.debug_funcnames)
383 }
a29a8af8
KT
384 .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
385 {
386 *(.zdebug_funcnames)
387 }
8a7140c3
NC
388
389 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
390 {
391 *(.debug_typenames)
392 }
a29a8af8
KT
393 .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
394 {
395 *(.zdebug_typenames)
396 }
8a7140c3
NC
397
398 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
399 {
400 *(.debug_varnames)
401 }
a29a8af8
KT
402 .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
403 {
404 *(.zdebug_varnames)
405 }
8a7140c3 406
b990ad61
KT
407 .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
408 {
409 *(.debug_macro)
410 }
a29a8af8
KT
411 .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
412 {
413 *(.zdebug_macro)
414 }
b990ad61 415
8a7140c3
NC
416 /* DWARF 3. */
417 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
418 {
419 *(.debug_ranges)
420 }
a29a8af8
KT
421 .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
422 {
423 *(.zdebug_ranges)
424 }
802d4822
KT
425
426 /* DWARF 4. */
427 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
428 {
ebe9c501 429 *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
802d4822 430 }
a29a8af8
KT
431 .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
432 {
433 *(.zdebug_types${RELOCATING+ .gnu.linkonce.wt.*})
434 }
786e3eba
NC
435
436 /* For Go and Rust. */
437 .debug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
438 {
439 *(.debug_gdb_scripts)
440 }
441 .zdebug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
442 {
443 *(.zdebug_gdb_scripts)
444 }
252b5132
RH
445}
446EOF
This page took 0.788375 seconds and 4 git commands to generate.