1# $MirOS: src/gnu/usr.bin/binutils/ld/scripttempl/mcorepe.sc,v 1.3 2009/10/04 03:03:05 tg Exp $
2#
3# Linker script for MCore 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
40if test "$RELOCATING"; then
41  # Can't use ${RELOCATING+blah "blah" blah} for this,
42  # because bash 2.x will lose the doublequotes.
43  cat <<EOF
44OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
45	  	           "${LITTLE_OUTPUT_FORMAT}")
46EOF
47fi
48
49cat <<EOF
50${LIB_SEARCH_DIRS}
51
52ENTRY(_mainCRTStartup)
53
54SECTIONS
55{
56  .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
57  {
58    ${RELOCATING+ *(.init)}
59    *(.text)
60    ${R_TEXT}
61    *(.glue_7t)
62    *(.glue_7)
63    ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
64			LONG (-1); *(.ctors); *(.ctor); LONG (0); }
65    ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
66			LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
67    ${RELOCATING+ *(.fini)}
68    /* ??? Why is .gcc_exc here?  */
69    ${RELOCATING+ *(.gcc_exc)}
70    ${RELOCATING+ etext = .;}
71    *(.gcc_except_table)
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  .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
99  {
100    *(.rdata)
101    ${R_RDATA}
102    *(.eh_frame)
103  }
104
105  .edata ${RELOCATING+BLOCK(__section_alignment__)} :
106  {
107    *(.edata)
108  }
109
110  /DISCARD/ :
111  {
112    *(.debug\$S)
113    *(.debug\$T)
114    *(.debug\$F)
115    *(.drectve)
116  }
117
118  .idata ${RELOCATING+BLOCK(__section_alignment__)} :
119  {
120    /* This cannot currently be handled with grouped sections.
121	See pe.em:sort_sections.  */
122    ${R_IDATA}
123  }
124  .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
125  {
126    ${R_CRT}
127  }
128
129  .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
130  {
131    /* end is deprecated, don't use it */
132    ${RELOCATING+ end = .;}
133    ${RELOCATING+ _end = .;}
134    ${RELOCATING+ __end__ = .;}
135  }
136
137  .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
138  {
139    *(.reloc)
140  }
141
142  .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
143  {
144    *(.rsrc)
145    ${R_RSRC}
146  }
147
148  .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
149  {
150    [ .stab ]
151  }
152
153  .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
154  {
155    [ .stabstr ]
156  }
157
158  .stack 0x80000 :
159  {
160    _stack = .;
161    *(.stack)
162  }
163}
164EOF
165