* gas/elf/elf.exp: Don't run tests on "*-*-linux*aout*" or
[binutils.git] / ld / ldemul.c
blobeab0432da3a194d6385d8a2d24ac1dbf13073b9a
1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #include "bfd.h"
21 #include "sysdep.h"
23 #include "ld.h"
24 #include "ldemul.h"
25 #include "ldmisc.h"
26 #include "ldexp.h"
27 #include "ldlang.h"
28 #include "ldfile.h"
29 #include "ldmain.h"
30 #include "ldemul-list.h"
32 ld_emulation_xfer_type *ld_emulation;
34 void
35 ldemul_hll(name)
36 char *name;
38 ld_emulation->hll(name);
42 void ldemul_syslib(name)
43 char *name;
45 ld_emulation->syslib(name);
48 void
49 ldemul_after_parse()
51 ld_emulation->after_parse();
54 void
55 ldemul_before_parse()
57 ld_emulation->before_parse();
60 void
61 ldemul_after_open ()
63 ld_emulation->after_open ();
66 void
67 ldemul_after_allocation()
69 ld_emulation->after_allocation();
72 void
73 ldemul_before_allocation()
75 if (ld_emulation->before_allocation)
76 ld_emulation->before_allocation();
80 void
81 ldemul_set_output_arch()
83 ld_emulation->set_output_arch();
86 void
87 ldemul_finish()
89 if (ld_emulation->finish)
90 ld_emulation->finish();
93 void
94 ldemul_set_symbols()
96 if (ld_emulation->set_symbols)
97 ld_emulation->set_symbols();
100 void
101 ldemul_create_output_section_statements()
103 if (ld_emulation->create_output_section_statements)
104 ld_emulation->create_output_section_statements();
107 char *
108 ldemul_get_script(isfile)
109 int *isfile;
111 return ld_emulation->get_script(isfile);
114 boolean
115 ldemul_open_dynamic_archive (arch, search, entry)
116 const char *arch;
117 search_dirs_type *search;
118 lang_input_statement_type *entry;
120 if (ld_emulation->open_dynamic_archive)
121 return (*ld_emulation->open_dynamic_archive) (arch, search, entry);
122 return false;
125 boolean
126 ldemul_place_orphan (file, s)
127 lang_input_statement_type *file;
128 asection *s;
130 if (ld_emulation->place_orphan)
131 return (*ld_emulation->place_orphan) (file, s);
132 return false;
136 ldemul_parse_args (argc, argv)
137 int argc;
138 char **argv;
140 /* Try and use the emulation parser if there is one. */
141 if (ld_emulation->parse_args)
143 return ld_emulation->parse_args (argc, argv);
145 return 0;
148 /* Let the emulation code handle an unrecognized file. */
150 boolean
151 ldemul_unrecognized_file (entry)
152 lang_input_statement_type *entry;
154 if (ld_emulation->unrecognized_file)
155 return (*ld_emulation->unrecognized_file) (entry);
156 return false;
159 /* Let the emulation code handle a recognized file. */
161 boolean
162 ldemul_recognized_file (entry)
163 lang_input_statement_type *entry;
165 if (ld_emulation->recognized_file)
166 return (*ld_emulation->recognized_file) (entry);
167 return false;
170 char *
171 ldemul_choose_target()
173 return ld_emulation->choose_target();
176 /* The default choose_target function. */
178 char *
179 ldemul_default_target()
181 char *from_outside = getenv (TARGET_ENVIRON);
182 if (from_outside != (char *)NULL)
183 return from_outside;
184 return ld_emulation->target_name;
187 void
188 after_parse_default()
193 void
194 after_open_default ()
198 void
199 after_allocation_default()
204 void
205 before_allocation_default()
210 void
211 set_output_arch_default()
213 /* Set the output architecture and machine if possible */
214 bfd_set_arch_mach(output_bfd,
215 ldfile_output_architecture, ldfile_output_machine);
218 /*ARGSUSED*/
219 void
220 syslib_default(ignore)
221 char *ignore;
223 info_msg (_("%S SYSLIB ignored\n"));
226 /*ARGSUSED*/
227 void
228 hll_default(ignore)
229 char *ignore;
231 info_msg (_("%S HLL ignored\n"));
234 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
236 void
237 ldemul_choose_mode(target)
238 char *target;
240 ld_emulation_xfer_type **eptr = ld_emulations;
241 /* Ignore "gld" prefix. */
242 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
243 target += 3;
244 for (; *eptr; eptr++)
246 if (strcmp(target, (*eptr)->emulation_name) == 0)
248 ld_emulation = *eptr;
249 return;
252 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
253 einfo (_("Supported emulations: "));
254 ldemul_list_emulations (stderr);
255 einfo ("%F\n");
258 void
259 ldemul_list_emulations (f)
260 FILE *f;
262 ld_emulation_xfer_type **eptr = ld_emulations;
263 boolean first = true;
265 for (; *eptr; eptr++)
267 if (first)
268 first = false;
269 else
270 fprintf (f, " ");
271 fprintf (f, "%s", (*eptr)->emulation_name);
275 void
276 ldemul_list_emulation_options (f)
277 FILE * f;
279 ld_emulation_xfer_type ** eptr;
280 int options_found = 0;
282 for (eptr = ld_emulations; * eptr; eptr ++)
284 ld_emulation_xfer_type * emul = * eptr;
286 if (emul->list_options)
288 fprintf (f, "%s: \n", emul->emulation_name);
290 emul->list_options (f);
292 options_found = 1;
296 if (! options_found)
297 fprintf (f, _(" no emulation specific options.\n"));