1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<EOF
4 /* Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001
5 Free Software Foundation, Inc.
7 This file is part of GLD, the Gnu Linker.
9 GLD is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 1, or (at your option)
14 GLD is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GLD; see the file COPYING. If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 * emulate the Intels port of gld
32 #include "libiberty.h"
44 static void gld960_before_parse PARAMS ((void));
45 static void gld960_set_output_arch PARAMS ((void));
46 static char *gld960_choose_target PARAMS ((void));
47 static char *gld960_get_script PARAMS ((int *));
54 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
58 for ( p = env_variables; *p; p++ ){
59 env = (char *) getenv(*p);
61 ldfile_add_library_path (concat (env,
67 ldfile_output_architecture = bfd_arch_i960;
70 #else /* not GNU960 */
72 static void gld960_before_parse()
75 env = getenv("G960LIB");
77 ldfile_add_library_path(env, false);
79 env = getenv("G960BASE");
81 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL),
83 ldfile_output_architecture = bfd_arch_i960;
90 gld960_set_output_arch()
92 if (ldfile_output_machine_name != NULL
93 && *ldfile_output_machine_name != '\0')
97 s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
98 for (s1 = s; *s1 != '\0'; s1++)
99 if (isupper ((unsigned char) *s1))
100 *s1 = tolower ((unsigned char) *s1);
101 ldfile_set_output_arch (s);
105 set_output_arch_default ();
109 gld960_choose_target()
113 output_filename = "b.out";
114 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
118 char *from_outside = getenv(TARGET_ENVIRON);
119 output_filename = "b.out";
121 if (from_outside != (char *)NULL)
124 return "coff-Intel-little";
130 gld960_get_script(isfile)
134 if test -n "$COMPILE_IN"
136 # Scripts compiled in.
138 # sed commands to quote an ld script as a C string.
139 sc="-f stringify.sed"
141 cat >>e${EMULATION_NAME}.c <<EOF
145 if (link_info.relocateable == true && config.build_constructors == true)
148 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
149 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
150 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
151 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
152 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
153 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
154 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
155 echo ' ; else return' >> e${EMULATION_NAME}.c
156 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
157 echo '; }' >> e${EMULATION_NAME}.c
160 # Scripts read from the filesystem.
162 cat >>e${EMULATION_NAME}.c <<EOF
166 if (link_info.relocateable == true && config.build_constructors == true)
167 return "ldscripts/${EMULATION_NAME}.xu";
168 else if (link_info.relocateable == true)
169 return "ldscripts/${EMULATION_NAME}.xr";
170 else if (!config.text_read_only)
171 return "ldscripts/${EMULATION_NAME}.xbn";
172 else if (!config.magic_demand_paged)
173 return "ldscripts/${EMULATION_NAME}.xn";
175 return "ldscripts/${EMULATION_NAME}.x";
181 cat >>e${EMULATION_NAME}.c <<EOF
183 struct ld_emulation_xfer_struct ld_gld960coff_emulation =
190 after_allocation_default,
191 gld960_set_output_arch,
192 gld960_choose_target,
193 before_allocation_default,
198 NULL, /* create output section statements */
199 NULL, /* open dynamic archive */
200 NULL, /* place orphan */
201 NULL, /* set symbols */
202 NULL, /* parse args */
203 NULL, /* unrecognized file */
204 NULL, /* list options */
205 NULL, /* recognized file */
206 NULL /* find_potential_libraries */