1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<EOF
4 /* intel coff loader emulation specific stuff
5 Copyright (C) 1991, 1993 Free Software Foundation, Inc.
6 Written by Steve Chamberlain steve@cygnus.com
8 This file is part of GLD, the Gnu Linker.
10 GLD is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GLD is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GLD; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #include "libiberty.h"
29 /*#include "archures.h"*/
38 typedef struct lib_list {
40 struct lib_list *next;
43 static lib_list_type *hll_list;
44 static lib_list_type **hll_list_tail = &hll_list;
46 static lib_list_type *syslib_list;
47 static lib_list_type **syslib_list_tail = &syslib_list;
52 lib_list_type ***list;
55 lib_list_type *element =
56 (lib_list_type *)(xmalloc(sizeof(lib_list_type)));
59 element->next = (lib_list_type *)NULL;
61 *list = &element->next;
65 static boolean had_hll = false;
66 static boolean had_hll_name = false;
73 if (name != (char *)NULL) {
75 append(&hll_list_tail, name);
83 append(&syslib_list_tail,name);
92 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
96 for ( p = env_variables; *p; p++ ){
97 env = (char *) getenv(*p);
99 ldfile_add_library_path(concat(env,"/lib/libcoff",""), false);
103 env= (char *) getenv("I960BASE");
105 ldfile_add_library_path(concat(env,"/lib",""), false);
108 ldfile_output_architecture = bfd_arch_i960;
109 ldfile_output_machine = bfd_mach_i960_core;
112 #else /* not GNU960 */
115 lnk960_before_parse()
117 char *name = getenv("I960BASE");
119 if (name == (char *)NULL) {
120 name = getenv("G960BASE");
121 if (name == (char *)NULL) {
122 einfo("%P%F I960BASE and G960BASE not set\n");
127 ldfile_add_library_path(concat(name,"/lib",""), false);
128 ldfile_output_architecture = bfd_arch_i960;
129 ldfile_output_machine = bfd_mach_i960_core;
138 lang_input_file_enum_type search;
141 lang_add_input_file(list->name,
150 /* If there has been no arch, default to -KB */
151 if (ldfile_output_machine_name[0] ==0) {
152 ldfile_add_arch("KB");
155 /* if there has been no hll list then add our own */
157 if(had_hll && !had_hll_name) {
158 append(&hll_list_tail,"cg");
159 if (ldfile_output_machine == bfd_mach_i960_ka_sa ||
160 ldfile_output_machine == bfd_mach_i960_ca) {
162 append(&hll_list_tail,"fpg");
167 add_on(hll_list, lang_input_file_is_l_enum);
168 add_on(syslib_list, lang_input_file_is_search_file_enum);
172 lnk960_before_allocation()
177 lnk960_after_allocation()
179 if (link_info.relocateable == false) {
180 lang_abs_symbol_at_end_of(".text","_etext");
181 lang_abs_symbol_at_end_of(".data","_edata");
182 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
183 lang_abs_symbol_at_end_of(".bss","_end");
190 unsigned long number;
195 { bfd_mach_i960_core ,"CORE" },
196 { bfd_mach_i960_kb_sb ,"KB" },
197 { bfd_mach_i960_kb_sb ,"SB" },
198 { bfd_mach_i960_mc ,"MC" },
199 { bfd_mach_i960_xa ,"XA" },
200 { bfd_mach_i960_ca ,"CA" },
201 { bfd_mach_i960_ka_sa ,"KA" },
202 { bfd_mach_i960_ka_sa ,"SA" },
203 { bfd_mach_i960_jx ,"JX" },
204 { bfd_mach_i960_hx ,"HX" },
206 { bfd_mach_i960_core ,"core" },
207 { bfd_mach_i960_kb_sb ,"kb" },
208 { bfd_mach_i960_kb_sb ,"sb" },
209 { bfd_mach_i960_mc ,"mc" },
210 { bfd_mach_i960_xa ,"xa" },
211 { bfd_mach_i960_ca ,"ca" },
212 { bfd_mach_i960_ka_sa ,"ka" },
213 { bfd_mach_i960_ka_sa ,"sa" },
214 { bfd_mach_i960_jx ,"jx" },
215 { bfd_mach_i960_hx ,"hx" },
221 lnk960_set_output_arch()
223 /* Set the output architecture and machine if possible */
225 ldfile_output_machine = bfd_mach_i960_core;
226 for (i= 0; machine_table[i].name != (char*)NULL; i++) {
227 if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) {
228 ldfile_output_machine = machine_table[i].number;
232 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine);
236 lnk960_choose_target()
240 return bfd_make_targ_name(BFD_COFF_FORMAT, 0);
244 char *from_outside = getenv(TARGET_ENVIRON);
245 if (from_outside != (char *)NULL)
248 return "coff-Intel-little";
250 return "coff-Intel-big";
257 lnk960_get_script(isfile)
261 if test -n "$COMPILE_IN"
263 # Scripts compiled in.
265 # sed commands to quote an ld script as a C string.
272 cat >>e${EMULATION_NAME}.c <<EOF
275 if (link_info.relocateable == true && config.build_constructors == true)
276 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
277 else if (link_info.relocateable == true)
278 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
279 else if (!config.text_read_only)
280 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
281 else if (!config.magic_demand_paged)
282 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
284 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
289 # Scripts read from the filesystem.
291 cat >>e${EMULATION_NAME}.c <<EOF
295 if (link_info.relocateable == true && config.build_constructors == true)
296 return "ldscripts/${EMULATION_NAME}.xu";
297 else if (link_info.relocateable == true)
298 return "ldscripts/${EMULATION_NAME}.xr";
299 else if (!config.text_read_only)
300 return "ldscripts/${EMULATION_NAME}.xbn";
301 else if (!config.magic_demand_paged)
302 return "ldscripts/${EMULATION_NAME}.xn";
304 return "ldscripts/${EMULATION_NAME}.x";
310 cat >>e${EMULATION_NAME}.c <<EOF
312 struct ld_emulation_xfer_struct ld_lnk960_emulation =
318 NULL, /* after_open */
319 lnk960_after_allocation,
320 lnk960_set_output_arch,
321 lnk960_choose_target,
322 lnk960_before_allocation,