1 # Linker script for PE.
3 # Copyright (C) 2014-2025 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 if test "${RELOCATING}"; then
22 /* These zeroes mark the end of the import list. */
23 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
42 /* Copyright (C) 2014-2025 Free Software Foundation, Inc.
44 Copying and distribution of this script, with or without modification,
45 are permitted in any medium without royalty provided the copyright
46 notice and this notice are preserved. */
48 ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
49 ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
53 ${RELOCATING+ENTRY (__start)}
54 ${RELOCATING+header = .;}
55 ${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */}
56 ${RELOCATING+__ldused = .;}
59 .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
61 ${RELOCATING+ __text_start__ = . ;}
62 ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
67 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
68 LONG (-1); *(.ctors); *(.ctor); LONG (0); }
69 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
70 LONG (-1); *(.dtors); *(.dtor); LONG (0); }
71 ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
72 ${RELOCATING+/* ??? Why is .gcc_exc here? */}
73 ${RELOCATING+ *(.gcc_exc)}
74 ${RELOCATING+ etext = .;}
75 ${RELOCATING+ __text_end__ = .;}
79 /* The Cygwin32 library uses a section to avoid copying certain data
80 on fork. This used to be named ".data$nocopy". The linker used
81 to include this between __data_start__ and __data_end__, but that
82 breaks building the cygwin32 dll. Instead, we name the section
83 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
85 .data ${RELOCATING+BLOCK(__section_alignment__)} :
87 ${RELOCATING+__data_start__ = . ;}
91 ${RELOCATING+__data_end__ = . ;}
92 ${RELOCATING+*(.data_cygwin_nocopy)}
95 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
97 ${RELOCATING+__bss_start__ = . ;}
100 /* link.exe apparently pulls in .obj's because of UNDEF common
101 symbols, which is not the coff way, but that's MS for you. */
106 ${RELOCATING+__bss_end__ = . ;}
109 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
116 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
130 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
132 /* This cannot currently be handled with grouped sections.
133 See pe.em:sort_sections. */
136 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
141 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
143 /* end is deprecated, don't use it */
144 ${RELOCATING+ end = .;}
145 ${RELOCATING+ _end = .;}
146 ${RELOCATING+ __end__ = .;}
149 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
154 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
160 .exc ${RELOCATING+BLOCK(__section_alignment__)} :
166 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
171 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
177 source_sh $srcdir/scripttempl/DWARF.sc