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