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