fix typo.
[deliverable/binutils-gdb.git] / ld / emultempl / armcoff.em
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<EOF
4 /* This file is is generated by a shell script. DO NOT EDIT! */
5
6 /* emulate the original gld for the given ${EMULATION_NAME}
7 Copyright (C) 1991, 93, 96, 97, 1998 Free Software Foundation, Inc.
8 Written by Steve Chamberlain steve@cygnus.com
9
10 This file is part of GLD, the Gnu Linker.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25
26 #define TARGET_IS_${EMULATION_NAME}
27
28 #include "bfd.h"
29 #include "sysdep.h"
30 #include "bfdlink.h"
31 #include "getopt.h"
32
33 #include "ld.h"
34 #include "ldmain.h"
35 #include "ldemul.h"
36 #include "ldfile.h"
37 #include "ldmisc.h"
38
39 #include "ldexp.h"
40 #include "ldlang.h"
41
42 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
43 static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
44 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
45 static int gld${EMULATION_NAME}_parse_args PARAMS((int, char **));
46 static void gld${EMULATION_NAME}_list_options PARAMS ((FILE *));
47
48 /* If true, then interworking stubs which support calls to old, non-interworking
49 aware ARM code should be generated. */
50
51 static int support_old_code = 0;
52
53 #define OPTION_SUPPORT_OLD_CODE 300
54
55 static struct option longopts[] =
56 {
57 {"support-old-code", no_argument, NULL, OPTION_SUPPORT_OLD_CODE},
58 {NULL, no_argument, NULL, 0}
59 };
60
61 static void
62 gld${EMULATION_NAME}_list_options (file)
63 FILE * file;
64 {
65 fprintf (file, _(" --support-old-code Support interworking with old code\n"));
66 }
67
68 static int
69 gld${EMULATION_NAME}_parse_args (argc, argv)
70 int argc;
71 char ** argv;
72 {
73 int longind;
74 int optc;
75 int prevoptind = optind;
76 int prevopterr = opterr;
77 int wanterror;
78 static int lastoptind = -1;
79
80 if (lastoptind != optind)
81 opterr = 0;
82
83 wanterror = opterr;
84 lastoptind = optind;
85
86 optc = getopt_long_only (argc, argv, "-", longopts, & longind);
87 opterr = prevopterr;
88
89 switch (optc)
90 {
91 default:
92 if (wanterror)
93 xexit (1);
94 optind = prevoptind;
95 return 0;
96
97 case OPTION_SUPPORT_OLD_CODE:
98 support_old_code = 1;
99 break;
100 }
101
102 return 1;
103 }
104 \f
105 static void
106 gld${EMULATION_NAME}_before_parse ()
107 {
108 #ifndef TARGET_ /* I.e., if not generic. */
109 ldfile_set_output_arch ("`echo ${ARCH}`");
110 #endif /* not TARGET_ */
111 }
112
113 /* This is called after the sections have been attached to output
114 sections, but before any sizes or addresses have been set. */
115
116 static void
117 gld${EMULATION_NAME}_before_allocation ()
118 {
119 /* we should be able to set the size of the interworking stub section */
120
121 /* Here we rummage through the found bfds to collect glue information */
122 /* FIXME: should this be based on a command line option? krk@cygnus.com */
123 {
124 LANG_FOR_EACH_INPUT_STATEMENT (is)
125 {
126 if (! bfd_arm_process_before_allocation
127 (is->the_bfd, & link_info, support_old_code))
128 {
129 /* xgettext:c-format */
130 einfo (_("Errors encountered processing file %s"), is->filename);
131 }
132 }
133 }
134
135 /* We have seen it all. Allocate it, and carry on */
136 bfd_arm_allocate_interworking_sections (& link_info);
137 }
138
139 static void
140 gld${EMULATION_NAME}_after_open ()
141 {
142 LANG_FOR_EACH_INPUT_STATEMENT (is)
143 {
144 if (bfd_arm_get_bfd_for_interworking (is->the_bfd, & link_info))
145 break;
146 }
147 }
148
149 static char *
150 gld${EMULATION_NAME}_get_script (isfile)
151 int *isfile;
152 EOF
153
154 if test -n "$COMPILE_IN"
155 then
156 # Scripts compiled in.
157
158 # sed commands to quote an ld script as a C string.
159 sc="-f ${srcdir}/emultempl/stringify.sed"
160
161 cat >>e${EMULATION_NAME}.c <<EOF
162 {
163 *isfile = 0;
164
165 if (link_info.relocateable == true && config.build_constructors == true)
166 return
167 EOF
168 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
169 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
170 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
171 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
172 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
173 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
174 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
175 echo ' ; else return' >> e${EMULATION_NAME}.c
176 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
177 echo '; }' >> e${EMULATION_NAME}.c
178
179 else
180 # Scripts read from the filesystem.
181
182 cat >>e${EMULATION_NAME}.c <<EOF
183 {
184 *isfile = 1;
185
186 if (link_info.relocateable == true && config.build_constructors == true)
187 return "ldscripts/${EMULATION_NAME}.xu";
188 else if (link_info.relocateable == true)
189 return "ldscripts/${EMULATION_NAME}.xr";
190 else if (!config.text_read_only)
191 return "ldscripts/${EMULATION_NAME}.xbn";
192 else if (!config.magic_demand_paged)
193 return "ldscripts/${EMULATION_NAME}.xn";
194 else
195 return "ldscripts/${EMULATION_NAME}.x";
196 }
197 EOF
198
199 fi
200
201 cat >>e${EMULATION_NAME}.c <<EOF
202
203 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
204 {
205 gld${EMULATION_NAME}_before_parse,
206 syslib_default,
207 hll_default,
208 after_parse_default,
209 gld${EMULATION_NAME}_after_open,
210 after_allocation_default,
211 set_output_arch_default,
212 ldemul_default_target,
213 gld${EMULATION_NAME}_before_allocation,
214 gld${EMULATION_NAME}_get_script,
215 "${EMULATION_NAME}",
216 "${OUTPUT_FORMAT}",
217 NULL, /* finish */
218 NULL, /* create output section statements */
219 NULL, /* open dynamic archive */
220 NULL, /* place orphan */
221 NULL, /* set_symbols */
222 gld${EMULATION_NAME}_parse_args,
223 NULL, /* unrecognised file */
224 gld${EMULATION_NAME}_list_options
225 };
226 EOF
This page took 0.037735 seconds and 5 git commands to generate.