1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 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)
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
32 #include "ldemul-list.h"
34 ld_emulation_xfer_type
*ld_emulation
;
40 ld_emulation
->hll (name
);
47 ld_emulation
->syslib (name
);
53 ld_emulation
->after_parse ();
57 ldemul_before_parse ()
59 ld_emulation
->before_parse ();
65 ld_emulation
->after_open ();
69 ldemul_after_allocation ()
71 ld_emulation
->after_allocation ();
75 ldemul_before_allocation ()
77 if (ld_emulation
->before_allocation
)
78 ld_emulation
->before_allocation ();
82 ldemul_set_output_arch ()
84 ld_emulation
->set_output_arch ();
90 if (ld_emulation
->finish
)
91 ld_emulation
->finish ();
97 if (ld_emulation
->set_symbols
)
98 ld_emulation
->set_symbols ();
102 ldemul_create_output_section_statements ()
104 if (ld_emulation
->create_output_section_statements
)
105 ld_emulation
->create_output_section_statements ();
109 ldemul_get_script (isfile
)
112 return ld_emulation
->get_script (isfile
);
116 ldemul_open_dynamic_archive (arch
, search
, entry
)
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
);
127 ldemul_place_orphan (file
, s
)
128 lang_input_statement_type
*file
;
131 if (ld_emulation
->place_orphan
)
132 return (*ld_emulation
->place_orphan
) (file
, s
);
137 ldemul_parse_args (argc
, 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
);
149 /* Let the emulation code handle an unrecognized file. */
152 ldemul_unrecognized_file (entry
)
153 lang_input_statement_type
*entry
;
155 if (ld_emulation
->unrecognized_file
)
156 return (*ld_emulation
->unrecognized_file
) (entry
);
160 /* Let the emulation code handle a recognized file. */
163 ldemul_recognized_file (entry
)
164 lang_input_statement_type
*entry
;
166 if (ld_emulation
->recognized_file
)
167 return (*ld_emulation
->recognized_file
) (entry
);
172 ldemul_choose_target ()
174 return ld_emulation
->choose_target ();
177 /* The default choose_target function. */
180 ldemul_default_target ()
182 char *from_outside
= getenv (TARGET_ENVIRON
);
183 if (from_outside
!= (char *) NULL
)
185 return ld_emulation
->target_name
;
189 after_parse_default ()
195 after_open_default ()
200 after_allocation_default ()
206 before_allocation_default ()
212 set_output_arch_default ()
214 /* Set the output architecture and machine if possible. */
215 bfd_set_arch_mach (output_bfd
,
216 ldfile_output_architecture
, ldfile_output_machine
);
220 syslib_default (ignore
)
221 char *ignore ATTRIBUTE_UNUSED
;
223 info_msg (_("%S SYSLIB ignored\n"));
228 char *ignore ATTRIBUTE_UNUSED
;
230 info_msg (_("%S HLL ignored\n"));
233 ld_emulation_xfer_type
*ld_emulations
[] = { EMULATION_LIST
};
236 ldemul_choose_mode (target
)
239 ld_emulation_xfer_type
**eptr
= ld_emulations
;
240 /* Ignore "gld" prefix. */
241 if (target
[0] == 'g' && target
[1] == 'l' && target
[2] == 'd')
243 for (; *eptr
; eptr
++)
245 if (strcmp (target
, (*eptr
)->emulation_name
) == 0)
247 ld_emulation
= *eptr
;
251 einfo (_("%P: unrecognised emulation mode: %s\n"), target
);
252 einfo (_("Supported emulations: "));
253 ldemul_list_emulations (stderr
);
258 ldemul_list_emulations (f
)
261 ld_emulation_xfer_type
**eptr
= ld_emulations
;
262 boolean first
= true;
264 for (; *eptr
; eptr
++)
270 fprintf (f
, "%s", (*eptr
)->emulation_name
);
275 ldemul_list_emulation_options (f
)
278 ld_emulation_xfer_type
**eptr
;
279 int options_found
= 0;
281 for (eptr
= ld_emulations
; *eptr
; eptr
++)
283 ld_emulation_xfer_type
*emul
= *eptr
;
285 if (emul
->list_options
)
287 fprintf (f
, "%s: \n", emul
->emulation_name
);
289 emul
->list_options (f
);
296 fprintf (f
, _(" no emulation specific options.\n"));
300 ldemul_find_potential_libraries (name
, entry
)
302 lang_input_statement_type
*entry
;
304 if (ld_emulation
->find_potential_libraries
)
305 return ld_emulation
->find_potential_libraries (name
, entry
);