* ld.texinfo (Simple Example): Add missing punctuation.
[deliverable/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
0c7a8e5a 23/*
252b5132
RH
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
252b5132
RH
42#ifdef GNU960
43
44static void
0c7a8e5a 45gld960_before_parse (void)
252b5132
RH
46{
47 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
48 char **p;
49 char *env ;
50
51 for ( p = env_variables; *p; p++ ){
52 env = (char *) getenv(*p);
53 if (env) {
54 ldfile_add_library_path (concat (env,
55 "/lib/libbout",
56 (const char *) NULL),
b34976b6 57 FALSE);
252b5132
RH
58 }
59 }
60 ldfile_output_architecture = bfd_arch_i960;
61}
62
63#else /* not GNU960 */
64
0c7a8e5a 65static void gld960_before_parse (void)
252b5132
RH
66{
67 char *env ;
68 env = getenv("G960LIB");
69 if (env) {
b34976b6 70 ldfile_add_library_path(env, FALSE);
252b5132
RH
71 }
72 env = getenv("G960BASE");
73 if (env)
b34976b6 74 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), FALSE);
252b5132
RH
75 ldfile_output_architecture = bfd_arch_i960;
76}
77
78#endif /* GNU960 */
79
80
81static void
0c7a8e5a 82gld960_set_output_arch (void)
252b5132
RH
83{
84 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
85}
86
87static char *
0c7a8e5a 88gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
252b5132
RH
89{
90#ifdef GNU960
91
92 output_filename = "b.out";
93 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
94
95#else
96
97 char *from_outside = getenv(TARGET_ENVIRON);
98 output_filename = "b.out";
99
100 if (from_outside != (char *)NULL)
101 return from_outside;
102
103 return "b.out.little";
104
105#endif
106}
107
108static char *
0c7a8e5a 109gld960_get_script (int *isfile)
252b5132
RH
110EOF
111
112if test -n "$COMPILE_IN"
113then
114# Scripts compiled in.
115
116# sed commands to quote an ld script as a C string.
597e2591 117sc="-f stringify.sed"
252b5132
RH
118
119cat >>e${EMULATION_NAME}.c <<EOF
0c7a8e5a 120{
252b5132
RH
121 *isfile = 0;
122
1049f94e 123 if (link_info.relocatable && config.build_constructors)
597e2591 124 return
252b5132 125EOF
b34976b6 126sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
1049f94e 127echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
b34976b6
AM
128sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
129echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
130sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
131echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
132sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
133echo ' ; else return' >> e${EMULATION_NAME}.c
134sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
135echo '; }' >> e${EMULATION_NAME}.c
252b5132
RH
136
137else
138# Scripts read from the filesystem.
139
140cat >>e${EMULATION_NAME}.c <<EOF
0c7a8e5a 141{
252b5132
RH
142 *isfile = 1;
143
1049f94e 144 if (link_info.relocatable && config.build_constructors)
252b5132 145 return "ldscripts/${EMULATION_NAME}.xu";
1049f94e 146 else if (link_info.relocatable)
252b5132
RH
147 return "ldscripts/${EMULATION_NAME}.xr";
148 else if (!config.text_read_only)
149 return "ldscripts/${EMULATION_NAME}.xbn";
150 else if (!config.magic_demand_paged)
151 return "ldscripts/${EMULATION_NAME}.xn";
152 else
153 return "ldscripts/${EMULATION_NAME}.x";
154}
155EOF
156
157fi
158
159cat >>e${EMULATION_NAME}.c <<EOF
160
0c7a8e5a 161struct ld_emulation_xfer_struct ld_gld960_emulation =
252b5132
RH
162{
163 gld960_before_parse,
164 syslib_default,
165 hll_default,
166 after_parse_default,
167 after_open_default,
168 after_allocation_default,
169 gld960_set_output_arch,
170 gld960_choose_target,
171 before_allocation_default,
172 gld960_get_script,
173 "960",
e1c47aa4
AM
174 "",
175 NULL, /* finish */
176 NULL, /* create output section statements */
177 NULL, /* open dynamic archive */
178 NULL, /* place orphan */
179 NULL, /* set symbols */
180 NULL, /* parse args */
3bcf5557
AM
181 NULL, /* add_options */
182 NULL, /* handle_option */
e1c47aa4
AM
183 NULL, /* unrecognized file */
184 NULL, /* list options */
40d109bf 185 NULL, /* recognized file */
fac1652d
AM
186 NULL, /* find_potential_libraries */
187 NULL /* new_vers_pattern */
252b5132
RH
188};
189EOF
This page took 0.200023 seconds and 4 git commands to generate.