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