1# $MirOS: src/gnu/usr.bin/binutils/ld/scripttempl/epocpe.sc,v 1.2 2005/03/13 16:07:07 tg Exp $
2#
3# Linker script for PE.
4
5if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
6  RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
7fi
8
9# We can't easily and portably get an unquoted $ in a shell
10# substitution, so we do this instead.
11# Sorting of the .foo$* sections is required by the definition of
12# grouped sections in PE.
13# Sorting of the file names in R_IDATA is required by the
14# current implementation of dlltool (this could probably be changed to
15# use grouped sections instead).
16if test "${RELOCATING}"; then
17  R_TEXT='*(SORT(.text$*))'
18  R_DATA='*(SORT(.data$*))'
19  R_RDATA='*(SORT(.rdata$*))'
20  R_IDATA='
21    SORT(*)(.idata$2)
22    SORT(*)(.idata$3)
23    /* These zeroes mark the end of the import list.  */
24    LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
25    SORT(*)(.idata$4)
26    SORT(*)(.idata$5)
27    SORT(*)(.idata$6)
28    SORT(*)(.idata$7)'
29  R_CRT='*(SORT(.CRT$*))'
30  R_RSRC='*(SORT(.rsrc$*))'
31else
32  R_TEXT=
33  R_DATA=
34  R_RDATA=
35  R_IDATA=
36  R_CRT=
37  R_RSRC=
38fi
39
40cat <<EOF
41${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
42${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
43
44${LIB_SEARCH_DIRS}
45
46ENTRY(_mainCRTStartup)
47
48SECTIONS
49{
50  .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
51  {
52    ${RELOCATING+ *(.init)}
53    *(.text)
54    ${R_TEXT}
55    *(.glue_7t)
56    *(.glue_7)
57    ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
58			LONG (-1); *(.ctors); *(.ctor); LONG (0); }
59    ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
60			LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
61    ${RELOCATING+ *(.fini)}
62    /* ??? Why is .gcc_exc here?  */
63    ${RELOCATING+ *(.gcc_exc)}
64    ${RELOCATING+ etext = .;}
65    *(.gcc_except_table)
66
67    /* For EPOC the read only data is located at the end of the .text
68    section */
69    *(.rdata)
70    ${R_RDATA}
71    *(.eh_frame)
72  }
73
74  /* The Cygwin32 library uses a section to avoid copying certain data
75     on fork.  This used to be named ".data$nocopy".  The linker used
76     to include this between __data_start__ and __data_end__, but that
77     breaks building the cygwin32 dll.  Instead, we name the section
78     ".data_cygwin_nocopy" and explictly include it after __data_end__. */
79
80  .data ${RELOCATING+BLOCK(__section_alignment__)} :
81  {
82    ${RELOCATING+__data_start__ = . ;}
83    *(.data)
84    *(.data2)
85    ${R_DATA}
86    ${RELOCATING+__data_end__ = . ;}
87    ${RELOCATING+*(.data_cygwin_nocopy)}
88  }
89
90  .bss ${RELOCATING+BLOCK(__section_alignment__)} :
91  {
92    ${RELOCATING+__bss_start__ = . ;}
93    *(.bss)
94    *(COMMON)
95    ${RELOCATING+__bss_end__ = . ;}
96  }
97
98  .edata ${RELOCATING+BLOCK(__section_alignment__)} :
99  {
100    *(.edata)
101  }
102
103  /DISCARD/ :
104  {
105    *(.debug\$S)
106    *(.debug\$T)
107    *(.debug\$F)
108    *(.drectve)
109  }
110
111  .idata ${RELOCATING+BLOCK(__section_alignment__)} :
112  {
113    /* This cannot currently be handled with grouped sections.
114	See pe.em:sort_sections.  */
115    ${R_IDATA}
116  }
117
118  .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
119  {
120    ${R_CRT}
121  }
122
123  .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
124  {
125    /* end is deprecated, don't use it */
126    ${RELOCATING+ end = .;}
127    ${RELOCATING+ _end = .;}
128    ${RELOCATING+ __end__ = .;}
129  }
130
131  .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
132  {
133    *(.reloc)
134  }
135
136  .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
137  {
138    *(.rsrc)
139    ${R_RSRC}
140  }
141
142  .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
143  {
144    [ .stab ]
145  }
146
147  .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
148  {
149    [ .stabstr ]
150  }
151
152}
153EOF
154