]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/pe.sc
PR ld/12365
[thirdparty/binutils-gdb.git] / ld / scripttempl / pe.sc
CommitLineData
252b5132
RH
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='
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$*))'
46else
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=
55fi
56
57cat <<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
64SECTIONS
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.*)}
252b5132
RH
76 *(.glue_7t)
77 *(.glue_7)
78 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
3c17e4f7 79 LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); }
252b5132 80 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
3c17e4f7 81 LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); }
252b5132
RH
82 ${RELOCATING+ *(.fini)}
83 /* ??? Why is .gcc_exc here? */
84 ${RELOCATING+ *(.gcc_exc)}
15c9f673 85 ${RELOCATING+PROVIDE (etext = .);}
5f294ed6 86 ${RELOCATING+ *(.gcc_except_table)}
252b5132
RH
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 explictly include it after __data_end__. */
94
95 .data ${RELOCATING+BLOCK(__section_alignment__)} :
96 {
97 ${RELOCATING+__data_start__ = . ;}
98 *(.data)
99 *(.data2)
100 ${R_DATA}
02f80eef 101 *(.jcr)
252b5132
RH
102 ${RELOCATING+__data_end__ = . ;}
103 ${RELOCATING+*(.data_cygwin_nocopy)}
104 }
105
be4514d3
ILT
106 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
107 {
be4514d3 108 ${R_RDATA}
36379167
NC
109 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
110 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;}
ad5211be 111 *(.rdata_runtime_pseudo_reloc)
36379167
NC
112 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
113 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
be4514d3
ILT
114 }
115
27505b5d
TG
116 .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
117 {
72b016b4 118 *(.eh_frame*)
27505b5d
TG
119 }
120
344a211f
NC
121 .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
122 {
123 *(.pdata)
124 }
125
252b5132
RH
126 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
127 {
128 ${RELOCATING+__bss_start__ = . ;}
129 *(.bss)
130 *(COMMON)
131 ${RELOCATING+__bss_end__ = . ;}
132 }
133
252b5132
RH
134 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
135 {
136 *(.edata)
137 }
138
139 /DISCARD/ :
140 {
141 *(.debug\$S)
142 *(.debug\$T)
143 *(.debug\$F)
144 *(.drectve)
fecc36fd
KT
145 ${RELOCATING+ *(.note.GNU-stack)}
146 ${RELOCATING+ *(.gnu.lto_*)}
252b5132
RH
147 }
148
149 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
150 {
151 /* This cannot currently be handled with grouped sections.
152 See pe.em:sort_sections. */
d4874973
KT
153 ${R_IDATA234}
154 ${RELOCATING+__IAT_start__ = .;}
155 ${R_IDATA5}
156 ${RELOCATING+__IAT_end__ = .;}
157 ${R_IDATA67}
252b5132
RH
158 }
159 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
160 {
552f8272
CF
161 ${RELOCATING+___crt_xc_start__ = . ;}
162 ${R_CRT_XC}
163 ${RELOCATING+___crt_xc_end__ = . ;}
164 ${RELOCATING+___crt_xi_start__ = . ;}
165 ${R_CRT_XI}
166 ${RELOCATING+___crt_xi_end__ = . ;}
167 ${RELOCATING+___crt_xl_start__ = . ;}
168 ${R_CRT_XL}
169 /* ___crt_xl_end__ is defined in the TLS Directory support code */
170 ${RELOCATING+___crt_xp_start__ = . ;}
171 ${R_CRT_XP}
172 ${RELOCATING+___crt_xp_end__ = . ;}
173 ${RELOCATING+___crt_xt_start__ = . ;}
174 ${R_CRT_XT}
175 ${RELOCATING+___crt_xt_end__ = . ;}
252b5132
RH
176 }
177
ca6dee30
NC
178 .tls ${RELOCATING+BLOCK(__section_alignment__)} :
179 {
552f8272 180 ${RELOCATING+___tls_start__ = . ;}
ca6dee30 181 ${R_TLS}
552f8272 182 ${RELOCATING+___tls_end__ = . ;}
ca6dee30
NC
183 }
184
252b5132
RH
185 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
186 {
187 /* end is deprecated, don't use it */
15c9f673
CF
188 ${RELOCATING+PROVIDE (end = .);}
189 ${RELOCATING+PROVIDE ( _end = .);}
252b5132
RH
190 ${RELOCATING+ __end__ = .;}
191 }
192
252b5132
RH
193 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
194 {
195 *(.rsrc)
196 ${R_RSRC}
197 }
198
be4514d3
ILT
199 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
200 {
201 *(.reloc)
202 }
203
252b5132
RH
204 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
205 {
8a7140c3 206 *(.stab)
252b5132
RH
207 }
208
209 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
210 {
8a7140c3 211 *(.stabstr)
252b5132
RH
212 }
213
8a7140c3
NC
214 /* DWARF debug sections.
215 Symbols in the DWARF debugging sections are relative to the beginning
216 of the section. Unlike other targets that fake this by putting the
217 section VMA at 0, the PE format will not allow it. */
218
219 /* DWARF 1.1 and DWARF 2. */
220 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
221 {
222 *(.debug_aranges)
223 }
224
225 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
226 {
227 *(.debug_pubnames)
228 }
229
22418005 230 .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
a626fe20
KT
231 {
232 *(.debug_pubtypes)
233 }
234
8a7140c3
NC
235 /* DWARF 2. */
236 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
237 {
238 *(.debug_info) *(.gnu.linkonce.wi.*)
239 }
240
241 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
242 {
243 *(.debug_abbrev)
244 }
245
246 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
247 {
248 *(.debug_line)
249 }
250
251 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
252 {
72b016b4 253 *(.debug_frame*)
8a7140c3
NC
254 }
255
256 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
257 {
258 *(.debug_str)
259 }
260
261 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
262 {
263 *(.debug_loc)
264 }
265
266 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
267 {
268 *(.debug_macinfo)
269 }
270
271 /* SGI/MIPS DWARF 2 extensions. */
272 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
273 {
274 *(.debug_weaknames)
275 }
276
277 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
278 {
279 *(.debug_funcnames)
280 }
281
282 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
283 {
284 *(.debug_typenames)
285 }
286
287 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
288 {
289 *(.debug_varnames)
290 }
291
292 /* DWARF 3. */
293 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
294 {
295 *(.debug_ranges)
296 }
802d4822
KT
297
298 /* DWARF 4. */
299 .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
300 {
301 *(.debug_types) *(.gnu.linkonce.wt.*)
302 }
252b5132
RH
303}
304EOF