Commit | Line | Data |
---|---|---|
252b5132 RH |
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 | R_DATA='*(SORT(.data$*))' | |
17 | R_RDATA='*(SORT(.rdata$*))' | |
18 | R_IDATA=' | |
19 | SORT(*)(.idata$2) | |
20 | SORT(*)(.idata$3) | |
21 | /* These zeroes mark the end of the import list. */ | |
22 | LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); | |
23 | SORT(*)(.idata$4) | |
24 | SORT(*)(.idata$5) | |
25 | SORT(*)(.idata$6) | |
26 | SORT(*)(.idata$7)' | |
552f8272 CF |
27 | R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' |
28 | R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' | |
29 | R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' | |
30 | R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' | |
31 | R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' | |
ca6dee30 NC |
32 | R_TLS=' |
33 | *(.tls) | |
34 | *(.tls$) | |
35 | *(SORT(.tls$*))' | |
252b5132 RH |
36 | R_RSRC='*(SORT(.rsrc$*))' |
37 | else | |
38 | R_TEXT= | |
39 | R_DATA= | |
40 | R_RDATA= | |
41 | R_IDATA= | |
42 | R_CRT= | |
43 | R_RSRC= | |
44 | fi | |
45 | ||
46 | cat <<EOF | |
47 | ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} | |
48 | ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} | |
c6c37250 | 49 | ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} |
252b5132 RH |
50 | |
51 | ${LIB_SEARCH_DIRS} | |
52 | ||
be4514d3 | 53 | ENTRY(${ENTRY}) |
252b5132 RH |
54 | |
55 | SECTIONS | |
56 | { | |
03098a9a CF |
57 | ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} |
58 | ${RELOCATING+ lower than the target page size. */} | |
59 | ${RELOCATING+. = SIZEOF_HEADERS;} | |
60 | ${RELOCATING+. = ALIGN(__section_alignment__);} | |
61 | .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : | |
252b5132 RH |
62 | { |
63 | ${RELOCATING+ *(.init)} | |
64 | *(.text) | |
65 | ${R_TEXT} | |
66 | *(.glue_7t) | |
67 | *(.glue_7) | |
68 | ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; | |
3c17e4f7 | 69 | LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); } |
252b5132 | 70 | ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
3c17e4f7 | 71 | LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); } |
252b5132 RH |
72 | ${RELOCATING+ *(.fini)} |
73 | /* ??? Why is .gcc_exc here? */ | |
74 | ${RELOCATING+ *(.gcc_exc)} | |
15c9f673 | 75 | ${RELOCATING+PROVIDE (etext = .);} |
252b5132 RH |
76 | *(.gcc_except_table) |
77 | } | |
78 | ||
79 | /* The Cygwin32 library uses a section to avoid copying certain data | |
80 | on fork. This used to be named ".data$nocopy". The linker used | |
81 | to include this between __data_start__ and __data_end__, but that | |
82 | breaks building the cygwin32 dll. Instead, we name the section | |
83 | ".data_cygwin_nocopy" and explictly include it after __data_end__. */ | |
84 | ||
85 | .data ${RELOCATING+BLOCK(__section_alignment__)} : | |
86 | { | |
87 | ${RELOCATING+__data_start__ = . ;} | |
88 | *(.data) | |
89 | *(.data2) | |
90 | ${R_DATA} | |
02f80eef | 91 | *(.jcr) |
252b5132 RH |
92 | ${RELOCATING+__data_end__ = . ;} |
93 | ${RELOCATING+*(.data_cygwin_nocopy)} | |
94 | } | |
95 | ||
be4514d3 ILT |
96 | .rdata ${RELOCATING+BLOCK(__section_alignment__)} : |
97 | { | |
98 | *(.rdata) | |
99 | ${R_RDATA} | |
100 | *(.eh_frame) | |
36379167 NC |
101 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} |
102 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} | |
ad5211be | 103 | *(.rdata_runtime_pseudo_reloc) |
36379167 NC |
104 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} |
105 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
be4514d3 ILT |
106 | } |
107 | ||
344a211f NC |
108 | .pdata ${RELOCATING+BLOCK(__section_alignment__)} : |
109 | { | |
110 | *(.pdata) | |
111 | } | |
112 | ||
252b5132 RH |
113 | .bss ${RELOCATING+BLOCK(__section_alignment__)} : |
114 | { | |
115 | ${RELOCATING+__bss_start__ = . ;} | |
116 | *(.bss) | |
117 | *(COMMON) | |
118 | ${RELOCATING+__bss_end__ = . ;} | |
119 | } | |
120 | ||
252b5132 RH |
121 | .edata ${RELOCATING+BLOCK(__section_alignment__)} : |
122 | { | |
123 | *(.edata) | |
124 | } | |
125 | ||
126 | /DISCARD/ : | |
127 | { | |
128 | *(.debug\$S) | |
129 | *(.debug\$T) | |
130 | *(.debug\$F) | |
131 | *(.drectve) | |
132 | } | |
133 | ||
134 | .idata ${RELOCATING+BLOCK(__section_alignment__)} : | |
135 | { | |
136 | /* This cannot currently be handled with grouped sections. | |
137 | See pe.em:sort_sections. */ | |
138 | ${R_IDATA} | |
139 | } | |
140 | .CRT ${RELOCATING+BLOCK(__section_alignment__)} : | |
141 | { | |
552f8272 CF |
142 | ${RELOCATING+___crt_xc_start__ = . ;} |
143 | ${R_CRT_XC} | |
144 | ${RELOCATING+___crt_xc_end__ = . ;} | |
145 | ${RELOCATING+___crt_xi_start__ = . ;} | |
146 | ${R_CRT_XI} | |
147 | ${RELOCATING+___crt_xi_end__ = . ;} | |
148 | ${RELOCATING+___crt_xl_start__ = . ;} | |
149 | ${R_CRT_XL} | |
150 | /* ___crt_xl_end__ is defined in the TLS Directory support code */ | |
151 | ${RELOCATING+___crt_xp_start__ = . ;} | |
152 | ${R_CRT_XP} | |
153 | ${RELOCATING+___crt_xp_end__ = . ;} | |
154 | ${RELOCATING+___crt_xt_start__ = . ;} | |
155 | ${R_CRT_XT} | |
156 | ${RELOCATING+___crt_xt_end__ = . ;} | |
252b5132 RH |
157 | } |
158 | ||
ca6dee30 NC |
159 | .tls ${RELOCATING+BLOCK(__section_alignment__)} : |
160 | { | |
552f8272 | 161 | ${RELOCATING+___tls_start__ = . ;} |
ca6dee30 | 162 | ${R_TLS} |
552f8272 | 163 | ${RELOCATING+___tls_end__ = . ;} |
ca6dee30 NC |
164 | } |
165 | ||
252b5132 RH |
166 | .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : |
167 | { | |
168 | /* end is deprecated, don't use it */ | |
15c9f673 CF |
169 | ${RELOCATING+PROVIDE (end = .);} |
170 | ${RELOCATING+PROVIDE ( _end = .);} | |
252b5132 RH |
171 | ${RELOCATING+ __end__ = .;} |
172 | } | |
173 | ||
252b5132 RH |
174 | .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : |
175 | { | |
176 | *(.rsrc) | |
177 | ${R_RSRC} | |
178 | } | |
179 | ||
be4514d3 ILT |
180 | .reloc ${RELOCATING+BLOCK(__section_alignment__)} : |
181 | { | |
182 | *(.reloc) | |
183 | } | |
184 | ||
252b5132 RH |
185 | .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
186 | { | |
8a7140c3 | 187 | *(.stab) |
252b5132 RH |
188 | } |
189 | ||
190 | .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
191 | { | |
8a7140c3 | 192 | *(.stabstr) |
252b5132 RH |
193 | } |
194 | ||
8a7140c3 NC |
195 | /* DWARF debug sections. |
196 | Symbols in the DWARF debugging sections are relative to the beginning | |
197 | of the section. Unlike other targets that fake this by putting the | |
198 | section VMA at 0, the PE format will not allow it. */ | |
199 | ||
200 | /* DWARF 1.1 and DWARF 2. */ | |
201 | .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
202 | { | |
203 | *(.debug_aranges) | |
204 | } | |
205 | ||
206 | .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
207 | { | |
208 | *(.debug_pubnames) | |
209 | } | |
210 | ||
211 | /* DWARF 2. */ | |
212 | .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
213 | { | |
214 | *(.debug_info) *(.gnu.linkonce.wi.*) | |
215 | } | |
216 | ||
217 | .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
218 | { | |
219 | *(.debug_abbrev) | |
220 | } | |
221 | ||
222 | .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
223 | { | |
224 | *(.debug_line) | |
225 | } | |
226 | ||
227 | .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
228 | { | |
229 | *(.debug_frame) | |
230 | } | |
231 | ||
232 | .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
233 | { | |
234 | *(.debug_str) | |
235 | } | |
236 | ||
237 | .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
238 | { | |
239 | *(.debug_loc) | |
240 | } | |
241 | ||
242 | .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
243 | { | |
244 | *(.debug_macinfo) | |
245 | } | |
246 | ||
247 | /* SGI/MIPS DWARF 2 extensions. */ | |
248 | .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
249 | { | |
250 | *(.debug_weaknames) | |
251 | } | |
252 | ||
253 | .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
254 | { | |
255 | *(.debug_funcnames) | |
256 | } | |
257 | ||
258 | .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
259 | { | |
260 | *(.debug_typenames) | |
261 | } | |
262 | ||
263 | .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
264 | { | |
265 | *(.debug_varnames) | |
266 | } | |
267 | ||
268 | /* DWARF 3. */ | |
269 | .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
270 | { | |
271 | *(.debug_ranges) | |
272 | } | |
252b5132 RH |
273 | } |
274 | EOF |