1 # Linker script for PE.
3 # Copyright (C) 2014 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$*))'
35 /* These zeroes mark the end of the import list. */
36 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
38 R_IDATA5='SORT(*)(.idata$5)'
42 R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */'
43 R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */'
44 R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */'
45 R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */'
46 R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */'
68 /* Copyright (C) 2014 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+ *(.init)}
91 ${RELOCATING+ *(.text.*)}
92 ${RELOCATING+ *(.gnu.linkonce.t.*)}
95 ${CONSTRUCTING+. = ALIGN(8);}
96 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
97 LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); LONG (0); }
98 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
99 LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); LONG (0); }
100 ${RELOCATING+ *(.fini)}
101 /* ??? Why is .gcc_exc here? */
102 ${RELOCATING+ *(.gcc_exc)}
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 .xdata ${RELOCATING+BLOCK(__section_alignment__)} :
152 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
154 ${RELOCATING+__bss_start__ = . ;}
157 ${RELOCATING+__bss_end__ = . ;}
160 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
171 ${RELOCATING+ *(.note.GNU-stack)}
172 ${RELOCATING+ *(.gnu.lto_*)}
175 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
177 /* This cannot currently be handled with grouped sections.
178 See pep.em:sort_sections. */
180 ${RELOCATING+__IAT_start__ = .;}
182 ${RELOCATING+__IAT_end__ = .;}
185 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
187 ${RELOCATING+___crt_xc_start__ = . ;}
189 ${RELOCATING+___crt_xc_end__ = . ;}
190 ${RELOCATING+___crt_xi_start__ = . ;}
192 ${RELOCATING+___crt_xi_end__ = . ;}
193 ${RELOCATING+___crt_xl_start__ = . ;}
195 /* ___crt_xl_end__ is defined in the TLS Directory support code */
196 ${RELOCATING+___crt_xp_start__ = . ;}
198 ${RELOCATING+___crt_xp_end__ = . ;}
199 ${RELOCATING+___crt_xt_start__ = . ;}
201 ${RELOCATING+___crt_xt_end__ = . ;}
204 /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
205 at the end of the .tls section. This is important because _tls_start MUST
206 be at the beginning of the section to enable SECREL32 relocations with TLS
208 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
210 ${RELOCATING+___tls_start__ = . ;}
212 ${RELOCATING+___tls_end__ = . ;}
215 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
217 /* end is deprecated, don't use it */
218 ${RELOCATING+PROVIDE (end = .);}
219 ${RELOCATING+PROVIDE ( _end = .);}
220 ${RELOCATING+ __end__ = .;}
223 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4)
228 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
233 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
238 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
243 /* DWARF debug sections.
244 Symbols in the DWARF debugging sections are relative to the beginning
245 of the section. Unlike other targets that fake this by putting the
246 section VMA at 0, the PE format will not allow it. */
248 /* DWARF 1.1 and DWARF 2. */
249 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
253 .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
258 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
262 .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
267 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
271 .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
277 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
279 *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
281 .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
283 *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*})
286 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
290 .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
295 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
299 .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
304 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
308 .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
313 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
317 .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
322 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
326 .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
331 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
335 .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
340 /* SGI/MIPS DWARF 2 extensions. */
341 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
345 .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
350 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
354 .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
359 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
363 .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
368 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
372 .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
377 .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
381 .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
387 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
391 .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
397 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
399 *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
401 .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
403 *(.zdebug_types${RELOCATING+ .zdebug.gnu.linkonce.wt.*})