]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/emultempl/gld960.em
Correct spelling of "relocatable".
[thirdparty/binutils-gdb.git] / ld / emultempl / gld960.em
CommitLineData
252b5132
RH
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
3bcf5557 4/* Copyright 1991, 1992, 1994, 1999, 2000, 2001, 2002, 2003
48f6162b 5 Free Software Foundation, Inc.
252b5132
RH
6
7This file is part of GLD, the Gnu Linker.
8
9GLD is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 1, or (at your option)
12any later version.
13
14GLD is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GLD; see the file COPYING. If not, write to
21the 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"
252b5132
RH
34#include "ldmisc.h"
35#include "ldmain.h"
36
b71e2778
AM
37#include "ldexp.h"
38#include "ldlang.h"
39#include "ldfile.h"
40#include "ldemul.h"
41
48f6162b 42static void gld960_before_parse PARAMS ((void));
742aeb63 43static char *gld960_choose_target PARAMS ((int, char **));
48f6162b
AJ
44static void gld960_set_output_arch PARAMS ((void));
45static char *gld960_get_script PARAMS ((int *));
46
252b5132
RH
47#ifdef GNU960
48
49static void
50gld960_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),
b34976b6 62 FALSE);
252b5132
RH
63 }
64 }
65 ldfile_output_architecture = bfd_arch_i960;
66}
67
68#else /* not GNU960 */
69
70static void gld960_before_parse()
71{
72 char *env ;
73 env = getenv("G960LIB");
74 if (env) {
b34976b6 75 ldfile_add_library_path(env, FALSE);
252b5132
RH
76 }
77 env = getenv("G960BASE");
78 if (env)
b34976b6 79 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), FALSE);
252b5132
RH
80 ldfile_output_architecture = bfd_arch_i960;
81}
82
83#endif /* GNU960 */
84
85
86static void
87gld960_set_output_arch()
88{
89 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
90}
91
92static char *
742aeb63
TR
93gld960_choose_target (argc, argv)
94 int argc ATTRIBUTE_UNUSED;
95 char **argv ATTRIBUTE_UNUSED;
252b5132
RH
96{
97#ifdef GNU960
98
99 output_filename = "b.out";
100 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
101
102#else
103
104 char *from_outside = getenv(TARGET_ENVIRON);
105 output_filename = "b.out";
106
107 if (from_outside != (char *)NULL)
108 return from_outside;
109
110 return "b.out.little";
111
112#endif
113}
114
115static char *
116gld960_get_script(isfile)
117 int *isfile;
118EOF
119
120if test -n "$COMPILE_IN"
121then
122# Scripts compiled in.
123
124# sed commands to quote an ld script as a C string.
597e2591 125sc="-f stringify.sed"
252b5132
RH
126
127cat >>e${EMULATION_NAME}.c <<EOF
128{
129 *isfile = 0;
130
1049f94e 131 if (link_info.relocatable && config.build_constructors)
597e2591 132 return
252b5132 133EOF
b34976b6 134sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1049f94e 135echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
b34976b6
AM
136sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
137echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
138sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
139echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
140sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
141echo ' ; else return' >> e${EMULATION_NAME}.c
142sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
143echo '; }' >> e${EMULATION_NAME}.c
252b5132
RH
144
145else
146# Scripts read from the filesystem.
147
148cat >>e${EMULATION_NAME}.c <<EOF
149{
150 *isfile = 1;
151
1049f94e 152 if (link_info.relocatable && config.build_constructors)
252b5132 153 return "ldscripts/${EMULATION_NAME}.xu";
1049f94e 154 else if (link_info.relocatable)
252b5132
RH
155 return "ldscripts/${EMULATION_NAME}.xr";
156 else if (!config.text_read_only)
157 return "ldscripts/${EMULATION_NAME}.xbn";
158 else if (!config.magic_demand_paged)
159 return "ldscripts/${EMULATION_NAME}.xn";
160 else
161 return "ldscripts/${EMULATION_NAME}.x";
162}
163EOF
164
165fi
166
167cat >>e${EMULATION_NAME}.c <<EOF
168
169struct ld_emulation_xfer_struct ld_gld960_emulation =
170{
171 gld960_before_parse,
172 syslib_default,
173 hll_default,
174 after_parse_default,
175 after_open_default,
176 after_allocation_default,
177 gld960_set_output_arch,
178 gld960_choose_target,
179 before_allocation_default,
180 gld960_get_script,
181 "960",
e1c47aa4
AM
182 "",
183 NULL, /* finish */
184 NULL, /* create output section statements */
185 NULL, /* open dynamic archive */
186 NULL, /* place orphan */
187 NULL, /* set symbols */
188 NULL, /* parse args */
3bcf5557
AM
189 NULL, /* add_options */
190 NULL, /* handle_option */
e1c47aa4
AM
191 NULL, /* unrecognized file */
192 NULL, /* list options */
40d109bf 193 NULL, /* recognized file */
fac1652d
AM
194 NULL, /* find_potential_libraries */
195 NULL /* new_vers_pattern */
252b5132
RH
196};
197EOF