1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
4 /* Copyright (C) 1991-2014 Free Software Foundation, Inc.
6 This file is part of the GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
24 /* Emulate the Intel's port of gld. */
28 #include "libiberty.h"
29 #include "safe-ctype.h"
41 static void gld960_before_parse (void)
44 env = getenv("G960LIB");
46 ldfile_add_library_path(env, FALSE);
48 env = getenv("G960BASE");
50 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL),
52 ldfile_output_architecture = bfd_arch_i960;
56 gld960_set_output_arch (void)
58 if (ldfile_output_machine_name != NULL
59 && *ldfile_output_machine_name != '\0')
63 s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
64 for (s1 = s; *s1 != '\0'; s1++)
66 ldfile_set_output_arch (s, bfd_arch_unknown);
70 set_output_arch_default ();
74 gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
76 char *from_outside = getenv(TARGET_ENVIRON);
77 output_filename = "b.out";
79 if (from_outside != (char *)NULL)
82 return "coff-Intel-little";
86 gld960_get_script (int *isfile)
89 if test x"$COMPILE_IN" = xyes
91 # Scripts compiled in.
93 # sed commands to quote an ld script as a C string.
100 if (link_info.relocatable && config.build_constructors)
103 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
104 echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
105 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
106 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
107 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
108 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
109 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
110 echo ' ; else return' >> e${EMULATION_NAME}.c
111 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
112 echo '; }' >> e${EMULATION_NAME}.c
115 # Scripts read from the filesystem.
121 if (link_info.relocatable && config.build_constructors)
122 return "ldscripts/${EMULATION_NAME}.xu";
123 else if (link_info.relocatable)
124 return "ldscripts/${EMULATION_NAME}.xr";
125 else if (!config.text_read_only)
126 return "ldscripts/${EMULATION_NAME}.xbn";
127 else if (!config.magic_demand_paged)
128 return "ldscripts/${EMULATION_NAME}.xn";
130 return "ldscripts/${EMULATION_NAME}.x";
138 struct ld_emulation_xfer_struct ld_gld960coff_emulation =
145 after_allocation_default,
146 gld960_set_output_arch,
147 gld960_choose_target,
148 before_allocation_default,
153 NULL, /* create output section statements */
154 NULL, /* open dynamic archive */
155 NULL, /* place orphan */
156 NULL, /* set symbols */
157 NULL, /* parse args */
158 NULL, /* add_options */
159 NULL, /* handle_option */
160 NULL, /* unrecognized file */
161 NULL, /* list options */
162 NULL, /* recognized file */
163 NULL, /* find_potential_libraries */
164 NULL /* new_vers_pattern */