New revision from Andrew
[deliverable/binutils-gdb.git] / ld / ldemul.c
CommitLineData
4a6afc88
ILT
1/* ldemul.c -- clearing house for ld emulation states
2 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
f177a611
JG
3
4This file is part of GLD, the Gnu Linker.
5
6GLD is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
4a6afc88 8the Free Software Foundation; either version 2, or (at your option)
f177a611
JG
9any later version.
10
11GLD is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GLD; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
f177a611
JG
20#include "bfd.h"
21#include "sysdep.h"
22
23#include "config.h"
24#include "ld.h"
25#include "ldemul.h"
26#include "ldmisc.h"
b73b4131
ILT
27#include "ldexp.h"
28#include "ldlang.h"
4a6afc88
ILT
29#include "ldfile.h"
30#include "ldmain.h"
31#include "ldemul-list.h"
f177a611
JG
32
33ld_emulation_xfer_type *ld_emulation;
34
35void
36ldemul_hll(name)
4a6afc88 37 char *name;
f177a611
JG
38{
39 ld_emulation->hll(name);
40}
41
42
43void ldemul_syslib(name)
4a6afc88 44 char *name;
f177a611
JG
45{
46 ld_emulation->syslib(name);
47}
48
49void
50ldemul_after_parse()
51{
52 ld_emulation->after_parse();
53}
54
55void
56ldemul_before_parse()
57{
58 ld_emulation->before_parse();
59}
60
b73b4131
ILT
61void
62ldemul_after_open ()
63{
64 ld_emulation->after_open ();
65}
66
f177a611
JG
67void
68ldemul_after_allocation()
69{
70 ld_emulation->after_allocation();
71}
72
73void
74ldemul_before_allocation()
75{
4a6afc88 76 if (ld_emulation->before_allocation)
f177a611 77 ld_emulation->before_allocation();
f177a611
JG
78}
79
80
81void
82ldemul_set_output_arch()
83{
84 ld_emulation->set_output_arch();
85}
86
4a6afc88
ILT
87void
88ldemul_finish()
89{
90 if (ld_emulation->finish)
91 ld_emulation->finish();
92}
93
94void
95ldemul_create_output_section_statements()
96{
97 if (ld_emulation->create_output_section_statements)
98 ld_emulation->create_output_section_statements();
99}
100
101char *
102ldemul_get_script(isfile)
103 int *isfile;
104{
105 return ld_emulation->get_script(isfile);
106}
107
b73b4131
ILT
108boolean
109ldemul_open_dynamic_archive (arch, entry)
110 const char *arch;
111 lang_input_statement_type *entry;
112{
113 if (ld_emulation->open_dynamic_archive)
114 return (*ld_emulation->open_dynamic_archive) (arch, entry);
115 return false;
116}
117
118boolean
119ldemul_place_orphan (file, s)
120 lang_input_statement_type *file;
121 asection *s;
122{
123 if (ld_emulation->place_orphan)
124 return (*ld_emulation->place_orphan) (file, s);
125 return false;
126}
127
f177a611
JG
128char *
129ldemul_choose_target()
130{
131 return ld_emulation->choose_target();
132}
133
4a6afc88
ILT
134/* The default choose_target function. */
135
f177a611 136char *
4a6afc88 137ldemul_default_target()
f177a611 138{
4a6afc88
ILT
139 char *from_outside = getenv(TARGET_ENVIRON);
140 if (from_outside != (char *)NULL)
141 return from_outside;
142 return ld_emulation->target_name;
143}
144
145void
146after_parse_default()
147{
148
f177a611
JG
149}
150
b73b4131
ILT
151void
152after_open_default ()
153{
154}
155
f177a611 156void
4a6afc88
ILT
157after_allocation_default()
158{
159
160}
161
162void
163before_allocation_default()
164{
165
166}
167
168void
169set_output_arch_default()
170{
171 /* Set the output architecture and machine if possible */
172 bfd_set_arch_mach(output_bfd,
173 ldfile_output_architecture, ldfile_output_machine);
f177a611
JG
174}
175
b73b4131 176/*ARGSUSED*/
4a6afc88
ILT
177void
178syslib_default(ignore)
179 char *ignore;
180{
181 info_msg ("%S SYSLIB ignored\n");
182}
f177a611 183
b73b4131 184/*ARGSUSED*/
4a6afc88
ILT
185void
186hll_default(ignore)
187 char *ignore;
188{
189 info_msg ("%S HLL ignored\n");
190}
f177a611 191
4a6afc88
ILT
192ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST };
193
194void
195ldemul_choose_mode(target)
196 char *target;
197{
198 ld_emulation_xfer_type **eptr = ld_emulations;
199 /* Ignore "gld" prefix. */
200 if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd')
201 target += 3;
202 for (; *eptr; eptr++)
203 {
204 if (strcmp(target, (*eptr)->emulation_name) == 0)
205 {
206 ld_emulation = *eptr;
207 return;
208 }
209 }
210 einfo("%P%F: unrecognised emulation mode: %s\n",target);
211}
b73b4131
ILT
212
213void
214ldemul_list_emulations (f)
215 FILE *f;
216{
217 ld_emulation_xfer_type **eptr = ld_emulations;
218 boolean first = true;
219
220 for (; *eptr; eptr++)
221 {
222 if (first)
223 first = false;
224 else
225 fprintf (f, " ");
226 fprintf (f, "%s", (*eptr)->emulation_name);
227 }
228}
This page took 0.175763 seconds and 4 git commands to generate.