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