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)
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. */
30 #include "ldemul-list.h"
32 ld_emulation_xfer_type *ld_emulation;
38 ld_emulation->hll(name);
42 void ldemul_syslib(name)
45 ld_emulation->syslib(name);
51 ld_emulation->after_parse();
57 ld_emulation->before_parse();
63 ld_emulation->after_open ();
67 ldemul_after_allocation()
69 ld_emulation->after_allocation();
73 ldemul_before_allocation()
75 if (ld_emulation->before_allocation)
76 ld_emulation->before_allocation();
81 ldemul_set_output_arch()
83 ld_emulation->set_output_arch();
89 if (ld_emulation->finish)
90 ld_emulation->finish();
96 if (ld_emulation->set_symbols)
97 ld_emulation->set_symbols();
101 ldemul_create_output_section_statements()
103 if (ld_emulation->create_output_section_statements)
104 ld_emulation->create_output_section_statements();
108 ldemul_get_script(isfile)
111 return ld_emulation->get_script(isfile);
115 ldemul_open_dynamic_archive (arch, search, entry)
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);
126 ldemul_place_orphan (file, s)
127 lang_input_statement_type *file;
130 if (ld_emulation->place_orphan)
131 return (*ld_emulation->place_orphan) (file, s);
136 ldemul_parse_args (argc, 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);
148 /* Let the emulation code handle an unrecognized file. */
151 ldemul_unrecognized_file (entry)
152 lang_input_statement_type *entry;
154 if (ld_emulation->unrecognized_file)
155 return (*ld_emulation->unrecognized_file) (entry);
159 /* Let the emulation code handle a recognized file. */
162 ldemul_recognized_file (entry)
163 lang_input_statement_type *entry;
165 if (ld_emulation->recognized_file)
166 return (*ld_emulation->recognized_file) (entry);
171 ldemul_choose_target()
173 return ld_emulation->choose_target();
176 /* The default choose_target function. */
179 ldemul_default_target()
181 char *from_outside = getenv (TARGET_ENVIRON);
182 if (from_outside != (char *)NULL)
184 return ld_emulation->target_name;
188 after_parse_default()
194 after_open_default ()
199 after_allocation_default()
205 before_allocation_default()
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);
220 syslib_default(ignore)
223 info_msg (_("%S SYSLIB ignored\n"));
231 info_msg (_("%S HLL ignored\n"));
234 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
237 ldemul_choose_mode(target)
240 ld_emulation_xfer_type **eptr = ld_emulations;
241 /* Ignore "gld" prefix. */
242 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
244 for (; *eptr; eptr++)
246 if (strcmp(target, (*eptr)->emulation_name) == 0)
248 ld_emulation = *eptr;
252 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
253 einfo (_("Supported emulations: "));
254 ldemul_list_emulations (stderr);
259 ldemul_list_emulations (f)
262 ld_emulation_xfer_type **eptr = ld_emulations;
263 boolean first = true;
265 for (; *eptr; eptr++)
271 fprintf (f, "%s", (*eptr)->emulation_name);
276 ldemul_list_emulation_options (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);
297 fprintf (f, _(" no emulation specific options.\n"));