1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003
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
33 #include "ldemul-list.h"
35 ld_emulation_xfer_type
*ld_emulation
;
41 ld_emulation
->hll (name
);
48 ld_emulation
->syslib (name
);
54 ld_emulation
->after_parse ();
58 ldemul_before_parse ()
60 ld_emulation
->before_parse ();
66 ld_emulation
->after_open ();
70 ldemul_after_allocation ()
72 ld_emulation
->after_allocation ();
76 ldemul_before_allocation ()
78 if (ld_emulation
->before_allocation
)
79 ld_emulation
->before_allocation ();
83 ldemul_set_output_arch ()
85 ld_emulation
->set_output_arch ();
91 if (ld_emulation
->finish
)
92 ld_emulation
->finish ();
98 if (ld_emulation
->set_symbols
)
99 ld_emulation
->set_symbols ();
103 ldemul_create_output_section_statements ()
105 if (ld_emulation
->create_output_section_statements
)
106 ld_emulation
->create_output_section_statements ();
110 ldemul_get_script (isfile
)
113 return ld_emulation
->get_script (isfile
);
117 ldemul_open_dynamic_archive (arch
, search
, entry
)
119 search_dirs_type
*search
;
120 lang_input_statement_type
*entry
;
122 if (ld_emulation
->open_dynamic_archive
)
123 return (*ld_emulation
->open_dynamic_archive
) (arch
, search
, entry
);
128 ldemul_place_orphan (file
, s
)
129 lang_input_statement_type
*file
;
132 if (ld_emulation
->place_orphan
)
133 return (*ld_emulation
->place_orphan
) (file
, s
);
138 ldemul_add_options (ns
, shortopts
, nl
, longopts
, nrl
, really_longopts
)
142 struct option
**longopts
;
144 struct option
**really_longopts
;
146 if (ld_emulation
->add_options
)
147 (*ld_emulation
->add_options
) (ns
, shortopts
, nl
, longopts
,
148 nrl
, really_longopts
);
152 ldemul_handle_option (optc
)
155 if (ld_emulation
->handle_option
)
156 return (*ld_emulation
->handle_option
) (optc
);
161 ldemul_parse_args (argc
, argv
)
165 /* Try and use the emulation parser if there is one. */
166 if (ld_emulation
->parse_args
)
167 return (*ld_emulation
->parse_args
) (argc
, argv
);
171 /* Let the emulation code handle an unrecognized file. */
174 ldemul_unrecognized_file (entry
)
175 lang_input_statement_type
*entry
;
177 if (ld_emulation
->unrecognized_file
)
178 return (*ld_emulation
->unrecognized_file
) (entry
);
182 /* Let the emulation code handle a recognized file. */
185 ldemul_recognized_file (entry
)
186 lang_input_statement_type
*entry
;
188 if (ld_emulation
->recognized_file
)
189 return (*ld_emulation
->recognized_file
) (entry
);
194 ldemul_choose_target (argc
, argv
)
198 return ld_emulation
->choose_target (argc
, argv
);
202 /* The default choose_target function. */
205 ldemul_default_target (argc
, argv
)
206 int argc ATTRIBUTE_UNUSED
;
207 char **argv ATTRIBUTE_UNUSED
;
209 char *from_outside
= getenv (TARGET_ENVIRON
);
210 if (from_outside
!= (char *) NULL
)
212 return ld_emulation
->target_name
;
216 after_parse_default ()
221 after_open_default ()
226 after_allocation_default ()
231 before_allocation_default ()
236 set_output_arch_default ()
238 /* Set the output architecture and machine if possible. */
239 bfd_set_arch_mach (output_bfd
,
240 ldfile_output_architecture
, ldfile_output_machine
);
244 syslib_default (ignore
)
245 char *ignore ATTRIBUTE_UNUSED
;
247 info_msg (_("%S SYSLIB ignored\n"));
252 char *ignore ATTRIBUTE_UNUSED
;
254 info_msg (_("%S HLL ignored\n"));
257 ld_emulation_xfer_type
*ld_emulations
[] = { EMULATION_LIST
};
260 ldemul_choose_mode (target
)
263 ld_emulation_xfer_type
**eptr
= ld_emulations
;
264 /* Ignore "gld" prefix. */
265 if (target
[0] == 'g' && target
[1] == 'l' && target
[2] == 'd')
267 for (; *eptr
; eptr
++)
269 if (strcmp (target
, (*eptr
)->emulation_name
) == 0)
271 ld_emulation
= *eptr
;
275 einfo (_("%P: unrecognised emulation mode: %s\n"), target
);
276 einfo (_("Supported emulations: "));
277 ldemul_list_emulations (stderr
);
282 ldemul_list_emulations (f
)
285 ld_emulation_xfer_type
**eptr
= ld_emulations
;
286 bfd_boolean first
= TRUE
;
288 for (; *eptr
; eptr
++)
294 fprintf (f
, "%s", (*eptr
)->emulation_name
);
299 ldemul_list_emulation_options (f
)
302 ld_emulation_xfer_type
**eptr
;
303 int options_found
= 0;
305 for (eptr
= ld_emulations
; *eptr
; eptr
++)
307 ld_emulation_xfer_type
*emul
= *eptr
;
309 if (emul
->list_options
)
311 fprintf (f
, "%s: \n", emul
->emulation_name
);
313 emul
->list_options (f
);
320 fprintf (f
, _(" no emulation specific options.\n"));
324 ldemul_find_potential_libraries (name
, entry
)
326 lang_input_statement_type
*entry
;
328 if (ld_emulation
->find_potential_libraries
)
329 return ld_emulation
->find_potential_libraries (name
, entry
);
334 struct bfd_elf_version_expr
*
335 ldemul_new_vers_pattern (entry
)
336 struct bfd_elf_version_expr
*entry
;
338 if (ld_emulation
->new_vers_pattern
)
339 entry
= (*ld_emulation
->new_vers_pattern
) (entry
);