daily update
[external/binutils.git] / ld / scripttempl / pep.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+. = ALIGN(8);}
75     ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
76                         LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*));  LONG (0); LONG (0); }
77     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
78                         LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*));  LONG (0); LONG (0); }
79     ${RELOCATING+ *(.fini)}
80     /* ??? Why is .gcc_exc here?  */
81     ${RELOCATING+ *(.gcc_exc)}
82     ${RELOCATING+PROVIDE (etext = .);}
83     ${RELOCATING+ *(.gcc_except_table)}
84   }
85
86   /* The Cygwin32 library uses a section to avoid copying certain data
87      on fork.  This used to be named ".data$nocopy".  The linker used
88      to include this between __data_start__ and __data_end__, but that
89      breaks building the cygwin32 dll.  Instead, we name the section
90      ".data_cygwin_nocopy" and explictly include it after __data_end__. */
91
92   .data ${RELOCATING+BLOCK(__section_alignment__)} : 
93   {
94     ${RELOCATING+__data_start__ = . ;}
95     *(.data)
96     *(.data2)
97     ${R_DATA}
98     *(.jcr)
99     ${RELOCATING+__data_end__ = . ;}
100     ${RELOCATING+*(.data_cygwin_nocopy)}
101   }
102
103   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
104   {
105     ${R_RDATA}
106     ${RELOCATING+ *(.eh_frame)}
107     ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
108     ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;}
109     *(.rdata_runtime_pseudo_reloc)
110     ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
111     ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
112   }
113
114   .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
115   {
116     *(.pdata)
117   }
118
119   .bss ${RELOCATING+BLOCK(__section_alignment__)} :
120   {
121     ${RELOCATING+__bss_start__ = . ;}
122     *(.bss)
123     *(COMMON)
124     ${RELOCATING+__bss_end__ = . ;}
125   }
126
127   .edata ${RELOCATING+BLOCK(__section_alignment__)} :
128   {
129     *(.edata)
130   }
131
132   /DISCARD/ :
133   {
134     *(.debug\$S)
135     *(.debug\$T)
136     *(.debug\$F)
137     *(.drectve)
138   }
139
140   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
141   {
142     /* This cannot currently be handled with grouped sections.
143         See pep.em:sort_sections.  */
144     ${R_IDATA}
145   }
146   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
147   {                                     
148     ${RELOCATING+___crt_xc_start__ = . ;}
149     ${R_CRT_XC}
150     ${RELOCATING+___crt_xc_end__ = . ;}
151     ${RELOCATING+___crt_xi_start__ = . ;}
152     ${R_CRT_XI}
153     ${RELOCATING+___crt_xi_end__ = . ;}
154     ${RELOCATING+___crt_xl_start__ = . ;}
155     ${R_CRT_XL}
156     /* ___crt_xl_end__ is defined in the TLS Directory support code */
157     ${RELOCATING+___crt_xp_start__ = . ;}
158     ${R_CRT_XP}
159     ${RELOCATING+___crt_xp_end__ = . ;}
160     ${RELOCATING+___crt_xt_start__ = . ;}
161     ${R_CRT_XT}
162     ${RELOCATING+___crt_xt_end__ = . ;}
163   }
164
165   .tls ${RELOCATING+BLOCK(__section_alignment__)} :
166   {                                     
167     ${RELOCATING+___tls_start__ = . ;}
168     ${R_TLS}
169     ${RELOCATING+___tls_end__ = . ;}
170   }
171
172   .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
173   {
174     /* end is deprecated, don't use it */
175     ${RELOCATING+PROVIDE (end = .);}
176     ${RELOCATING+PROVIDE ( _end = .);}
177     ${RELOCATING+ __end__ = .;}
178   }
179
180   .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
181   {                                     
182     *(.rsrc)
183     ${R_RSRC}
184   }
185
186   .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
187   {                                     
188     *(.reloc)
189   }
190
191   .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
192   {
193     *(.stab)
194   }
195
196   .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
197   {
198     *(.stabstr)
199   }
200
201   /* DWARF debug sections.
202      Symbols in the DWARF debugging sections are relative to the beginning
203      of the section.  Unlike other targets that fake this by putting the
204      section VMA at 0, the PE format will not allow it.  */
205      
206   /* DWARF 1.1 and DWARF 2.  */
207   .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
208   {
209     *(.debug_aranges)
210   }
211
212   .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
213   {
214     *(.debug_pubnames)
215   }
216
217   /* DWARF 2.  */
218   .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
219   {
220     *(.debug_info) *(.gnu.linkonce.wi.*)
221   }
222
223   .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
224   {
225     *(.debug_abbrev)
226   }
227
228   .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
229   {
230     *(.debug_line)
231   }
232
233   .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
234   {
235     *(.debug_frame)
236   }
237
238   .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
239   {
240     *(.debug_str)
241   }
242
243   .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
244   {
245     *(.debug_loc)
246   }
247
248   .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
249   {
250     *(.debug_macinfo)
251   }
252
253   /* SGI/MIPS DWARF 2 extensions.  */
254   .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
255   {
256     *(.debug_weaknames)
257   }
258
259   .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
260   {
261     *(.debug_funcnames)
262   }
263
264   .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
265   {
266     *(.debug_typenames)
267   }
268
269   .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
270   {
271     *(.debug_varnames)
272   }
273
274   /* DWARF 3.  */
275   .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
276   {
277     *(.debug_ranges)
278   }
279 }
280 EOF