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