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, 93, 94, 95, 96, 99, 2000
6 Free Software Foundation, Inc.
7 Written by Steve Chamberlain steve@cygnus.com
9 This file is part of GLD, the Gnu Linker.
11 GLD is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 GLD is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GLD; see the file COPYING. If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "libiberty.h"
30 /*#include "archures.h"*/
39 typedef struct lib_list {
41 struct lib_list *next;
44 static lib_list_type *hll_list;
45 static lib_list_type **hll_list_tail = &hll_list;
47 static lib_list_type *syslib_list;
48 static lib_list_type **syslib_list_tail = &syslib_list;
53 lib_list_type ***list;
56 lib_list_type *element =
57 (lib_list_type *)(xmalloc(sizeof(lib_list_type)));
60 element->next = (lib_list_type *)NULL;
62 *list = &element->next;
66 static boolean had_hll = false;
67 static boolean had_hll_name = false;
74 if (name != (char *)NULL) {
76 append(&hll_list_tail, name);
84 append(&syslib_list_tail,name);
93 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
97 for ( p = env_variables; *p; p++ ){
98 env = (char *) getenv(*p);
100 ldfile_add_library_path(concat(env,"/lib/libcoff",""), false);
104 env= (char *) getenv("I960BASE");
106 ldfile_add_library_path(concat(env,"/lib",""), false);
109 ldfile_output_architecture = bfd_arch_i960;
110 ldfile_output_machine = bfd_mach_i960_core;
113 #else /* not GNU960 */
116 lnk960_before_parse()
118 char *name = getenv("I960BASE");
120 if (name == (char *)NULL) {
121 name = getenv("G960BASE");
122 if (name == (char *)NULL) {
123 einfo("%P%F I960BASE and G960BASE not set\n");
128 ldfile_add_library_path(concat(name,"/lib",""), false);
129 ldfile_output_architecture = bfd_arch_i960;
130 ldfile_output_machine = bfd_mach_i960_core;
139 lang_input_file_enum_type search;
142 lang_add_input_file(list->name,
151 /* If there has been no arch, default to -KB */
152 if (ldfile_output_machine_name[0] ==0) {
153 ldfile_add_arch("KB");
156 /* if there has been no hll list then add our own */
158 if(had_hll && !had_hll_name) {
159 append(&hll_list_tail,"cg");
160 if (ldfile_output_machine == bfd_mach_i960_ka_sa ||
161 ldfile_output_machine == bfd_mach_i960_ca) {
163 append(&hll_list_tail,"fpg");
168 add_on(hll_list, lang_input_file_is_l_enum);
169 add_on(syslib_list, lang_input_file_is_search_file_enum);
173 lnk960_before_allocation()
178 lnk960_after_allocation()
180 if (link_info.relocateable == false) {
181 lang_abs_symbol_at_end_of(".text","_etext");
182 lang_abs_symbol_at_end_of(".data","_edata");
183 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
184 lang_abs_symbol_at_end_of(".bss","_end");
191 unsigned long number;
196 { bfd_mach_i960_core ,"CORE" },
197 { bfd_mach_i960_kb_sb ,"KB" },
198 { bfd_mach_i960_kb_sb ,"SB" },
199 { bfd_mach_i960_mc ,"MC" },
200 { bfd_mach_i960_xa ,"XA" },
201 { bfd_mach_i960_ca ,"CA" },
202 { bfd_mach_i960_ka_sa ,"KA" },
203 { bfd_mach_i960_ka_sa ,"SA" },
204 { bfd_mach_i960_jx ,"JX" },
205 { bfd_mach_i960_hx ,"HX" },
207 { bfd_mach_i960_core ,"core" },
208 { bfd_mach_i960_kb_sb ,"kb" },
209 { bfd_mach_i960_kb_sb ,"sb" },
210 { bfd_mach_i960_mc ,"mc" },
211 { bfd_mach_i960_xa ,"xa" },
212 { bfd_mach_i960_ca ,"ca" },
213 { bfd_mach_i960_ka_sa ,"ka" },
214 { bfd_mach_i960_ka_sa ,"sa" },
215 { bfd_mach_i960_jx ,"jx" },
216 { bfd_mach_i960_hx ,"hx" },
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 -n "$COMPILE_IN"
264 # Scripts compiled in.
266 # sed commands to quote an ld script as a C string.
267 sc="-f stringify.sed"
269 cat >>e${EMULATION_NAME}.c <<EOF
273 if (link_info.relocateable == true && config.build_constructors == true)
276 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
277 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
278 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
279 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
280 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
281 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
282 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
283 echo ' ; else return' >> e${EMULATION_NAME}.c
284 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
285 echo '; }' >> e${EMULATION_NAME}.c
288 # Scripts read from the filesystem.
290 cat >>e${EMULATION_NAME}.c <<EOF
294 if (link_info.relocateable == true && config.build_constructors == true)
295 return "ldscripts/${EMULATION_NAME}.xu";
296 else if (link_info.relocateable == true)
297 return "ldscripts/${EMULATION_NAME}.xr";
298 else if (!config.text_read_only)
299 return "ldscripts/${EMULATION_NAME}.xbn";
300 else if (!config.magic_demand_paged)
301 return "ldscripts/${EMULATION_NAME}.xn";
303 return "ldscripts/${EMULATION_NAME}.x";
309 cat >>e${EMULATION_NAME}.c <<EOF
311 struct ld_emulation_xfer_struct ld_lnk960_emulation =
317 NULL, /* after_open */
318 lnk960_after_allocation,
319 lnk960_set_output_arch,
320 lnk960_choose_target,
321 lnk960_before_allocation,
326 NULL, /* create output section statements */
327 NULL, /* open dynamic archive */
328 NULL, /* place orphan */
329 NULL, /* set symbols */
330 NULL, /* parse args */
331 NULL, /* unrecognized file */
332 NULL, /* list options */
333 NULL, /* recognized file */
334 NULL /* find_potential_libraries */