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