* ldemul.c (ldemul_parse_args): Return FALSE by default.
[deliverable/binutils-gdb.git] / ld / ldemul.c
1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002
3 Free Software Foundation, Inc.
4
5 This file is part of GLD, the Gnu Linker.
6
7 GLD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GLD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GLD; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 #include "bfd.h"
23 #include "sysdep.h"
24
25 #include "ld.h"
26 #include "ldmisc.h"
27 #include "ldexp.h"
28 #include "ldlang.h"
29 #include "ldfile.h"
30 #include "ldemul.h"
31 #include "ldmain.h"
32 #include "ldemul-list.h"
33
34 ld_emulation_xfer_type *ld_emulation;
35
36 void
37 ldemul_hll (name)
38 char *name;
39 {
40 ld_emulation->hll (name);
41 }
42
43 void
44 ldemul_syslib (name)
45 char *name;
46 {
47 ld_emulation->syslib (name);
48 }
49
50 void
51 ldemul_after_parse ()
52 {
53 ld_emulation->after_parse ();
54 }
55
56 void
57 ldemul_before_parse ()
58 {
59 ld_emulation->before_parse ();
60 }
61
62 void
63 ldemul_after_open ()
64 {
65 ld_emulation->after_open ();
66 }
67
68 void
69 ldemul_after_allocation ()
70 {
71 ld_emulation->after_allocation ();
72 }
73
74 void
75 ldemul_before_allocation ()
76 {
77 if (ld_emulation->before_allocation)
78 ld_emulation->before_allocation ();
79 }
80
81 void
82 ldemul_set_output_arch ()
83 {
84 ld_emulation->set_output_arch ();
85 }
86
87 void
88 ldemul_finish ()
89 {
90 if (ld_emulation->finish)
91 ld_emulation->finish ();
92 }
93
94 void
95 ldemul_set_symbols ()
96 {
97 if (ld_emulation->set_symbols)
98 ld_emulation->set_symbols ();
99 }
100
101 void
102 ldemul_create_output_section_statements ()
103 {
104 if (ld_emulation->create_output_section_statements)
105 ld_emulation->create_output_section_statements ();
106 }
107
108 char *
109 ldemul_get_script (isfile)
110 int *isfile;
111 {
112 return ld_emulation->get_script (isfile);
113 }
114
115 bfd_boolean
116 ldemul_open_dynamic_archive (arch, search, entry)
117 const char *arch;
118 search_dirs_type *search;
119 lang_input_statement_type *entry;
120 {
121 if (ld_emulation->open_dynamic_archive)
122 return (*ld_emulation->open_dynamic_archive) (arch, search, entry);
123 return FALSE;
124 }
125
126 bfd_boolean
127 ldemul_place_orphan (file, s)
128 lang_input_statement_type *file;
129 asection *s;
130 {
131 if (ld_emulation->place_orphan)
132 return (*ld_emulation->place_orphan) (file, s);
133 return FALSE;
134 }
135
136 void
137 ldemul_add_options (ns, shortopts, nl, longopts, nrl, really_longopts)
138 int ns;
139 char **shortopts;
140 int nl;
141 struct option **longopts;
142 int nrl;
143 struct option **really_longopts;
144 {
145 if (ld_emulation->add_options)
146 (*ld_emulation->add_options) (ns, shortopts, nl, longopts,
147 nrl, really_longopts);
148 }
149
150 bfd_boolean
151 ldemul_handle_option (optc)
152 int optc;
153 {
154 if (ld_emulation->handle_option)
155 return (*ld_emulation->handle_option) (optc);
156 return FALSE;
157 }
158
159 bfd_boolean
160 ldemul_parse_args (argc, argv)
161 int argc;
162 char **argv;
163 {
164 /* Try and use the emulation parser if there is one. */
165 if (ld_emulation->parse_args)
166 return (*ld_emulation->parse_args) (argc, argv);
167 return FALSE;
168 }
169
170 /* Let the emulation code handle an unrecognized file. */
171
172 bfd_boolean
173 ldemul_unrecognized_file (entry)
174 lang_input_statement_type *entry;
175 {
176 if (ld_emulation->unrecognized_file)
177 return (*ld_emulation->unrecognized_file) (entry);
178 return FALSE;
179 }
180
181 /* Let the emulation code handle a recognized file. */
182
183 bfd_boolean
184 ldemul_recognized_file (entry)
185 lang_input_statement_type *entry;
186 {
187 if (ld_emulation->recognized_file)
188 return (*ld_emulation->recognized_file) (entry);
189 return FALSE;
190 }
191
192 char *
193 ldemul_choose_target (argc, argv)
194 int argc;
195 char **argv;
196 {
197 return ld_emulation->choose_target (argc, argv);
198 }
199
200
201 /* The default choose_target function. */
202
203 char *
204 ldemul_default_target (argc, argv)
205 int argc ATTRIBUTE_UNUSED;
206 char **argv ATTRIBUTE_UNUSED;
207 {
208 char *from_outside = getenv (TARGET_ENVIRON);
209 if (from_outside != (char *) NULL)
210 return from_outside;
211 return ld_emulation->target_name;
212 }
213
214 void
215 after_parse_default ()
216 {
217 }
218
219 void
220 after_open_default ()
221 {
222 }
223
224 void
225 after_allocation_default ()
226 {
227 }
228
229 void
230 before_allocation_default ()
231 {
232 }
233
234 void
235 set_output_arch_default ()
236 {
237 /* Set the output architecture and machine if possible. */
238 bfd_set_arch_mach (output_bfd,
239 ldfile_output_architecture, ldfile_output_machine);
240 }
241
242 void
243 syslib_default (ignore)
244 char *ignore ATTRIBUTE_UNUSED;
245 {
246 info_msg (_("%S SYSLIB ignored\n"));
247 }
248
249 void
250 hll_default (ignore)
251 char *ignore ATTRIBUTE_UNUSED;
252 {
253 info_msg (_("%S HLL ignored\n"));
254 }
255
256 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
257
258 void
259 ldemul_choose_mode (target)
260 char *target;
261 {
262 ld_emulation_xfer_type **eptr = ld_emulations;
263 /* Ignore "gld" prefix. */
264 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
265 target += 3;
266 for (; *eptr; eptr++)
267 {
268 if (strcmp (target, (*eptr)->emulation_name) == 0)
269 {
270 ld_emulation = *eptr;
271 return;
272 }
273 }
274 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
275 einfo (_("Supported emulations: "));
276 ldemul_list_emulations (stderr);
277 einfo ("%F\n");
278 }
279
280 void
281 ldemul_list_emulations (f)
282 FILE *f;
283 {
284 ld_emulation_xfer_type **eptr = ld_emulations;
285 bfd_boolean first = TRUE;
286
287 for (; *eptr; eptr++)
288 {
289 if (first)
290 first = FALSE;
291 else
292 fprintf (f, " ");
293 fprintf (f, "%s", (*eptr)->emulation_name);
294 }
295 }
296
297 void
298 ldemul_list_emulation_options (f)
299 FILE *f;
300 {
301 ld_emulation_xfer_type **eptr;
302 int options_found = 0;
303
304 for (eptr = ld_emulations; *eptr; eptr++)
305 {
306 ld_emulation_xfer_type *emul = *eptr;
307
308 if (emul->list_options)
309 {
310 fprintf (f, "%s: \n", emul->emulation_name);
311
312 emul->list_options (f);
313
314 options_found = 1;
315 }
316 }
317
318 if (! options_found)
319 fprintf (f, _(" no emulation specific options.\n"));
320 }
321
322 int
323 ldemul_find_potential_libraries (name, entry)
324 char *name;
325 lang_input_statement_type *entry;
326 {
327 if (ld_emulation->find_potential_libraries)
328 return ld_emulation->find_potential_libraries (name, entry);
329
330 return 0;
331 }
332
333 struct bfd_elf_version_expr *
334 ldemul_new_vers_pattern (entry)
335 struct bfd_elf_version_expr *entry;
336 {
337 if (ld_emulation->new_vers_pattern)
338 entry = (*ld_emulation->new_vers_pattern) (entry);
339 return entry;
340 }
This page took 0.037595 seconds and 5 git commands to generate.