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 1991, 1992, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2005
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;
52 append (lib_list_type ***list, char *name)
54 lib_list_type *element = (lib_list_type *) xmalloc (sizeof (lib_list_type));
57 element->next = (lib_list_type *) NULL;
59 *list = &element->next;
63 static bfd_boolean had_hll = FALSE;
64 static bfd_boolean had_hll_name = FALSE;
67 lnk960_hll (char *name)
70 if (name != (char *) NULL)
73 append (&hll_list_tail, name);
78 lnk960_syslib (char *name)
80 append (&syslib_list_tail, name);
85 lnk960_before_parse (void)
87 char *name = getenv ("I960BASE");
89 if (name == (char *) NULL)
91 name = getenv("G960BASE");
92 if (name == (char *) NULL)
93 einfo ("%P%F I960BASE and G960BASE not set\n");
96 ldfile_add_library_path (concat (name, "/lib", NULL), FALSE);
97 ldfile_output_architecture = bfd_arch_i960;
98 ldfile_output_machine = bfd_mach_i960_core;
102 add_on (lib_list_type *list, lang_input_file_enum_type search)
106 lang_add_input_file (list->name, search, (char *) NULL);
112 lnk960_after_parse (void)
114 /* If there has been no arch, default to -KB */
115 if (ldfile_output_machine_name[0] == 0)
116 ldfile_add_arch ("KB");
118 /* if there has been no hll list then add our own */
120 if (had_hll && !had_hll_name)
122 append (&hll_list_tail, "cg");
123 if (ldfile_output_machine == bfd_mach_i960_ka_sa
124 || ldfile_output_machine == bfd_mach_i960_ca)
125 append (&hll_list_tail, "fpg");
128 add_on (hll_list, lang_input_file_is_l_enum);
129 add_on (syslib_list, lang_input_file_is_search_file_enum);
133 lnk960_before_allocation (void)
138 lnk960_after_allocation (void)
140 if (!link_info.relocatable)
142 lang_abs_symbol_at_end_of (".text", "_etext");
143 lang_abs_symbol_at_end_of (".data", "_edata");
144 lang_abs_symbol_at_beginning_of (".bss", "_bss_start");
145 lang_abs_symbol_at_end_of (".bss", "_end");
152 unsigned long number;
157 { bfd_mach_i960_core ,"CORE" },
158 { bfd_mach_i960_kb_sb ,"KB" },
159 { bfd_mach_i960_kb_sb ,"SB" },
160 { bfd_mach_i960_mc ,"MC" },
161 { bfd_mach_i960_xa ,"XA" },
162 { bfd_mach_i960_ca ,"CA" },
163 { bfd_mach_i960_ka_sa ,"KA" },
164 { bfd_mach_i960_ka_sa ,"SA" },
165 { bfd_mach_i960_jx ,"JX" },
166 { bfd_mach_i960_hx ,"HX" },
168 { bfd_mach_i960_core ,"core" },
169 { bfd_mach_i960_kb_sb ,"kb" },
170 { bfd_mach_i960_kb_sb ,"sb" },
171 { bfd_mach_i960_mc ,"mc" },
172 { bfd_mach_i960_xa ,"xa" },
173 { bfd_mach_i960_ca ,"ca" },
174 { bfd_mach_i960_ka_sa ,"ka" },
175 { bfd_mach_i960_ka_sa ,"sa" },
176 { bfd_mach_i960_jx ,"jx" },
177 { bfd_mach_i960_hx ,"hx" },
183 lnk960_set_output_arch (void)
185 /* Set the output architecture and machine if possible */
187 ldfile_output_machine = bfd_mach_i960_core;
188 for (i= 0; machine_table[i].name != (char*) NULL; i++)
190 if (strcmp (ldfile_output_machine_name, machine_table[i].name) == 0)
192 ldfile_output_machine = machine_table[i].number;
196 bfd_set_arch_mach (output_bfd, ldfile_output_architecture,
197 ldfile_output_machine);
201 lnk960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
203 char *from_outside = getenv (TARGET_ENVIRON);
204 if (from_outside != (char *) NULL)
207 return "coff-Intel-little";
209 return "coff-Intel-big";
214 lnk960_get_script (int *isfile)
217 if test -n "$COMPILE_IN"
219 # Scripts compiled in.
221 # sed commands to quote an ld script as a C string.
222 sc="-f stringify.sed"
224 cat >>e${EMULATION_NAME}.c <<EOF
228 if (link_info.relocatable && config.build_constructors)
231 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
232 echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
233 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
234 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
235 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
236 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
237 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
238 echo ' ; else return' >> e${EMULATION_NAME}.c
239 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
240 echo '; }' >> e${EMULATION_NAME}.c
243 # Scripts read from the filesystem.
245 cat >>e${EMULATION_NAME}.c <<EOF
249 if (link_info.relocatable && config.build_constructors)
250 return "ldscripts/${EMULATION_NAME}.xu";
251 else if (link_info.relocatable)
252 return "ldscripts/${EMULATION_NAME}.xr";
253 else if (!config.text_read_only)
254 return "ldscripts/${EMULATION_NAME}.xbn";
255 else if (!config.magic_demand_paged)
256 return "ldscripts/${EMULATION_NAME}.xn";
258 return "ldscripts/${EMULATION_NAME}.x";
264 cat >>e${EMULATION_NAME}.c <<EOF
266 struct ld_emulation_xfer_struct ld_lnk960_emulation =
272 NULL, /* after_open */
273 lnk960_after_allocation,
274 lnk960_set_output_arch,
275 lnk960_choose_target,
276 lnk960_before_allocation,
281 NULL, /* create output section statements */
282 NULL, /* open dynamic archive */
283 NULL, /* place orphan */
284 NULL, /* set symbols */
285 NULL, /* parse args */
286 NULL, /* add_options */
287 NULL, /* handle_option */
288 NULL, /* unrecognized file */
289 NULL, /* list options */
290 NULL, /* recognized file */
291 NULL, /* find_potential_libraries */
292 NULL /* new_vers_pattern */