Add EXTERN references to __ctbpm __gp and __ep.
[binutils.git] / ld / ldemul.c
blobc90673b919d3dda6316fa006e68df2cbc387f800
1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000
3 Free Software Foundation, Inc.
5 This file is part of GLD, the Gnu Linker.
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.
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.
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. */
22 #include "bfd.h"
23 #include "sysdep.h"
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"
34 ld_emulation_xfer_type *ld_emulation;
36 void
37 ldemul_hll (name)
38 char *name;
40 ld_emulation->hll (name);
43 void
44 ldemul_syslib (name)
45 char *name;
47 ld_emulation->syslib (name);
50 void
51 ldemul_after_parse ()
53 ld_emulation->after_parse ();
56 void
57 ldemul_before_parse ()
59 ld_emulation->before_parse ();
62 void
63 ldemul_after_open ()
65 ld_emulation->after_open ();
68 void
69 ldemul_after_allocation ()
71 ld_emulation->after_allocation ();
74 void
75 ldemul_before_allocation ()
77 if (ld_emulation->before_allocation)
78 ld_emulation->before_allocation ();
81 void
82 ldemul_set_output_arch ()
84 ld_emulation->set_output_arch ();
87 void
88 ldemul_finish ()
90 if (ld_emulation->finish)
91 ld_emulation->finish ();
94 void
95 ldemul_set_symbols ()
97 if (ld_emulation->set_symbols)
98 ld_emulation->set_symbols ();
101 void
102 ldemul_create_output_section_statements ()
104 if (ld_emulation->create_output_section_statements)
105 ld_emulation->create_output_section_statements ();
108 char *
109 ldemul_get_script (isfile)
110 int *isfile;
112 return ld_emulation->get_script (isfile);
115 boolean
116 ldemul_open_dynamic_archive (arch, search, entry)
117 const char *arch;
118 search_dirs_type *search;
119 lang_input_statement_type *entry;
121 if (ld_emulation->open_dynamic_archive)
122 return (*ld_emulation->open_dynamic_archive) (arch, search, entry);
123 return false;
126 boolean
127 ldemul_place_orphan (file, s)
128 lang_input_statement_type *file;
129 asection *s;
131 if (ld_emulation->place_orphan)
132 return (*ld_emulation->place_orphan) (file, s);
133 return false;
137 ldemul_parse_args (argc, argv)
138 int argc;
139 char **argv;
141 /* Try and use the emulation parser if there is one. */
142 if (ld_emulation->parse_args)
144 return ld_emulation->parse_args (argc, argv);
146 return 0;
149 /* Let the emulation code handle an unrecognized file. */
151 boolean
152 ldemul_unrecognized_file (entry)
153 lang_input_statement_type *entry;
155 if (ld_emulation->unrecognized_file)
156 return (*ld_emulation->unrecognized_file) (entry);
157 return false;
160 /* Let the emulation code handle a recognized file. */
162 boolean
163 ldemul_recognized_file (entry)
164 lang_input_statement_type *entry;
166 if (ld_emulation->recognized_file)
167 return (*ld_emulation->recognized_file) (entry);
168 return false;
171 char *
172 ldemul_choose_target (argc, argv)
173 int argc;
174 char **argv;
176 return ld_emulation->choose_target (argc, argv);
180 /* The default choose_target function. */
182 char *
183 ldemul_default_target (argc, argv)
184 int argc ATTRIBUTE_UNUSED;
185 char **argv ATTRIBUTE_UNUSED;
187 char *from_outside = getenv (TARGET_ENVIRON);
188 if (from_outside != (char *) NULL)
189 return from_outside;
190 return ld_emulation->target_name;
193 void
194 after_parse_default ()
198 void
199 after_open_default ()
203 void
204 after_allocation_default ()
208 void
209 before_allocation_default ()
213 void
214 set_output_arch_default ()
216 /* Set the output architecture and machine if possible. */
217 bfd_set_arch_mach (output_bfd,
218 ldfile_output_architecture, ldfile_output_machine);
221 void
222 syslib_default (ignore)
223 char *ignore ATTRIBUTE_UNUSED;
225 info_msg (_("%S SYSLIB ignored\n"));
228 void
229 hll_default (ignore)
230 char *ignore ATTRIBUTE_UNUSED;
232 info_msg (_("%S HLL ignored\n"));
235 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
237 void
238 ldemul_choose_mode (target)
239 char *target;
241 ld_emulation_xfer_type **eptr = ld_emulations;
242 /* Ignore "gld" prefix. */
243 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
244 target += 3;
245 for (; *eptr; eptr++)
247 if (strcmp (target, (*eptr)->emulation_name) == 0)
249 ld_emulation = *eptr;
250 return;
253 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
254 einfo (_("Supported emulations: "));
255 ldemul_list_emulations (stderr);
256 einfo ("%F\n");
259 void
260 ldemul_list_emulations (f)
261 FILE *f;
263 ld_emulation_xfer_type **eptr = ld_emulations;
264 boolean first = true;
266 for (; *eptr; eptr++)
268 if (first)
269 first = false;
270 else
271 fprintf (f, " ");
272 fprintf (f, "%s", (*eptr)->emulation_name);
276 void
277 ldemul_list_emulation_options (f)
278 FILE *f;
280 ld_emulation_xfer_type **eptr;
281 int options_found = 0;
283 for (eptr = ld_emulations; *eptr; eptr++)
285 ld_emulation_xfer_type *emul = *eptr;
287 if (emul->list_options)
289 fprintf (f, "%s: \n", emul->emulation_name);
291 emul->list_options (f);
293 options_found = 1;
297 if (! options_found)
298 fprintf (f, _(" no emulation specific options.\n"));
302 ldemul_find_potential_libraries (name, entry)
303 char *name;
304 lang_input_statement_type *entry;
306 if (ld_emulation->find_potential_libraries)
307 return ld_emulation->find_potential_libraries (name, entry);
309 return 0;
312 struct bfd_elf_version_expr *
313 ldemul_new_vers_pattern (entry)
314 struct bfd_elf_version_expr *entry;
316 if (ld_emulation->new_vers_pattern)
317 entry = (*ld_emulation->new_vers_pattern) (entry);
318 return entry;