Commit | Line | Data |
---|---|---|
4a6afc88 ILT |
1 | /* ldemul.c -- clearing house for ld emulation states |
2 | Copyright (C) 1991, 1993 Free Software Foundation, Inc. | |
f177a611 JG |
3 | |
4 | This file is part of GLD, the Gnu Linker. | |
5 | ||
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 | |
4a6afc88 | 8 | the Free Software Foundation; either version 2, or (at your option) |
f177a611 JG |
9 | any later version. |
10 | ||
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. | |
15 | ||
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. */ | |
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 | |
33 | ld_emulation_xfer_type *ld_emulation; | |
34 | ||
35 | void | |
36 | ldemul_hll(name) | |
4a6afc88 | 37 | char *name; |
f177a611 JG |
38 | { |
39 | ld_emulation->hll(name); | |
40 | } | |
41 | ||
42 | ||
43 | void ldemul_syslib(name) | |
4a6afc88 | 44 | char *name; |
f177a611 JG |
45 | { |
46 | ld_emulation->syslib(name); | |
47 | } | |
48 | ||
49 | void | |
50 | ldemul_after_parse() | |
51 | { | |
52 | ld_emulation->after_parse(); | |
53 | } | |
54 | ||
55 | void | |
56 | ldemul_before_parse() | |
57 | { | |
58 | ld_emulation->before_parse(); | |
59 | } | |
60 | ||
b73b4131 ILT |
61 | void |
62 | ldemul_after_open () | |
63 | { | |
64 | ld_emulation->after_open (); | |
65 | } | |
66 | ||
f177a611 JG |
67 | void |
68 | ldemul_after_allocation() | |
69 | { | |
70 | ld_emulation->after_allocation(); | |
71 | } | |
72 | ||
73 | void | |
74 | ldemul_before_allocation() | |
75 | { | |
4a6afc88 | 76 | if (ld_emulation->before_allocation) |
f177a611 | 77 | ld_emulation->before_allocation(); |
f177a611 JG |
78 | } |
79 | ||
80 | ||
81 | void | |
82 | ldemul_set_output_arch() | |
83 | { | |
84 | ld_emulation->set_output_arch(); | |
85 | } | |
86 | ||
4a6afc88 ILT |
87 | void |
88 | ldemul_finish() | |
89 | { | |
90 | if (ld_emulation->finish) | |
91 | ld_emulation->finish(); | |
92 | } | |
93 | ||
94 | void | |
95 | ldemul_create_output_section_statements() | |
96 | { | |
97 | if (ld_emulation->create_output_section_statements) | |
98 | ld_emulation->create_output_section_statements(); | |
99 | } | |
100 | ||
101 | char * | |
102 | ldemul_get_script(isfile) | |
103 | int *isfile; | |
104 | { | |
105 | return ld_emulation->get_script(isfile); | |
106 | } | |
107 | ||
b73b4131 ILT |
108 | boolean |
109 | ldemul_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 | ||
118 | boolean | |
119 | ldemul_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 |
128 | char * |
129 | ldemul_choose_target() | |
130 | { | |
131 | return ld_emulation->choose_target(); | |
132 | } | |
133 | ||
4a6afc88 ILT |
134 | /* The default choose_target function. */ |
135 | ||
f177a611 | 136 | char * |
4a6afc88 | 137 | ldemul_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 | ||
145 | void | |
146 | after_parse_default() | |
147 | { | |
148 | ||
f177a611 JG |
149 | } |
150 | ||
b73b4131 ILT |
151 | void |
152 | after_open_default () | |
153 | { | |
154 | } | |
155 | ||
f177a611 | 156 | void |
4a6afc88 ILT |
157 | after_allocation_default() |
158 | { | |
159 | ||
160 | } | |
161 | ||
162 | void | |
163 | before_allocation_default() | |
164 | { | |
165 | ||
166 | } | |
167 | ||
168 | void | |
169 | set_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 |
177 | void |
178 | syslib_default(ignore) | |
179 | char *ignore; | |
180 | { | |
181 | info_msg ("%S SYSLIB ignored\n"); | |
182 | } | |
f177a611 | 183 | |
b73b4131 | 184 | /*ARGSUSED*/ |
4a6afc88 ILT |
185 | void |
186 | hll_default(ignore) | |
187 | char *ignore; | |
188 | { | |
189 | info_msg ("%S HLL ignored\n"); | |
190 | } | |
f177a611 | 191 | |
4a6afc88 ILT |
192 | ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST }; |
193 | ||
194 | void | |
195 | ldemul_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 | |
213 | void | |
214 | ldemul_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 | } |