1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >em_${EMULATION_NAME}.c <<EOF
4 /* intel coff loader emulation specific stuff
5 Copyright (C) 1991 Free Software Foundation, Inc.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
27 /*#include "archures.h"*/
35 extern boolean lang_float_flag;
36 extern bfd *output_bfd;
40 extern enum bfd_architecture ldfile_output_architecture;
41 extern unsigned long ldfile_output_machine;
42 extern char *ldfile_output_machine_name;
45 typedef struct lib_list {
47 struct lib_list *next;
50 static lib_list_type *hll_list;
51 static lib_list_type **hll_list_tail = &hll_list;
53 static lib_list_type *syslib_list;
54 static lib_list_type **syslib_list_tail = &syslib_list;
59 lib_list_type ***list;
62 lib_list_type *element =
63 (lib_list_type *)(ldmalloc(sizeof(lib_list_type)));
66 element->next = (lib_list_type *)NULL;
68 *list = &element->next;
72 static boolean had_hll = false;
73 static boolean had_hll_name = false;
79 if (name != (char *)NULL) {
81 append(&hll_list_tail, name);
89 append(&syslib_list_tail,name);
99 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
103 for ( p = env_variables; *p; p++ ){
104 env = (char *) getenv(*p);
106 ldfile_add_library_path(concat(env,"/lib/libcoff",""));
110 env= (char *) getenv("I960BASE");
112 ldfile_add_library_path(concat(env,"/lib",""));
115 ldfile_output_architecture = bfd_arch_i960;
116 ldfile_output_machine = bfd_mach_i960_core;
119 #else /* not GNU960 */
122 lnk960_before_parse()
124 char *name = getenv("I960BASE");
126 if (name == (char *)NULL) {
127 name = getenv("G960BASE");
128 if (name == (char *)NULL) {
129 einfo("%P%F I960BASE and G960BASE not set\n");
134 ldfile_add_library_path(concat(name,"/lib",""));
135 ldfile_output_architecture = bfd_arch_i960;
136 ldfile_output_machine = bfd_mach_i960_core;
145 lang_input_file_enum_type search;
148 lang_add_input_file(list->name,
154 static void lnk960_after_parse()
157 /* If there has been no arch, default to -KB */
158 if (ldfile_output_machine_name[0] ==0) {
159 ldfile_add_arch("KB");
162 /* if there has been no hll list then add our own */
164 if(had_hll && !had_hll_name) {
165 append(&hll_list_tail,"cg");
166 if (ldfile_output_machine == bfd_mach_i960_ka_sa ||
167 ldfile_output_machine == bfd_mach_i960_ca) {
169 append(&hll_list_tail,"fpg");
174 add_on(hll_list, lang_input_file_is_l_enum);
175 add_on(syslib_list, lang_input_file_is_search_file_enum);
179 lnk960_before_allocation()
183 lnk960_after_allocation()
185 extern ld_config_type config;
186 if (config.relocateable_output == false) {
187 lang_abs_symbol_at_end_of(".text","_etext");
188 lang_abs_symbol_at_end_of(".data","_edata");
189 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
190 lang_abs_symbol_at_end_of(".bss","_end");
197 unsigned long number;
201 bfd_mach_i960_core ,"CORE",
202 bfd_mach_i960_kb_sb ,"KB",
203 bfd_mach_i960_kb_sb ,"SB",
204 bfd_mach_i960_mc ,"MC",
205 bfd_mach_i960_xa ,"XA",
206 bfd_mach_i960_ca ,"CA",
207 bfd_mach_i960_ka_sa ,"KA",
208 bfd_mach_i960_ka_sa ,"SA",
210 bfd_mach_i960_core ,"core",
211 bfd_mach_i960_kb_sb ,"kb",
212 bfd_mach_i960_kb_sb ,"sb",
213 bfd_mach_i960_mc ,"mc",
214 bfd_mach_i960_xa ,"xa",
215 bfd_mach_i960_ca ,"ca",
216 bfd_mach_i960_ka_sa ,"ka",
217 bfd_mach_i960_ka_sa ,"sa",
222 lnk960_set_output_arch()
224 /* Set the output architecture and machine if possible */
226 ldfile_output_machine = bfd_mach_i960_core;
227 for (i= 0; machine_table[i].name != (char*)NULL; i++) {
228 if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) {
229 ldfile_output_machine = machine_table[i].number;
233 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine);
237 lnk960_choose_target()
241 return bfd_make_targ_name(BFD_COFF_FORMAT, 0);
245 char *from_outside = getenv(TARGET_ENVIRON);
246 if (from_outside != (char *)NULL)
249 return "coff-Intel-little";
251 return "coff-Intel-big";
258 lnk960_get_script(isfile)
262 if test "$DEFAULT_EMULATION" = "$EMULATION_NAME"
264 # Scripts compiled in.
266 # sed commands to quote an ld script as a C string.
273 cat >>em_${EMULATION_NAME}.c <<EOF
274 extern ld_config_type config;
278 if (config.relocateable_output == true && config.build_constructors == true)
279 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
280 else if (config.relocateable_output == true)
281 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
282 else if (!config.text_read_only)
283 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
284 else if (!config.magic_demand_paged)
285 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
287 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
292 # Scripts read from the filesystem.
294 cat >>em_${EMULATION_NAME}.c <<EOF
296 extern ld_config_type config;
300 if (config.relocateable_output == true && config.build_constructors == true)
301 return "ldscripts/${EMULATION_NAME}.xu";
302 else if (config.relocateable_output == true)
303 return "ldscripts/${EMULATION_NAME}.xr";
304 else if (!config.text_read_only)
305 return "ldscripts/${EMULATION_NAME}.xbn";
306 else if (!config.magic_demand_paged)
307 return "ldscripts/${EMULATION_NAME}.xn";
309 return "ldscripts/${EMULATION_NAME}.x";
315 cat >>em_${EMULATION_NAME}.c <<EOF
317 struct ld_emulation_xfer_struct ld_lnk960_emulation =
323 lnk960_after_allocation,
324 lnk960_set_output_arch,
325 lnk960_choose_target,
326 lnk960_before_allocation,