1 # Linker script for PE.
3 # Copyright (C) 2014-2016 Free Software Foundation, Inc.
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.
9 if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
10 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
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$*))
28 R_DATA='*(SORT(.data$*))'
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='KEEP (SORT(*)(.idata$5))'
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 */'
51 KEEP (*(SORT(.tls$*)))
68 /* Copyright (C) 2014-2016 Free Software Foundation, Inc.
70 Copying and distribution of this script, with or without modification,
71 are permitted in any medium without royalty provided the copyright
72 notice and this notice are preserved. */
74 ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
75 ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
76 ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
82 ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is}
83 ${RELOCATING+ lower than the target page size. */}
84 ${RELOCATING+. = SIZEOF_HEADERS;}
85 ${RELOCATING+. = ALIGN(__section_alignment__);}
86 .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
88 ${RELOCATING+ KEEP(*(.init))}
91 ${RELOCATING+ *(.text.*)}
92 ${RELOCATING+ *(.gnu.linkonce.t.*)}
95 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
96 LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); }
97 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
98 LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); }
99 ${RELOCATING+ *(.fini)}
100 /* ??? Why is .gcc_exc here? */
101 ${RELOCATING+ *(.gcc_exc)}
102 ${RELOCATING+PROVIDE (etext = .);}
103 ${RELOCATING+PROVIDE (_etext = .);}
104 ${RELOCATING+ *(.gcc_except_table)}
107 /* The Cygwin32 library uses a section to avoid copying certain data
108 on fork. This used to be named ".data$nocopy". The linker used
109 to include this between __data_start__ and __data_end__, but that
110 breaks building the cygwin32 dll. Instead, we name the section
111 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
113 .data ${RELOCATING+BLOCK(__section_alignment__)} :
115 ${RELOCATING+__data_start__ = . ;}
120 ${RELOCATING+__data_end__ = . ;}
121 ${RELOCATING+*(.data_cygwin_nocopy)}
124 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
127 ${RELOCATING+__rt_psrelocs_start = .;}
128 *(.rdata_runtime_pseudo_reloc)
129 ${RELOCATING+__rt_psrelocs_end = .;}
131 ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
132 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
133 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
134 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
135 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
137 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
142 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
147 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
149 ${RELOCATING+__bss_start__ = . ;}
152 ${RELOCATING+__bss_end__ = . ;}
155 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
166 ${RELOCATING+ *(.note.GNU-stack)}
167 ${RELOCATING+ *(.gnu.lto_*)}
170 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
172 /* This cannot currently be handled with grouped sections.
173 See pe.em:sort_sections. */
175 ${RELOCATING+__IAT_start__ = .;}
177 ${RELOCATING+__IAT_end__ = .;}
180 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
182 ${RELOCATING+___crt_xc_start__ = . ;}
184 ${RELOCATING+___crt_xc_end__ = . ;}
185 ${RELOCATING+___crt_xi_start__ = . ;}
187 ${RELOCATING+___crt_xi_end__ = . ;}
188 ${RELOCATING+___crt_xl_start__ = . ;}
190 /* ___crt_xl_end__ is defined in the TLS Directory support code */
191 ${RELOCATING+___crt_xp_start__ = . ;}
193 ${RELOCATING+___crt_xp_end__ = . ;}
194 ${RELOCATING+___crt_xt_start__ = . ;}
196 ${RELOCATING+___crt_xt_end__ = . ;}
199 /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
200 at the end of section. This is important because _tls_start MUST
201 be at the beginning of the section to enable SECREL32 relocations with TLS
203 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
205 ${RELOCATING+___tls_start__ = . ;}
207 ${RELOCATING+___tls_end__ = . ;}
210 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
212 /* end is deprecated, don't use it */
213 ${RELOCATING+PROVIDE (end = .);}
214 ${RELOCATING+PROVIDE ( _end = .);}
215 ${RELOCATING+ __end__ = .;}
218 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4)
223 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
228 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
233 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
238 /* DWARF debug sections.
239 Symbols in the DWARF debugging sections are relative to the beginning
240 of the section. Unlike other targets that fake this by putting the
241 section VMA at 0, the PE format will not allow it. */
243 /* DWARF 1.1 and DWARF 2. */
244 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
248 .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
253 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
257 .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
262 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
266 .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
272 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
274 *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
276 .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
278 *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*})
281 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
285 .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
290 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
294 .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
299 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
303 .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
308 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
312 .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
317 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
321 .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
326 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
330 .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
335 /* SGI/MIPS DWARF 2 extensions. */
336 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
340 .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
345 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
349 .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
354 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
358 .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
363 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
367 .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
372 .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
376 .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
382 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
386 .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
392 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
394 *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
396 .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
398 *(.zdebug_types${RELOCATING+ .gnu.linkonce.wt.*})