]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/ldemul.c
s/boolean/bfd_boolean/ s/true/TRUE/ s/false/FALSE/. Simplify
[thirdparty/binutils-gdb.git] / ld / ldemul.c
CommitLineData
252b5132 1/* ldemul.c -- clearing house for ld emulation states
b34976b6 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002
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
b34976b6 115bfd_boolean
252b5132
RH
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);
b34976b6 123 return FALSE;
252b5132
RH
124}
125
b34976b6 126bfd_boolean
252b5132
RH
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);
b34976b6 133 return FALSE;
252b5132
RH
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
b34976b6 151bfd_boolean
252b5132
RH
152ldemul_unrecognized_file (entry)
153 lang_input_statement_type *entry;
154{
155 if (ld_emulation->unrecognized_file)
156 return (*ld_emulation->unrecognized_file) (entry);
b34976b6 157 return FALSE;
252b5132
RH
158}
159
160/* Let the emulation code handle a recognized file. */
161
b34976b6 162bfd_boolean
252b5132
RH
163ldemul_recognized_file (entry)
164 lang_input_statement_type *entry;
165{
166 if (ld_emulation->recognized_file)
167 return (*ld_emulation->recognized_file) (entry);
b34976b6 168 return FALSE;
252b5132
RH
169}
170
171char *
742aeb63 172ldemul_choose_target (argc, argv)
658957db
KH
173 int argc;
174 char **argv;
252b5132 175{
742aeb63 176 return ld_emulation->choose_target (argc, argv);
252b5132
RH
177}
178
742aeb63 179
252b5132
RH
180/* The default choose_target function. */
181
182char *
742aeb63
TR
183ldemul_default_target (argc, argv)
184 int argc ATTRIBUTE_UNUSED;
185 char **argv ATTRIBUTE_UNUSED;
252b5132
RH
186{
187 char *from_outside = getenv (TARGET_ENVIRON);
4de2d33d 188 if (from_outside != (char *) NULL)
252b5132
RH
189 return from_outside;
190 return ld_emulation->target_name;
191}
192
4de2d33d
KH
193void
194after_parse_default ()
252b5132 195{
252b5132
RH
196}
197
198void
199after_open_default ()
200{
201}
202
203void
4de2d33d 204after_allocation_default ()
252b5132 205{
252b5132
RH
206}
207
208void
4de2d33d 209before_allocation_default ()
252b5132 210{
252b5132
RH
211}
212
213void
4de2d33d 214set_output_arch_default ()
252b5132 215{
4de2d33d
KH
216 /* Set the output architecture and machine if possible. */
217 bfd_set_arch_mach (output_bfd,
218 ldfile_output_architecture, ldfile_output_machine);
252b5132
RH
219}
220
252b5132 221void
4de2d33d
KH
222syslib_default (ignore)
223 char *ignore ATTRIBUTE_UNUSED;
252b5132
RH
224{
225 info_msg (_("%S SYSLIB ignored\n"));
226}
227
252b5132 228void
4de2d33d
KH
229hll_default (ignore)
230 char *ignore ATTRIBUTE_UNUSED;
252b5132
RH
231{
232 info_msg (_("%S HLL ignored\n"));
233}
234
235ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
236
237void
4de2d33d 238ldemul_choose_mode (target)
252b5132
RH
239 char *target;
240{
4de2d33d
KH
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++)
246 {
247 if (strcmp (target, (*eptr)->emulation_name) == 0)
248 {
249 ld_emulation = *eptr;
250 return;
251 }
252 }
253 einfo (_("%P: unrecognised emulation mode: %s\n"), target);
254 einfo (_("Supported emulations: "));
255 ldemul_list_emulations (stderr);
256 einfo ("%F\n");
252b5132
RH
257}
258
259void
260ldemul_list_emulations (f)
261 FILE *f;
262{
263 ld_emulation_xfer_type **eptr = ld_emulations;
b34976b6 264 bfd_boolean first = TRUE;
252b5132
RH
265
266 for (; *eptr; eptr++)
267 {
268 if (first)
b34976b6 269 first = FALSE;
252b5132
RH
270 else
271 fprintf (f, " ");
272 fprintf (f, "%s", (*eptr)->emulation_name);
273 }
274}
275
276void
277ldemul_list_emulation_options (f)
4de2d33d 278 FILE *f;
252b5132 279{
4de2d33d 280 ld_emulation_xfer_type **eptr;
252b5132 281 int options_found = 0;
4de2d33d
KH
282
283 for (eptr = ld_emulations; *eptr; eptr++)
252b5132 284 {
4de2d33d
KH
285 ld_emulation_xfer_type *emul = *eptr;
286
252b5132
RH
287 if (emul->list_options)
288 {
289 fprintf (f, "%s: \n", emul->emulation_name);
4de2d33d 290
252b5132
RH
291 emul->list_options (f);
292
293 options_found = 1;
294 }
295 }
4de2d33d 296
252b5132
RH
297 if (! options_found)
298 fprintf (f, _(" no emulation specific options.\n"));
299}
344a211f
NC
300
301int
302ldemul_find_potential_libraries (name, entry)
4de2d33d
KH
303 char *name;
304 lang_input_statement_type *entry;
344a211f
NC
305{
306 if (ld_emulation->find_potential_libraries)
307 return ld_emulation->find_potential_libraries (name, entry);
308
309 return 0;
310}
fac1652d
AM
311
312struct bfd_elf_version_expr *
313ldemul_new_vers_pattern (entry)
314 struct bfd_elf_version_expr *entry;
315{
316 if (ld_emulation->new_vers_pattern)
317 entry = (*ld_emulation->new_vers_pattern) (entry);
318 return entry;
319}