ChangeLog gas
[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_IDATA='
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 SORT(*)(.idata$5)
33 SORT(*)(.idata$6)
34 SORT(*)(.idata$7)'
35 R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */'
36 R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */'
37 R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */'
38 R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */'
39 R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */'
40 R_TLS='
41 *(.tls)
42 *(.tls$)
43 *(SORT(.tls$*))'
44 R_RSRC='*(SORT(.rsrc$*))'
45 else
46 R_TEXT=
47 R_DATA=
48 R_RDATA='*(.rdata)'
49 R_IDATA=
50 R_CRT=
51 R_RSRC=
52 fi
53
54 cat <<EOF
55 ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
56 ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
57 ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
58
59 ${LIB_SEARCH_DIRS}
60
61 SECTIONS
62 {
63 ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is}
64 ${RELOCATING+ lower than the target page size. */}
65 ${RELOCATING+. = SIZEOF_HEADERS;}
66 ${RELOCATING+. = ALIGN(__section_alignment__);}
67 .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
68 {
69 ${RELOCATING+ *(.init)}
70 *(.text)
71 ${R_TEXT}
72 ${RELOCATING+ *(.text.*)}
73 *(.glue_7t)
74 *(.glue_7)
75 ${CONSTRUCTING+. = ALIGN(8);}
76 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
77 LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); LONG (0); }
78 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
79 LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); LONG (0); }
80 ${RELOCATING+ *(.fini)}
81 /* ??? Why is .gcc_exc here? */
82 ${RELOCATING+ *(.gcc_exc)}
83 ${RELOCATING+PROVIDE (etext = .);}
84 ${RELOCATING+ *(.gcc_except_table)}
85 }
86
87 /* The Cygwin32 library uses a section to avoid copying certain data
88 on fork. This used to be named ".data$nocopy". The linker used
89 to include this between __data_start__ and __data_end__, but that
90 breaks building the cygwin32 dll. Instead, we name the section
91 ".data_cygwin_nocopy" and explictly include it after __data_end__. */
92
93 .data ${RELOCATING+BLOCK(__section_alignment__)} :
94 {
95 ${RELOCATING+__data_start__ = . ;}
96 *(.data)
97 *(.data2)
98 ${R_DATA}
99 *(.jcr)
100 ${RELOCATING+__data_end__ = . ;}
101 ${RELOCATING+*(.data_cygwin_nocopy)}
102 }
103
104 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
105 {
106 ${R_RDATA}
107 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
108 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;}
109 *(.rdata_runtime_pseudo_reloc)
110 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
111 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
112 }
113
114 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
115 {
116 *(.eh_frame)
117 }
118
119 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
120 {
121 *(.pdata*)
122 }
123
124 .xdata ${RELOCATING+BLOCK(__section_alignment__)} :
125 {
126 *(.xdata*)
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 pep.em:sort_sections. */
156 ${R_IDATA}
157 }
158 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
159 {
160 ${RELOCATING+___crt_xc_start__ = . ;}
161 ${R_CRT_XC}
162 ${RELOCATING+___crt_xc_end__ = . ;}
163 ${RELOCATING+___crt_xi_start__ = . ;}
164 ${R_CRT_XI}
165 ${RELOCATING+___crt_xi_end__ = . ;}
166 ${RELOCATING+___crt_xl_start__ = . ;}
167 ${R_CRT_XL}
168 /* ___crt_xl_end__ is defined in the TLS Directory support code */
169 ${RELOCATING+___crt_xp_start__ = . ;}
170 ${R_CRT_XP}
171 ${RELOCATING+___crt_xp_end__ = . ;}
172 ${RELOCATING+___crt_xt_start__ = . ;}
173 ${R_CRT_XT}
174 ${RELOCATING+___crt_xt_end__ = . ;}
175 }
176
177 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
178 {
179 ${RELOCATING+___tls_start__ = . ;}
180 ${R_TLS}
181 ${RELOCATING+___tls_end__ = . ;}
182 }
183
184 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
185 {
186 /* end is deprecated, don't use it */
187 ${RELOCATING+PROVIDE (end = .);}
188 ${RELOCATING+PROVIDE ( _end = .);}
189 ${RELOCATING+ __end__ = .;}
190 }
191
192 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
193 {
194 *(.rsrc)
195 ${R_RSRC}
196 }
197
198 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
199 {
200 *(.reloc)
201 }
202
203 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
204 {
205 *(.stab)
206 }
207
208 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
209 {
210 *(.stabstr)
211 }
212
213 /* DWARF debug sections.
214 Symbols in the DWARF debugging sections are relative to the beginning
215 of the section. Unlike other targets that fake this by putting the
216 section VMA at 0, the PE format will not allow it. */
217
218 /* DWARF 1.1 and DWARF 2. */
219 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
220 {
221 *(.debug_aranges)
222 }
223
224 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
225 {
226 *(.debug_pubnames)
227 }
228
229 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
230 {
231 *(.debug_pubtypes)
232 }
233
234 /* DWARF 2. */
235 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
236 {
237 *(.debug_info) *(.gnu.linkonce.wi.*)
238 }
239
240 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
241 {
242 *(.debug_abbrev)
243 }
244
245 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
246 {
247 *(.debug_line)
248 }
249
250 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
251 {
252 *(.debug_frame)
253 }
254
255 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
256 {
257 *(.debug_str)
258 }
259
260 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
261 {
262 *(.debug_loc)
263 }
264
265 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
266 {
267 *(.debug_macinfo)
268 }
269
270 /* SGI/MIPS DWARF 2 extensions. */
271 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
272 {
273 *(.debug_weaknames)
274 }
275
276 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
277 {
278 *(.debug_funcnames)
279 }
280
281 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
282 {
283 *(.debug_typenames)
284 }
285
286 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
287 {
288 *(.debug_varnames)
289 }
290
291 /* DWARF 3. */
292 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
293 {
294 *(.debug_ranges)
295 }
296 }
297 EOF