OSDN Git Service

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