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