1 /* ldemul.c -- clearing house for ld emulation states
2 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
4 This file is part of GLD, the Gnu Linker.
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29 #include "ldemul-list.h"
31 ld_emulation_xfer_type *ld_emulation;
37 ld_emulation->hll(name);
41 void ldemul_syslib(name)
44 ld_emulation->syslib(name);
50 ld_emulation->after_parse();
56 ld_emulation->before_parse();
60 ldemul_after_allocation()
62 ld_emulation->after_allocation();
66 ldemul_before_allocation()
68 if (ld_emulation->before_allocation)
69 ld_emulation->before_allocation();
74 ldemul_set_output_arch()
76 ld_emulation->set_output_arch();
82 if (ld_emulation->finish)
83 ld_emulation->finish();
87 ldemul_create_output_section_statements()
89 if (ld_emulation->create_output_section_statements)
90 ld_emulation->create_output_section_statements();
94 ldemul_get_script(isfile)
97 return ld_emulation->get_script(isfile);
101 ldemul_choose_target()
103 return ld_emulation->choose_target();
106 /* The default choose_target function. */
109 ldemul_default_target()
111 char *from_outside = getenv(TARGET_ENVIRON);
112 if (from_outside != (char *)NULL)
114 return ld_emulation->target_name;
118 after_parse_default()
124 after_allocation_default()
130 before_allocation_default()
136 set_output_arch_default()
138 /* Set the output architecture and machine if possible */
139 bfd_set_arch_mach(output_bfd,
140 ldfile_output_architecture, ldfile_output_machine);
144 syslib_default(ignore)
147 info_msg ("%S SYSLIB ignored\n");
154 info_msg ("%S HLL ignored\n");
157 ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
160 ldemul_choose_mode(target)
163 ld_emulation_xfer_type **eptr = ld_emulations;
164 /* Ignore "gld" prefix. */
165 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
167 for (; *eptr; eptr++)
169 if (strcmp(target, (*eptr)->emulation_name) == 0)
171 ld_emulation = *eptr;
175 einfo("%P%F: unrecognised emulation mode: %s\n",target);