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. */
31 #include "ldemul-list.h"
33 ld_emulation_xfer_type
*ld_emulation
;
39 ld_emulation
->hll(name
);
43 void ldemul_syslib(name
)
46 ld_emulation
->syslib(name
);
52 ld_emulation
->after_parse();
58 ld_emulation
->before_parse();
64 ld_emulation
->after_open ();
68 ldemul_after_allocation()
70 ld_emulation
->after_allocation();
74 ldemul_before_allocation()
76 if (ld_emulation
->before_allocation
)
77 ld_emulation
->before_allocation();
82 ldemul_set_output_arch()
84 ld_emulation
->set_output_arch();
90 if (ld_emulation
->finish
)
91 ld_emulation
->finish();
95 ldemul_create_output_section_statements()
97 if (ld_emulation
->create_output_section_statements
)
98 ld_emulation
->create_output_section_statements();
102 ldemul_get_script(isfile
)
105 return ld_emulation
->get_script(isfile
);
109 ldemul_open_dynamic_archive (arch
, entry
)
111 lang_input_statement_type
*entry
;
113 if (ld_emulation
->open_dynamic_archive
)
114 return (*ld_emulation
->open_dynamic_archive
) (arch
, entry
);
119 ldemul_place_orphan (file
, s
)
120 lang_input_statement_type
*file
;
123 if (ld_emulation
->place_orphan
)
124 return (*ld_emulation
->place_orphan
) (file
, s
);
129 ldemul_choose_target()
131 return ld_emulation
->choose_target();
134 /* The default choose_target function. */
137 ldemul_default_target()
139 char *from_outside
= getenv(TARGET_ENVIRON
);
140 if (from_outside
!= (char *)NULL
)
142 return ld_emulation
->target_name
;
146 after_parse_default()
152 after_open_default ()
157 after_allocation_default()
163 before_allocation_default()
169 set_output_arch_default()
171 /* Set the output architecture and machine if possible */
172 bfd_set_arch_mach(output_bfd
,
173 ldfile_output_architecture
, ldfile_output_machine
);
178 syslib_default(ignore
)
181 info_msg ("%S SYSLIB ignored\n");
189 info_msg ("%S HLL ignored\n");
192 ld_emulation_xfer_type
*ld_emulations
[] = { EMULATION_LIST
};
195 ldemul_choose_mode(target
)
198 ld_emulation_xfer_type
**eptr
= ld_emulations
;
199 /* Ignore "gld" prefix. */
200 if (target
[0] == 'g' && target
[1] == 'l' && target
[2] == 'd')
202 for (; *eptr
; eptr
++)
204 if (strcmp(target
, (*eptr
)->emulation_name
) == 0)
206 ld_emulation
= *eptr
;
210 einfo("%P%F: unrecognised emulation mode: %s\n",target
);
214 ldemul_list_emulations (f
)
217 ld_emulation_xfer_type
**eptr
= ld_emulations
;
218 boolean first
= true;
220 for (; *eptr
; eptr
++)
226 fprintf (f
, "%s", (*eptr
)->emulation_name
);