remove parentdir support; use INSTALL_XFORM
[deliverable/binutils-gdb.git] / ld / lnk960.em
CommitLineData
d73812a1 1cat >em_${EMULATION_NAME}.c <<EOF
6ecb2b74
PB
2/* intel coff loader emulation specific stuff
3 Copyright (C) 1991 Free Software Foundation, Inc.
4 Written by Steve Chamberlain steve@cygnus.com
5
6This file is part of GLD, the Gnu Linker.
7
8GLD is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GLD is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GLD; see the file COPYING. If not, write to
20the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22#include "bfd.h"
23#include "sysdep.h"
24
25/*#include "archures.h"*/
26#include "ld.h"
27#include "config.h"
28#include "ldemul.h"
29#include "ldmisc.h"
30#include "ldlang.h"
31#include "ldfile.h"
32
33extern boolean lang_float_flag;
34extern bfd *output_bfd;
35
36
37
38extern enum bfd_architecture ldfile_output_architecture;
39extern unsigned long ldfile_output_machine;
40extern char *ldfile_output_machine_name;
41
42
43typedef struct lib_list {
44 char *name;
45 struct lib_list *next;
46} lib_list_type;
47
48static lib_list_type *hll_list;
49static lib_list_type **hll_list_tail = &hll_list;
50
51static lib_list_type *syslib_list;
52static lib_list_type **syslib_list_tail = &syslib_list;
53
54
55static void
56append(list, name)
57lib_list_type ***list;
58char *name;
59{
60 lib_list_type *element =
61 (lib_list_type *)(ldmalloc(sizeof(lib_list_type)));
62
63 element->name = name;
64 element->next = (lib_list_type *)NULL;
65 **list = element;
66 *list = &element->next;
67
68}
69
70static boolean had_hll = false;
71static boolean had_hll_name = false;
72static void
73lnk960_hll(name)
74char *name;
75{
76 had_hll = true;
77 if (name != (char *)NULL) {
78 had_hll_name = true;
79 append(&hll_list_tail, name);
80 }
81}
82
83static void
84lnk960_syslib(name)
85char *name;
86{
87 append(&syslib_list_tail,name);
88}
89
90
91
92#ifdef GNU960
93
94static void
95lnk960_before_parse()
96{
97 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
98 char **p;
99 char *env ;
100
101 for ( p = env_variables; *p; p++ ){
102 env = (char *) getenv(*p);
103 if (env) {
104 ldfile_add_library_path(concat(env,"/lib/libcoff",""));
105 }
106 }
107
108 env= (char *) getenv("I960BASE");
109 if ( env ) {
110 ldfile_add_library_path(concat(env,"/lib",""));
111 }
112
113 ldfile_output_architecture = bfd_arch_i960;
114 ldfile_output_machine = bfd_mach_i960_core;
115}
116
117#else /* not GNU960 */
118
119static void
120lnk960_before_parse()
121{
122 char *name = getenv("I960BASE");
123
124 if (name == (char *)NULL) {
125 name = getenv("G960BASE");
126 if (name == (char *)NULL) {
127 einfo("%P%F I960BASE and G960BASE not set\n");
128 }
129 }
130
131
132 ldfile_add_library_path(concat(name,"/lib",""));
133 ldfile_output_architecture = bfd_arch_i960;
134 ldfile_output_machine = bfd_mach_i960_core;
135}
136
137#endif /* GNU960 */
138
139
140static void
141add_on(list, search)
142lib_list_type *list;
143lang_input_file_enum_type search;
144{
145 while (list) {
146 lang_add_input_file(list->name,
147 search,
148 (char *)NULL);
149 list = list->next;
150 }
151}
152static void lnk960_after_parse()
153{
154
155 /* If there has been no arch, default to -KB */
156 if (ldfile_output_machine_name[0] ==0) {
157 ldfile_add_arch("KB");
158 }
159
160 /* if there has been no hll list then add our own */
161
162 if(had_hll && !had_hll_name) {
163 append(&hll_list_tail,"cg");
164 if (ldfile_output_machine == bfd_mach_i960_ka_sa ||
165 ldfile_output_machine == bfd_mach_i960_ca) {
166 {
167 append(&hll_list_tail,"fpg");
168 }
169 }
170 }
171
172 add_on(hll_list, lang_input_file_is_l_enum);
173 add_on(syslib_list, lang_input_file_is_search_file_enum);
174}
175
176static void
177lnk960_before_allocation()
178{
179}
180static void
181lnk960_after_allocation()
182{
183 extern ld_config_type config;
184 if (config.relocateable_output == false) {
185 lang_abs_symbol_at_end_of(".text","_etext");
186 lang_abs_symbol_at_end_of(".data","_edata");
187 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
188 lang_abs_symbol_at_end_of(".bss","_end");
189 }
190}
191
192
193static struct
194 {
195 unsigned long number;
196 char *name;
197 }
198machine_table[] = {
199 bfd_mach_i960_core ,"CORE",
200 bfd_mach_i960_kb_sb ,"KB",
201 bfd_mach_i960_kb_sb ,"SB",
202 bfd_mach_i960_mc ,"MC",
203 bfd_mach_i960_xa ,"XA",
204 bfd_mach_i960_ca ,"CA",
205 bfd_mach_i960_ka_sa ,"KA",
206 bfd_mach_i960_ka_sa ,"SA",
207
208 bfd_mach_i960_core ,"core",
209 bfd_mach_i960_kb_sb ,"kb",
210 bfd_mach_i960_kb_sb ,"sb",
211 bfd_mach_i960_mc ,"mc",
212 bfd_mach_i960_xa ,"xa",
213 bfd_mach_i960_ca ,"ca",
214 bfd_mach_i960_ka_sa ,"ka",
215 bfd_mach_i960_ka_sa ,"sa",
216 0,(char *)NULL
217};
218
219static void
220lnk960_set_output_arch()
221{
222 /* Set the output architecture and machine if possible */
223 unsigned int i;
224 ldfile_output_machine = bfd_mach_i960_core;
225 for (i= 0; machine_table[i].name != (char*)NULL; i++) {
226 if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) {
227 ldfile_output_machine = machine_table[i].number;
228 break;
229 }
230 }
231 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine);
232}
233
234static char *
235lnk960_choose_target()
236{
237#ifdef GNU960
238
239 return bfd_make_targ_name(BFD_COFF_FORMAT, 0);
240
241#else
242
243 char *from_outside = getenv(TARGET_ENVIRON);
244 if (from_outside != (char *)NULL)
245 return from_outside;
246#ifdef LNK960_LITTLE
247 return "coff-Intel-little";
248#else
249 return "coff-Intel-big";
250#endif
251#endif
252
253}
254
255/* The default script if none is offered */
256static char *lnk960_script =
257#include "lnk960.x"
258;
259
260
261static char *lnk960_script_relocateable =
262#include "lnk960.xr"
263;
264
265static char *lnk960_get_script()
266{
267 extern ld_config_type config;
268 if (config.relocateable_output) {
269 return lnk960_script_relocateable;
270 }
271 return lnk960_script;
272}
273struct ld_emulation_xfer_struct ld_lnk960_emulation =
274{
275 lnk960_before_parse,
276 lnk960_syslib,
277 lnk960_hll,
278 lnk960_after_parse,
279 lnk960_after_allocation,
280 lnk960_set_output_arch,
281 lnk960_choose_target,
282 lnk960_before_allocation,
283 lnk960_get_script,
284 "lnk960",
285 ""
286};
287EOF
This page took 0.073921 seconds and 4 git commands to generate.