]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/gld960c.em
Fix formatting
[thirdparty/binutils-gdb.git] / ld / emultempl / gld960c.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
597e2591 4/* Copyright (C) 1991, 93, 94, 95, 96, 1999 Free Software Foundation, Inc.
252b5132
RH
5
6This file is part of GLD, the Gnu Linker.
7
8GLD is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 1, or (at your option)
11any later version.
12
13GLD is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GLD; see the file COPYING. If not, write to the Free
20Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2102111-1307, USA. */
22
23/*
24 * emulate the Intels port of gld
25 */
26
27
28#include <ctype.h>
29#include "bfd.h"
30#include "sysdep.h"
31#include "libiberty.h"
32#include "bfdlink.h"
33
34#include "ld.h"
35#include "ldemul.h"
36#include "ldfile.h"
37#include "ldmisc.h"
38#include "ldmain.h"
39
40#ifdef GNU960
41
42static void
43gld960_before_parse()
44{
45 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
46 char **p;
47 char *env ;
48
49 for ( p = env_variables; *p; p++ ){
50 env = (char *) getenv(*p);
51 if (env) {
52 ldfile_add_library_path (concat (env,
53 "/lib/libcoff",
54 (const char *) NULL),
55 false);
56 }
57 }
58 ldfile_output_architecture = bfd_arch_i960;
59}
60
61#else /* not GNU960 */
62
63static void gld960_before_parse()
64{
65 char *env ;
66 env = getenv("G960LIB");
67 if (env) {
68 ldfile_add_library_path(env, false);
69 }
70 env = getenv("G960BASE");
71 if (env)
72 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL),
73 false);
74 ldfile_output_architecture = bfd_arch_i960;
75}
76
77#endif /* GNU960 */
78
79
80static void
81gld960_set_output_arch()
82{
83 if (ldfile_output_machine_name != NULL
84 && *ldfile_output_machine_name != '\0')
85 {
86 char *s, *s1;
87
88 s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
89 for (s1 = s; *s1 != '\0'; s1++)
90 if (isupper ((unsigned char) *s1))
91 *s1 = tolower ((unsigned char) *s1);
92 ldfile_set_output_arch (s);
93 free (s);
94 }
95
96 set_output_arch_default ();
97}
98
99static char *
100gld960_choose_target()
101{
102#ifdef GNU960
103
104 output_filename = "b.out";
105 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
106
107#else
108
109 char *from_outside = getenv(TARGET_ENVIRON);
110 output_filename = "b.out";
111
112 if (from_outside != (char *)NULL)
113 return from_outside;
114
115 return "coff-Intel-little";
116
117#endif
118}
119
120static char *
121gld960_get_script(isfile)
122 int *isfile;
123EOF
124
125if test -n "$COMPILE_IN"
126then
127# Scripts compiled in.
128
129# sed commands to quote an ld script as a C string.
597e2591 130sc="-f stringify.sed"
252b5132
RH
131
132cat >>e${EMULATION_NAME}.c <<EOF
133{
134 *isfile = 0;
135
136 if (link_info.relocateable == true && config.build_constructors == true)
597e2591 137 return
252b5132 138EOF
597e2591
ILT
139sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
140echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
141sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
142echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
143sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
144echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
145sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
146echo ' ; else return' >> e${EMULATION_NAME}.c
147sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
148echo '; }' >> e${EMULATION_NAME}.c
252b5132
RH
149
150else
151# Scripts read from the filesystem.
152
153cat >>e${EMULATION_NAME}.c <<EOF
154{
155 *isfile = 1;
156
157 if (link_info.relocateable == true && config.build_constructors == true)
158 return "ldscripts/${EMULATION_NAME}.xu";
159 else if (link_info.relocateable == true)
160 return "ldscripts/${EMULATION_NAME}.xr";
161 else if (!config.text_read_only)
162 return "ldscripts/${EMULATION_NAME}.xbn";
163 else if (!config.magic_demand_paged)
164 return "ldscripts/${EMULATION_NAME}.xn";
165 else
166 return "ldscripts/${EMULATION_NAME}.x";
167}
168EOF
169
170fi
171
172cat >>e${EMULATION_NAME}.c <<EOF
173
174struct ld_emulation_xfer_struct ld_gld960coff_emulation =
175{
176 gld960_before_parse,
177 syslib_default,
178 hll_default,
179 after_parse_default,
180 after_open_default,
181 after_allocation_default,
182 gld960_set_output_arch,
183 gld960_choose_target,
184 before_allocation_default,
185 gld960_get_script,
186 "960coff",
e1c47aa4
AM
187 "",
188 NULL, /* finish */
189 NULL, /* create output section statements */
190 NULL, /* open dynamic archive */
191 NULL, /* place orphan */
192 NULL, /* set symbols */
193 NULL, /* parse args */
194 NULL, /* unrecognized file */
195 NULL, /* list options */
40d109bf
AM
196 NULL, /* recognized file */
197 NULL /* find_potential_libraries */
252b5132
RH
198};
199EOF