* pe-dll.c (auto_export): Use bsearch to speed up scan of exports
[deliverable/binutils-gdb.git] / ld / scripttempl / pep.sc
CommitLineData
99ad8390
NC
1# Linker script for PE.
2
3if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
4 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
5fi
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).
14if 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='
99ad8390
NC
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='
99ad8390
NC
34 SORT(*)(.idata$6)
35 SORT(*)(.idata$7)'
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 */'
41 R_TLS='
42 *(.tls)
43 *(.tls$)
44 *(SORT(.tls$*))'
45 R_RSRC='*(SORT(.rsrc$*))'
46else
47 R_TEXT=
48 R_DATA=
e2a83dd0 49 R_RDATA='*(.rdata)'
d4874973
KT
50 R_IDATA234=
51 R_IDATA5=
52 R_IDATA67=
99ad8390
NC
53 R_CRT=
54 R_RSRC=
55fi
56
57cat <<EOF
58${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
59${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
60${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
61
62${LIB_SEARCH_DIRS}
63
64SECTIONS
65{
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__ )} :
71 {
72 ${RELOCATING+ *(.init)}
73 *(.text)
74 ${R_TEXT}
032f3e01 75 ${RELOCATING+ *(.text.*)}
ebe9c501 76 ${RELOCATING+ *(.gnu.linkonce.t.*)}
99ad8390
NC
77 *(.glue_7t)
78 *(.glue_7)
da6fa31a 79 ${CONSTRUCTING+. = ALIGN(8);}
99ad8390 80 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
9b996610 81 LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); LONG (0); }
99ad8390 82 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
9b996610 83 LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); LONG (0); }
99ad8390
NC
84 ${RELOCATING+ *(.fini)}
85 /* ??? Why is .gcc_exc here? */
86 ${RELOCATING+ *(.gcc_exc)}
87 ${RELOCATING+PROVIDE (etext = .);}
5f294ed6 88 ${RELOCATING+ *(.gcc_except_table)}
99ad8390
NC
89 }
90
91 /* The Cygwin32 library uses a section to avoid copying certain data
92 on fork. This used to be named ".data$nocopy". The linker used
93 to include this between __data_start__ and __data_end__, but that
94 breaks building the cygwin32 dll. Instead, we name the section
cc643b88 95 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
99ad8390
NC
96
97 .data ${RELOCATING+BLOCK(__section_alignment__)} :
98 {
99 ${RELOCATING+__data_start__ = . ;}
100 *(.data)
101 *(.data2)
102 ${R_DATA}
103 *(.jcr)
104 ${RELOCATING+__data_end__ = . ;}
105 ${RELOCATING+*(.data_cygwin_nocopy)}
106 }
107
108 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
109 {
99ad8390 110 ${R_RDATA}
730035f7 111 ${RELOCATING+__rt_psrelocs_start = .;}
99ad8390 112 *(.rdata_runtime_pseudo_reloc)
730035f7 113 ${RELOCATING+__rt_psrelocs_end = .;}
99ad8390 114 }
730035f7
DK
115 ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
116 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
117 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
118 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
119 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
99ad8390 120
27505b5d
TG
121 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
122 {
72b016b4 123 *(.eh_frame*)
27505b5d
TG
124 }
125
99ad8390
NC
126 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
127 {
2d7f4929
KT
128 *(.pdata*)
129 }
130
131 .xdata ${RELOCATING+BLOCK(__section_alignment__)} :
132 {
133 *(.xdata*)
99ad8390
NC
134 }
135
136 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
137 {
138 ${RELOCATING+__bss_start__ = . ;}
139 *(.bss)
140 *(COMMON)
141 ${RELOCATING+__bss_end__ = . ;}
142 }
143
144 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
145 {
146 *(.edata)
147 }
148
149 /DISCARD/ :
150 {
151 *(.debug\$S)
152 *(.debug\$T)
153 *(.debug\$F)
154 *(.drectve)
fecc36fd
KT
155 ${RELOCATING+ *(.note.GNU-stack)}
156 ${RELOCATING+ *(.gnu.lto_*)}
99ad8390
NC
157 }
158
159 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
160 {
161 /* This cannot currently be handled with grouped sections.
162 See pep.em:sort_sections. */
d4874973
KT
163 ${R_IDATA234}
164 ${RELOCATING+__IAT_start__ = .;}
165 ${R_IDATA5}
166 ${RELOCATING+__IAT_end__ = .;}
167 ${R_IDATA67}
99ad8390
NC
168 }
169 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
170 {
171 ${RELOCATING+___crt_xc_start__ = . ;}
172 ${R_CRT_XC}
173 ${RELOCATING+___crt_xc_end__ = . ;}
174 ${RELOCATING+___crt_xi_start__ = . ;}
175 ${R_CRT_XI}
176 ${RELOCATING+___crt_xi_end__ = . ;}
177 ${RELOCATING+___crt_xl_start__ = . ;}
178 ${R_CRT_XL}
179 /* ___crt_xl_end__ is defined in the TLS Directory support code */
180 ${RELOCATING+___crt_xp_start__ = . ;}
181 ${R_CRT_XP}
182 ${RELOCATING+___crt_xp_end__ = . ;}
183 ${RELOCATING+___crt_xt_start__ = . ;}
184 ${R_CRT_XT}
185 ${RELOCATING+___crt_xt_end__ = . ;}
186 }
187
188 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
189 {
190 ${RELOCATING+___tls_start__ = . ;}
191 ${R_TLS}
192 ${RELOCATING+___tls_end__ = . ;}
193 }
194
195 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
196 {
197 /* end is deprecated, don't use it */
198 ${RELOCATING+PROVIDE (end = .);}
199 ${RELOCATING+PROVIDE ( _end = .);}
200 ${RELOCATING+ __end__ = .;}
201 }
202
203 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
204 {
205 *(.rsrc)
206 ${R_RSRC}
207 }
208
209 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
210 {
211 *(.reloc)
212 }
213
214 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
215 {
216 *(.stab)
217 }
218
219 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
220 {
221 *(.stabstr)
222 }
223
224 /* DWARF debug sections.
225 Symbols in the DWARF debugging sections are relative to the beginning
226 of the section. Unlike other targets that fake this by putting the
227 section VMA at 0, the PE format will not allow it. */
228
229 /* DWARF 1.1 and DWARF 2. */
230 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
231 {
232 *(.debug_aranges)
233 }
234
235 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
236 {
237 *(.debug_pubnames)
238 }
239
22418005 240 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
a626fe20
KT
241 {
242 *(.debug_pubtypes)
243 }
244
99ad8390
NC
245 /* DWARF 2. */
246 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
247 {
ebe9c501 248 *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
99ad8390
NC
249 }
250
251 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
252 {
253 *(.debug_abbrev)
254 }
255
256 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
257 {
258 *(.debug_line)
259 }
260
261 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
262 {
72b016b4 263 *(.debug_frame*)
99ad8390
NC
264 }
265
266 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
267 {
268 *(.debug_str)
269 }
270
271 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
272 {
273 *(.debug_loc)
274 }
275
276 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
277 {
278 *(.debug_macinfo)
279 }
280
281 /* SGI/MIPS DWARF 2 extensions. */
282 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
283 {
284 *(.debug_weaknames)
285 }
286
287 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
288 {
289 *(.debug_funcnames)
290 }
291
292 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
293 {
294 *(.debug_typenames)
295 }
296
297 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
298 {
299 *(.debug_varnames)
300 }
301
b990ad61
KT
302 .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
303 {
304 *(.debug_macro)
305 }
306
99ad8390
NC
307 /* DWARF 3. */
308 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
309 {
310 *(.debug_ranges)
311 }
802d4822
KT
312
313 /* DWARF 4. */
314 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
315 {
ebe9c501 316 *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
802d4822 317 }
99ad8390
NC
318}
319EOF
This page took 0.243977 seconds and 4 git commands to generate.