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