]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/scripttempl/pep.sc
Add .debug_gdb_scripts section to PE linker scripts.
[thirdparty/binutils-gdb.git] / ld / scripttempl / pep.sc
1 # Linker script for PE.
2 #
3 # Copyright (C) 2014-2017 Free Software Foundation, Inc.
4 #
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.
8
9 if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
10 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
11 fi
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).
20 if test "${RELOCATING}"; then
21 R_TEXT='*(SORT(.text$*))'
22 if test "x$LD_FLAG" = "xauto_import" ; then
23 R_DATA='*(SORT(.data$*))
24 *(.rdata)
25 *(SORT(.rdata$*))'
26 R_RDATA=''
27 else
28 R_DATA='*(SORT(.data$*))'
29 R_RDATA='*(.rdata)
30 *(SORT(.rdata$*))'
31 fi
32 R_IDATA234='
33 KEEP (SORT(*)(.idata$2))
34 KEEP (SORT(*)(.idata$3))
35 /* These zeroes mark the end of the import list. */
36 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
37 KEEP (SORT(*)(.idata$4))'
38 R_IDATA5='SORT(*)(.idata$5)'
39 R_IDATA67='
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 */'
47 R_TLS='
48 KEEP (*(.tls$AAA))
49 KEEP (*(.tls))
50 KEEP (*(.tls$))
51 KEEP (*(SORT(.tls$*)))
52 KEEP (*(.tls$ZZZ))'
53 R_RSRC='
54 KEEP (*(.rsrc))
55 KEEP (*(.rsrc$*))'
56 else
57 R_TEXT=
58 R_DATA=
59 R_RDATA='*(.rdata)'
60 R_IDATA234=
61 R_IDATA5=
62 R_IDATA67=
63 R_CRT_XC=
64 R_CRT_XI=
65 R_CRT_XL=
66 R_CRT_XP=
67 R_CRT_XT=
68 R_TLS='*(.tls)'
69 R_RSRC='*(.rsrc)'
70 fi
71
72 cat <<EOF
73 /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
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
79 ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
80 ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
81 ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
82
83 ${LIB_SEARCH_DIRS}
84
85 SECTIONS
86 {
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__);}
91 .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
92 {
93 ${RELOCATING+ KEEP(*(.init))}
94 *(.text)
95 ${R_TEXT}
96 ${RELOCATING+ *(.text.*)}
97 ${RELOCATING+ *(.gnu.linkonce.t.*)}
98 ${RELOCATING+*(.glue_7t)}
99 ${RELOCATING+*(.glue_7)}
100 ${CONSTRUCTING+. = ALIGN(8);}
101 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
102 LONG (-1); LONG (-1);
103 KEEP (*(.ctors));
104 KEEP (*(.ctor));
105 KEEP (*(SORT(.ctors.*)));
106 LONG (0); LONG (0); }
107 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
108 LONG (-1); LONG (-1);
109 KEEP (*(.dtors));
110 KEEP (*(.dtor));
111 KEEP (*(SORT(.dtors.*)));
112 LONG (0); LONG (0); }
113 ${RELOCATING+ KEEP (*(.fini))}
114 /* ??? Why is .gcc_exc here? */
115 ${RELOCATING+ *(.gcc_exc)}
116 ${RELOCATING+PROVIDE (etext = .);}
117 ${RELOCATING+ KEEP (*(.gcc_except_table))}
118 }
119
120 /* The Cygwin32 library uses a section to avoid copying certain data
121 on fork. This used to be named ".data$nocopy". The linker used
122 to include this between __data_start__ and __data_end__, but that
123 breaks building the cygwin32 dll. Instead, we name the section
124 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
125
126 .data ${RELOCATING+BLOCK(__section_alignment__)} :
127 {
128 ${RELOCATING+__data_start__ = . ;}
129 *(.data)
130 ${RELOCATING+*(.data2)}
131 ${R_DATA}
132 KEEP(*(.jcr))
133 ${RELOCATING+__data_end__ = . ;}
134 ${RELOCATING+*(.data_cygwin_nocopy)}
135 }
136
137 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
138 {
139 ${R_RDATA}
140 ${RELOCATING+__rt_psrelocs_start = .;}
141 ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))}
142 ${RELOCATING+__rt_psrelocs_end = .;}
143 }
144 ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
145 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
146 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
147 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
148 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
149
150 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
151 {
152 KEEP (*(.eh_frame${RELOCATING+*}))
153 }
154
155 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
156 {
157 KEEP(*(.pdata${RELOCATING+*}))
158 }
159
160 .xdata ${RELOCATING+BLOCK(__section_alignment__)} :
161 {
162 KEEP(*(.xdata${RELOCATING+*}))
163 }
164
165 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
166 {
167 ${RELOCATING+__bss_start__ = . ;}
168 *(.bss)
169 *(COMMON)
170 ${RELOCATING+__bss_end__ = . ;}
171 }
172
173 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
174 {
175 *(.edata)
176 }
177
178 /DISCARD/ :
179 {
180 *(.debug\$S)
181 *(.debug\$T)
182 *(.debug\$F)
183 *(.drectve)
184 ${RELOCATING+ *(.note.GNU-stack)}
185 ${RELOCATING+ *(.gnu.lto_*)}
186 }
187
188 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
189 {
190 /* This cannot currently be handled with grouped sections.
191 See pep.em:sort_sections. */
192 ${R_IDATA234}
193 ${RELOCATING+__IAT_start__ = .;}
194 ${R_IDATA5}
195 ${RELOCATING+__IAT_end__ = .;}
196 ${R_IDATA67}
197 }
198 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
199 {
200 ${RELOCATING+___crt_xc_start__ = . ;}
201 ${R_CRT_XC}
202 ${RELOCATING+___crt_xc_end__ = . ;}
203 ${RELOCATING+___crt_xi_start__ = . ;}
204 ${R_CRT_XI}
205 ${RELOCATING+___crt_xi_end__ = . ;}
206 ${RELOCATING+___crt_xl_start__ = . ;}
207 ${R_CRT_XL}
208 /* ___crt_xl_end__ is defined in the TLS Directory support code */
209 ${RELOCATING+___crt_xp_start__ = . ;}
210 ${R_CRT_XP}
211 ${RELOCATING+___crt_xp_end__ = . ;}
212 ${RELOCATING+___crt_xt_start__ = . ;}
213 ${R_CRT_XT}
214 ${RELOCATING+___crt_xt_end__ = . ;}
215 }
216
217 /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
218 at the end of the .tls section. This is important because _tls_start MUST
219 be at the beginning of the section to enable SECREL32 relocations with TLS
220 data. */
221 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
222 {
223 ${RELOCATING+___tls_start__ = . ;}
224 ${R_TLS}
225 ${RELOCATING+___tls_end__ = . ;}
226 }
227
228 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
229 {
230 /* end is deprecated, don't use it */
231 ${RELOCATING+PROVIDE (end = .);}
232 ${RELOCATING+PROVIDE ( _end = .);}
233 ${RELOCATING+ __end__ = .;}
234 }
235
236 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4)
237 {
238 ${R_RSRC}
239 }
240
241 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
242 {
243 *(.reloc)
244 }
245
246 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
247 {
248 *(.stab)
249 }
250
251 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
252 {
253 *(.stabstr)
254 }
255
256 /* DWARF debug sections.
257 Symbols in the DWARF debugging sections are relative to the beginning
258 of the section. Unlike other targets that fake this by putting the
259 section VMA at 0, the PE format will not allow it. */
260
261 /* DWARF 1.1 and DWARF 2. */
262 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
263 {
264 *(.debug_aranges)
265 }
266 .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
267 {
268 *(.zdebug_aranges)
269 }
270
271 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
272 {
273 *(.debug_pubnames)
274 }
275 .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
276 {
277 *(.zdebug_pubnames)
278 }
279
280 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
281 {
282 *(.debug_pubtypes)
283 }
284 .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
285 {
286 *(.zdebug_pubtypes)
287 }
288
289 /* DWARF 2. */
290 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
291 {
292 *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
293 }
294 .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
295 {
296 *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*})
297 }
298
299 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
300 {
301 *(.debug_abbrev)
302 }
303 .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
304 {
305 *(.zdebug_abbrev)
306 }
307
308 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
309 {
310 *(.debug_line)
311 }
312 .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
313 {
314 *(.zdebug_line)
315 }
316
317 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
318 {
319 *(.debug_frame)
320 }
321 .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
322 {
323 *(.zdebug_frame)
324 }
325
326 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
327 {
328 *(.debug_str)
329 }
330 .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
331 {
332 *(.zdebug_str)
333 }
334
335 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
336 {
337 *(.debug_loc)
338 }
339 .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
340 {
341 *(.zdebug_loc)
342 }
343
344 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
345 {
346 *(.debug_macinfo)
347 }
348 .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
349 {
350 *(.zdebug_macinfo)
351 }
352
353 /* SGI/MIPS DWARF 2 extensions. */
354 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
355 {
356 *(.debug_weaknames)
357 }
358 .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
359 {
360 *(.zdebug_weaknames)
361 }
362
363 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
364 {
365 *(.debug_funcnames)
366 }
367 .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
368 {
369 *(.zdebug_funcnames)
370 }
371
372 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
373 {
374 *(.debug_typenames)
375 }
376 .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
377 {
378 *(.zdebug_typenames)
379 }
380
381 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
382 {
383 *(.debug_varnames)
384 }
385 .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
386 {
387 *(.zdebug_varnames)
388 }
389
390 .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
391 {
392 *(.debug_macro)
393 }
394 .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
395 {
396 *(.zdebug_macro)
397 }
398
399 /* DWARF 3. */
400 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
401 {
402 *(.debug_ranges)
403 }
404 .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
405 {
406 *(.zdebug_ranges)
407 }
408
409 /* DWARF 4. */
410 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
411 {
412 *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
413 }
414 .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
415 {
416 *(.zdebug_types${RELOCATING+ .zdebug.gnu.linkonce.wt.*})
417 }
418
419 /* For Go and Rust. */
420 .debug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
421 {
422 *(.debug_gdb_scripts)
423 }
424 .zdebug_gdb_scripts ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
425 {
426 *(.zdebug_gdb_scripts)
427 }
428 }
429 EOF