Add support for DragonFlyBSD target.
[binutils.git] / ld / scripttempl / mcorepe.sc
blob511fdb1f898ecd0485fde5f7753ad5d8471fa6a7
1 # Linker script for MCore 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   R_DATA='*(SORT(.data$*))'
17   R_RDATA='*(SORT(.rdata$*))'
18   R_IDATA='
19     SORT(*)(.idata$2)
20     SORT(*)(.idata$3)
21     /* These zeroes mark the end of the import list.  */
22     LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
23     SORT(*)(.idata$4)
24     SORT(*)(.idata$5)
25     SORT(*)(.idata$6)
26     SORT(*)(.idata$7)'
27   R_CRT='*(SORT(.CRT$*))'
28   R_RSRC='*(SORT(.rsrc$*))'
29 else
30   R_TEXT=
31   R_DATA=
32   R_RDATA=
33   R_IDATA=
34   R_CRT=
35   R_RSRC=
38 if test "$RELOCATING"; then
39   # Can't use ${RELOCATING+blah "blah" blah} for this,
40   # because bash 2.x will lose the doublequotes.
41   cat <<EOF
42 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
43                            "${LITTLE_OUTPUT_FORMAT}")
44 EOF
47 cat <<EOF
48 ${LIB_SEARCH_DIRS}
50 ${RELOCATING+ENTRY (_mainCRTStartup)}
52 SECTIONS
54   .text ${RELOCATING+ __image_base__ + __section_alignment__ } : 
55   {
56     ${RELOCATING+ *(.init)}
57     *(.text)
58     ${R_TEXT}
59     ${RELOCATING+ *(.text.*)}
60     *(.glue_7t)
61     *(.glue_7)
62     ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
63                         LONG (-1); *(.ctors); *(.ctor); LONG (0); }
64     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
65                         LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
66     ${RELOCATING+ *(.fini)}
67     /* ??? Why is .gcc_exc here?  */
68     ${RELOCATING+ *(.gcc_exc)}
69     ${RELOCATING+ etext = .;}
70     *(.gcc_except_table)
71   }
73   /* The Cygwin32 library uses a section to avoid copying certain data
74      on fork.  This used to be named ".data$nocopy".  The linker used
75      to include this between __data_start__ and __data_end__, but that
76      breaks building the cygwin32 dll.  Instead, we name the section
77      ".data_cygwin_nocopy" and explictly include it after __data_end__. */
79   .data ${RELOCATING+BLOCK(__section_alignment__)} : 
80   {
81     ${RELOCATING+__data_start__ = . ;}
82     *(.data)
83     *(.data2)
84     ${R_DATA}
85     ${RELOCATING+__data_end__ = . ;}
86     ${RELOCATING+*(.data_cygwin_nocopy)}
87   }
89   .bss ${RELOCATING+BLOCK(__section_alignment__)} :
90   {
91     ${RELOCATING+__bss_start__ = . ;}
92     *(.bss)
93     *(COMMON)
94     ${RELOCATING+__bss_end__ = . ;}
95   }
97   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
98   {
99     *(.rdata)
100     ${R_RDATA}
101     *(.eh_frame)
102   }
104   .edata ${RELOCATING+BLOCK(__section_alignment__)} :
105   {
106     *(.edata)
107   }
109   /DISCARD/ :
110   {
111     *(.debug\$S)
112     *(.debug\$T)
113     *(.debug\$F)
114     *(.drectve)
115   }
117   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
118   {
119     /* This cannot currently be handled with grouped sections.
120         See pe.em:sort_sections.  */
121     ${R_IDATA}
122   }
123   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
124   {                                     
125     ${R_CRT}
126   }
128   .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
129   {
130     /* end is deprecated, don't use it */
131     ${RELOCATING+ end = .;}
132     ${RELOCATING+ _end = .;}
133     ${RELOCATING+ __end__ = .;}
134   }
136   .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
137   {                                     
138     *(.reloc)
139   }
141   .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
142   {                                     
143     *(.rsrc)
144     ${R_RSRC}
145   }
147   .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
148   {
149     [ .stab ]
150   }
152   .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
153   {
154     [ .stabstr ]
155   }
157   .stack 0x80000 :
158   {
159     _stack = .;
160     *(.stack)
161   }