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} | |
91 | ${RELOCATING+__data_end__ = . ;} | |
92 | ${RELOCATING+*(.data_cygwin_nocopy)} | |
93 | } | |
94 | ||
be4514d3 ILT |
95 | .rdata ${RELOCATING+BLOCK(__section_alignment__)} : |
96 | { | |
97 | *(.rdata) | |
98 | ${R_RDATA} | |
99 | *(.eh_frame) | |
36379167 NC |
100 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} |
101 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} | |
ad5211be | 102 | *(.rdata_runtime_pseudo_reloc) |
36379167 NC |
103 | ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} |
104 | ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} | |
be4514d3 ILT |
105 | } |
106 | ||
344a211f NC |
107 | .pdata ${RELOCATING+BLOCK(__section_alignment__)} : |
108 | { | |
109 | *(.pdata) | |
110 | } | |
111 | ||
252b5132 RH |
112 | .bss ${RELOCATING+BLOCK(__section_alignment__)} : |
113 | { | |
114 | ${RELOCATING+__bss_start__ = . ;} | |
115 | *(.bss) | |
116 | *(COMMON) | |
117 | ${RELOCATING+__bss_end__ = . ;} | |
118 | } | |
119 | ||
252b5132 RH |
120 | .edata ${RELOCATING+BLOCK(__section_alignment__)} : |
121 | { | |
122 | *(.edata) | |
123 | } | |
124 | ||
125 | /DISCARD/ : | |
126 | { | |
127 | *(.debug\$S) | |
128 | *(.debug\$T) | |
129 | *(.debug\$F) | |
130 | *(.drectve) | |
131 | } | |
132 | ||
133 | .idata ${RELOCATING+BLOCK(__section_alignment__)} : | |
134 | { | |
135 | /* This cannot currently be handled with grouped sections. | |
136 | See pe.em:sort_sections. */ | |
137 | ${R_IDATA} | |
138 | } | |
139 | .CRT ${RELOCATING+BLOCK(__section_alignment__)} : | |
140 | { | |
552f8272 CF |
141 | ${RELOCATING+___crt_xc_start__ = . ;} |
142 | ${R_CRT_XC} | |
143 | ${RELOCATING+___crt_xc_end__ = . ;} | |
144 | ${RELOCATING+___crt_xi_start__ = . ;} | |
145 | ${R_CRT_XI} | |
146 | ${RELOCATING+___crt_xi_end__ = . ;} | |
147 | ${RELOCATING+___crt_xl_start__ = . ;} | |
148 | ${R_CRT_XL} | |
149 | /* ___crt_xl_end__ is defined in the TLS Directory support code */ | |
150 | ${RELOCATING+___crt_xp_start__ = . ;} | |
151 | ${R_CRT_XP} | |
152 | ${RELOCATING+___crt_xp_end__ = . ;} | |
153 | ${RELOCATING+___crt_xt_start__ = . ;} | |
154 | ${R_CRT_XT} | |
155 | ${RELOCATING+___crt_xt_end__ = . ;} | |
252b5132 RH |
156 | } |
157 | ||
ca6dee30 NC |
158 | .tls ${RELOCATING+BLOCK(__section_alignment__)} : |
159 | { | |
552f8272 | 160 | ${RELOCATING+___tls_start__ = . ;} |
ca6dee30 | 161 | ${R_TLS} |
552f8272 | 162 | ${RELOCATING+___tls_end__ = . ;} |
ca6dee30 NC |
163 | } |
164 | ||
252b5132 RH |
165 | .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : |
166 | { | |
167 | /* end is deprecated, don't use it */ | |
15c9f673 CF |
168 | ${RELOCATING+PROVIDE (end = .);} |
169 | ${RELOCATING+PROVIDE ( _end = .);} | |
252b5132 RH |
170 | ${RELOCATING+ __end__ = .;} |
171 | } | |
172 | ||
252b5132 RH |
173 | .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : |
174 | { | |
175 | *(.rsrc) | |
176 | ${R_RSRC} | |
177 | } | |
178 | ||
be4514d3 ILT |
179 | .reloc ${RELOCATING+BLOCK(__section_alignment__)} : |
180 | { | |
181 | *(.reloc) | |
182 | } | |
183 | ||
252b5132 RH |
184 | .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : |
185 | { | |
8a7140c3 | 186 | *(.stab) |
252b5132 RH |
187 | } |
188 | ||
189 | .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
190 | { | |
8a7140c3 | 191 | *(.stabstr) |
252b5132 RH |
192 | } |
193 | ||
8a7140c3 NC |
194 | /* DWARF debug sections. |
195 | Symbols in the DWARF debugging sections are relative to the beginning | |
196 | of the section. Unlike other targets that fake this by putting the | |
197 | section VMA at 0, the PE format will not allow it. */ | |
198 | ||
199 | /* DWARF 1.1 and DWARF 2. */ | |
200 | .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
201 | { | |
202 | *(.debug_aranges) | |
203 | } | |
204 | ||
205 | .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
206 | { | |
207 | *(.debug_pubnames) | |
208 | } | |
209 | ||
210 | /* DWARF 2. */ | |
211 | .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
212 | { | |
213 | *(.debug_info) *(.gnu.linkonce.wi.*) | |
214 | } | |
215 | ||
216 | .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
217 | { | |
218 | *(.debug_abbrev) | |
219 | } | |
220 | ||
221 | .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
222 | { | |
223 | *(.debug_line) | |
224 | } | |
225 | ||
226 | .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
227 | { | |
228 | *(.debug_frame) | |
229 | } | |
230 | ||
231 | .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
232 | { | |
233 | *(.debug_str) | |
234 | } | |
235 | ||
236 | .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
237 | { | |
238 | *(.debug_loc) | |
239 | } | |
240 | ||
241 | .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
242 | { | |
243 | *(.debug_macinfo) | |
244 | } | |
245 | ||
246 | /* SGI/MIPS DWARF 2 extensions. */ | |
247 | .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
248 | { | |
249 | *(.debug_weaknames) | |
250 | } | |
251 | ||
252 | .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
253 | { | |
254 | *(.debug_funcnames) | |
255 | } | |
256 | ||
257 | .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
258 | { | |
259 | *(.debug_typenames) | |
260 | } | |
261 | ||
262 | .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
263 | { | |
264 | *(.debug_varnames) | |
265 | } | |
266 | ||
267 | /* DWARF 3. */ | |
268 | .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : | |
269 | { | |
270 | *(.debug_ranges) | |
271 | } | |
252b5132 RH |
272 | } |
273 | EOF |