Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # Linker script for PE. |
2 | ||
3 | if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then | |
4 | RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
5 | fi | |
6 | ||
7 | # We can't easily and portably get an unquoted $ in a shell | |
8 | # substitution, so we do this instead. | |
9 | # Sorting of the .foo$* sections is required by the definition of | |
10 | # grouped sections in PE. | |
11 | # Sorting of the file names in R_IDATA is required by the | |
12 | # current implementation of dlltool (this could probably be changed to | |
13 | # use grouped sections instead). | |
14 | if test "${RELOCATING}"; then | |
15 | R_TEXT='*(SORT(.text$*))' | |
e2a83dd0 NC |
16 | if test "x$LD_FLAG" = "xauto_import" ; then |
17 | R_DATA='*(SORT(.data$*)) | |
18 | *(.rdata) | |
19 | *(SORT(.rdata$*))' | |
20 | R_RDATA='' | |
21 | else | |
22 | R_DATA='*(SORT(.data$*))' | |
23 | R_RDATA='*(.rdata) | |
24 | *(SORT(.rdata$*))' | |
25 | fi | |
d4874973 | 26 | R_IDATA234=' |
252b5132 RH |
27 | SORT(*)(.idata$2) |
28 | SORT(*)(.idata$3) | |
29 | /* These zeroes mark the end of the import list. */ | |
30 | LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); | |
d4874973 KT |
31 | SORT(*)(.idata$4)' |
32 | R_IDATA5='SORT(*)(.idata$5)' | |
33 | R_IDATA67=' | |
252b5132 RH |
34 | SORT(*)(.idata$6) |
35 | SORT(*)(.idata$7)' | |
552f8272 CF |
36 | R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' |
37 | R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' | |
38 | R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' | |
39 | R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' | |
40 | R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' | |
ca6dee30 NC |
41 | R_TLS=' |
42 | *(.tls) | |
43 | *(.tls$) | |
44 | *(SORT(.tls$*))' | |
252b5132 RH |
45 | R_RSRC='*(SORT(.rsrc$*))' |
46 | else | |
47 | R_TEXT= | |
48 | R_DATA= | |
e2a83dd0 | 49 | R_RDATA='*(.rdata)' |
d4874973 KT |
50 | R_IDATA234= |
51 | R_IDATA5= | |
52 | R_IDATA67= | |
252b5132 RH |
53 | R_CRT= |
54 | R_RSRC= | |
55 | fi | |
56 | ||
57 | cat <<EOF | |
58 | ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} | |
59 | ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} | |
c6c37250 | 60 | ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} |
252b5132 RH |
61 | |
62 | ${LIB_SEARCH_DIRS} | |
63 | ||
252b5132 RH |
64 | SECTIONS |
65 | { | |
03098a9a CF |
66 | ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} |
67 | ${RELOCATING+ lower than the target page size. */} | |
68 | ${RELOCATING+. = SIZEOF_HEADERS;} | |
69 | ${RELOCATING+. = ALIGN(__section_alignment__);} | |
70 | .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : | |
252b5132 RH |
71 | { |
72 | ${RELOCATING+ *(.init)} | |
73 | *(.text) | |
74 | ${R_TEXT} | |
032f3e01 | 75 | ${RELOCATING+ *(.text.*)} |
ebe9c501 | 76 | ${RELOCATING+ *(.gnu.linkonce.t.*)} |
252b5132 RH |
77 | *(.glue_7t) |
78 | *(.glue_7) | |
79 | ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; | |
3c17e4f7 | 80 | LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); } |
252b5132 | 81 | ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
3c17e4f7 | 82 | LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); } |
252b5132 RH |
83 | ${RELOCATING+ *(.fini)} |
84 | /* ??? Why is .gcc_exc here? */ | |
85 | ${RELOCATING+ *(.gcc_exc)} | |
15c9f673 | 86 | ${RELOCATING+PROVIDE (etext = .);} |
5f294ed6 | 87 | ${RELOCATING+ *(.gcc_except_table)} |
252b5132 RH |
88 | } |
89 | ||
90 | /* The Cygwin32 library uses a section to avoid copying certain data | |
91 | on fork. This used to be named ".data$nocopy". The linker used | |
92 | to include this between __data_start__ and __data_end__, but that | |
93 | breaks building the cygwin32 dll. Instead, we name the section | |
cc643b88 | 94 | ".data_cygwin_nocopy" and explicitly include it after __data_end__. */ |
252b5132 RH |
95 | |
96 | .data ${RELOCATING+BLOCK(__section_alignment__)} : | |
97 | { | |
98 | ${RELOCATING+__data_start__ = . ;} | |
99 | *(.data) | |
100 | *(.data2) | |
101 | ${R_DATA} | |
02f80eef | 102 | *(.jcr) |
252b5132 RH |
103 | ${RELOCATING+__data_end__ = . ;} |
104 | ${RELOCATING+*(.data_cygwin_nocopy)} | |
105 | } | |
106 | ||
be4514d3 ILT |
107 | .rdata ${RELOCATING+BLOCK(__section_alignment__)} : |
108 | { | |
be4514d3 | 109 | ${R_RDATA} |
730035f7 | 110 | ${RELOCATING+__rt_psrelocs_start = .;} |
ad5211be | 111 | *(.rdata_runtime_pseudo_reloc) |
730035f7 | 112 | ${RELOCATING+__rt_psrelocs_end = .;} |
be4514d3 | 113 | } |
730035f7 DK |
114 | ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;} |
115 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
116 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
117 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} | |
118 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} | |
be4514d3 | 119 | |
27505b5d TG |
120 | .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : |
121 | { | |
72b016b4 | 122 | *(.eh_frame*) |
27505b5d TG |
123 | } |
124 | ||
344a211f NC |
125 | .pdata ${RELOCATING+BLOCK(__section_alignment__)} : |
126 | { | |
127 | *(.pdata) | |
128 | } | |
129 | ||
252b5132 RH |
130 | .bss ${RELOCATING+BLOCK(__section_alignment__)} : |
131 | { | |
132 | ${RELOCATING+__bss_start__ = . ;} | |
133 | *(.bss) | |
134 | *(COMMON) | |
135 | ${RELOCATING+__bss_end__ = . ;} | |
136 | } | |
137 | ||
252b5132 RH |
138 | .edata ${RELOCATING+BLOCK(__section_alignment__)} : |
139 | { | |
140 | *(.edata) | |
141 | } | |
142 | ||
143 | /DISCARD/ : | |
144 | { | |
145 | *(.debug\$S) | |
146 | *(.debug\$T) | |
147 | *(.debug\$F) | |
148 | *(.drectve) | |
fecc36fd KT |
149 | ${RELOCATING+ *(.note.GNU-stack)} |
150 | ${RELOCATING+ *(.gnu.lto_*)} | |
252b5132 RH |
151 | } |
152 | ||
153 | .idata ${RELOCATING+BLOCK(__section_alignment__)} : | |
154 | { | |
155 | /* This cannot currently be handled with grouped sections. | |
156 | See pe.em:sort_sections. */ | |
d4874973 KT |
157 | ${R_IDATA234} |
158 | ${RELOCATING+__IAT_start__ = .;} | |
159 | ${R_IDATA5} | |
160 | ${RELOCATING+__IAT_end__ = .;} | |
161 | ${R_IDATA67} | |
252b5132 RH |
162 | } |
163 | .CRT ${RELOCATING+BLOCK(__section_alignment__)} : | |
164 | { | |
552f8272 CF |
165 | ${RELOCATING+___crt_xc_start__ = . ;} |
166 | ${R_CRT_XC} | |
167 | ${RELOCATING+___crt_xc_end__ = . ;} | |
168 | ${RELOCATING+___crt_xi_start__ = . ;} | |
169 | ${R_CRT_XI} | |
170 | ${RELOCATING+___crt_xi_end__ = . ;} | |
171 | ${RELOCATING+___crt_xl_start__ = . ;} | |
172 | ${R_CRT_XL} | |
173 | /* ___crt_xl_end__ is defined in the TLS Directory support code */ | |
174 | ${RELOCATING+___crt_xp_start__ = . ;} | |
175 | ${R_CRT_XP} | |
176 | ${RELOCATING+___crt_xp_end__ = . ;} | |
177 | ${RELOCATING+___crt_xt_start__ = . ;} | |
178 | ${R_CRT_XT} | |
179 | ${RELOCATING+___crt_xt_end__ = . ;} | |
252b5132 RH |
180 | } |
181 | ||
ca6dee30 NC |
182 | .tls ${RELOCATING+BLOCK(__section_alignment__)} : |
183 | { | |
552f8272 | 184 | ${RELOCATING+___tls_start__ = . ;} |
ca6dee30 | 185 | ${R_TLS} |
552f8272 | 186 | ${RELOCATING+___tls_end__ = . ;} |
ca6dee30 NC |
187 | } |
188 | ||
252b5132 RH |
189 | .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : |
190 | { | |
191 | /* end is deprecated, don't use it */ | |
15c9f673 CF |
192 | ${RELOCATING+PROVIDE (end = .);} |
193 | ${RELOCATING+PROVIDE ( _end = .);} | |
252b5132 RH |
194 | ${RELOCATING+ __end__ = .;} |
195 | } | |
196 | ||
252b5132 RH |
197 | .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : |
198 | { | |
199 | *(.rsrc) | |
200 | ${R_RSRC} | |
201 | } | |
202 | ||
be4514d3 ILT |
203 | .reloc ${RELOCATING+BLOCK(__section_alignment__)} : |
204 | { | |
205 | *(.reloc) | |
206 | } | |
207 | ||
252b5132 RH |
208 | .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
209 | { | |
8a7140c3 | 210 | *(.stab) |
252b5132 RH |
211 | } |
212 | ||
213 | .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
214 | { | |
8a7140c3 | 215 | *(.stabstr) |
252b5132 RH |
216 | } |
217 | ||
8a7140c3 NC |
218 | /* DWARF debug sections. |
219 | Symbols in the DWARF debugging sections are relative to the beginning | |
220 | of the section. Unlike other targets that fake this by putting the | |
221 | section VMA at 0, the PE format will not allow it. */ | |
222 | ||
223 | /* DWARF 1.1 and DWARF 2. */ | |
224 | .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
225 | { | |
226 | *(.debug_aranges) | |
227 | } | |
228 | ||
229 | .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
230 | { | |
231 | *(.debug_pubnames) | |
232 | } | |
233 | ||
22418005 | 234 | .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
a626fe20 KT |
235 | { |
236 | *(.debug_pubtypes) | |
237 | } | |
238 | ||
8a7140c3 NC |
239 | /* DWARF 2. */ |
240 | .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
241 | { | |
ebe9c501 | 242 | *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) |
8a7140c3 NC |
243 | } |
244 | ||
245 | .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
246 | { | |
247 | *(.debug_abbrev) | |
248 | } | |
249 | ||
250 | .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
251 | { | |
252 | *(.debug_line) | |
253 | } | |
254 | ||
255 | .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
256 | { | |
72b016b4 | 257 | *(.debug_frame*) |
8a7140c3 NC |
258 | } |
259 | ||
260 | .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
261 | { | |
262 | *(.debug_str) | |
263 | } | |
264 | ||
265 | .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
266 | { | |
267 | *(.debug_loc) | |
268 | } | |
269 | ||
270 | .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
271 | { | |
272 | *(.debug_macinfo) | |
273 | } | |
274 | ||
275 | /* SGI/MIPS DWARF 2 extensions. */ | |
276 | .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
277 | { | |
278 | *(.debug_weaknames) | |
279 | } | |
280 | ||
281 | .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
282 | { | |
283 | *(.debug_funcnames) | |
284 | } | |
285 | ||
286 | .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
287 | { | |
288 | *(.debug_typenames) | |
289 | } | |
290 | ||
291 | .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
292 | { | |
293 | *(.debug_varnames) | |
294 | } | |
295 | ||
b990ad61 KT |
296 | .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
297 | { | |
298 | *(.debug_macro) | |
299 | } | |
300 | ||
8a7140c3 NC |
301 | /* DWARF 3. */ |
302 | .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
303 | { | |
304 | *(.debug_ranges) | |
305 | } | |
802d4822 KT |
306 | |
307 | /* DWARF 4. */ | |
308 | .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
309 | { | |
ebe9c501 | 310 | *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*}) |
802d4822 | 311 | } |
252b5132 RH |
312 | } |
313 | EOF |