]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/emultempl/gld960.em
* emultempl/aix.em: Add missing prototype.
[thirdparty/binutils-gdb.git] / ld / emultempl / gld960.em
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<EOF
4 /* Copyright 1991, 1992, 1994, 1999, 2000, 2001
5 Free Software Foundation, Inc.
6
7 This file is part of GLD, the Gnu Linker.
8
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)
12 any later version.
13
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.
18
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
21 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23 /*
24 * emulate the Intels port of gld
25 */
26
27
28 #include "bfd.h"
29 #include "sysdep.h"
30 #include "libiberty.h"
31 #include "bfdlink.h"
32
33 #include "ld.h"
34 #include "ldmisc.h"
35 #include "ldmain.h"
36
37 #include "ldexp.h"
38 #include "ldlang.h"
39 #include "ldfile.h"
40 #include "ldemul.h"
41
42 static void gld960_before_parse PARAMS ((void));
43 static char *gld960_choose_target PARAMS ((void));
44 static void gld960_set_output_arch PARAMS ((void));
45 static char *gld960_get_script PARAMS ((int *));
46
47 #ifdef GNU960
48
49 static void
50 gld960_before_parse()
51 {
52 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
53 char **p;
54 char *env ;
55
56 for ( p = env_variables; *p; p++ ){
57 env = (char *) getenv(*p);
58 if (env) {
59 ldfile_add_library_path (concat (env,
60 "/lib/libbout",
61 (const char *) NULL),
62 false);
63 }
64 }
65 ldfile_output_architecture = bfd_arch_i960;
66 }
67
68 #else /* not GNU960 */
69
70 static void gld960_before_parse()
71 {
72 char *env ;
73 env = getenv("G960LIB");
74 if (env) {
75 ldfile_add_library_path(env, false);
76 }
77 env = getenv("G960BASE");
78 if (env)
79 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), false);
80 ldfile_output_architecture = bfd_arch_i960;
81 }
82
83 #endif /* GNU960 */
84
85
86 static void
87 gld960_set_output_arch()
88 {
89 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
90 }
91
92 static char *
93 gld960_choose_target()
94 {
95 #ifdef GNU960
96
97 output_filename = "b.out";
98 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
99
100 #else
101
102 char *from_outside = getenv(TARGET_ENVIRON);
103 output_filename = "b.out";
104
105 if (from_outside != (char *)NULL)
106 return from_outside;
107
108 return "b.out.little";
109
110 #endif
111 }
112
113 static char *
114 gld960_get_script(isfile)
115 int *isfile;
116 EOF
117
118 if test -n "$COMPILE_IN"
119 then
120 # Scripts compiled in.
121
122 # sed commands to quote an ld script as a C string.
123 sc="-f stringify.sed"
124
125 cat >>e${EMULATION_NAME}.c <<EOF
126 {
127 *isfile = 0;
128
129 if (link_info.relocateable == true && config.build_constructors == true)
130 return
131 EOF
132 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
133 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
134 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
135 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
136 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
137 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
138 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
139 echo ' ; else return' >> e${EMULATION_NAME}.c
140 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
141 echo '; }' >> e${EMULATION_NAME}.c
142
143 else
144 # Scripts read from the filesystem.
145
146 cat >>e${EMULATION_NAME}.c <<EOF
147 {
148 *isfile = 1;
149
150 if (link_info.relocateable == true && config.build_constructors == true)
151 return "ldscripts/${EMULATION_NAME}.xu";
152 else if (link_info.relocateable == true)
153 return "ldscripts/${EMULATION_NAME}.xr";
154 else if (!config.text_read_only)
155 return "ldscripts/${EMULATION_NAME}.xbn";
156 else if (!config.magic_demand_paged)
157 return "ldscripts/${EMULATION_NAME}.xn";
158 else
159 return "ldscripts/${EMULATION_NAME}.x";
160 }
161 EOF
162
163 fi
164
165 cat >>e${EMULATION_NAME}.c <<EOF
166
167 struct ld_emulation_xfer_struct ld_gld960_emulation =
168 {
169 gld960_before_parse,
170 syslib_default,
171 hll_default,
172 after_parse_default,
173 after_open_default,
174 after_allocation_default,
175 gld960_set_output_arch,
176 gld960_choose_target,
177 before_allocation_default,
178 gld960_get_script,
179 "960",
180 "",
181 NULL, /* finish */
182 NULL, /* create output section statements */
183 NULL, /* open dynamic archive */
184 NULL, /* place orphan */
185 NULL, /* set symbols */
186 NULL, /* parse args */
187 NULL, /* unrecognized file */
188 NULL, /* list options */
189 NULL, /* recognized file */
190 NULL /* find_potential_libraries */
191 };
192 EOF