* emultempl/pe.em (set_pe_subsystem): Don't call
[deliverable/binutils-gdb.git] / ld / emultempl / gld960.em
CommitLineData
a6152e39
DM
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >em_${EMULATION_NAME}.c <<EOF
4/* Copyright (C) 1991 Free Software Foundation, Inc.
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
20the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22/*
23 * emulate the Intels port of gld
24 */
25
26
27#include "bfd.h"
28#include "sysdep.h"
29
30
31#include "ld.h"
32#include "config.h"
33#include "ldemul.h"
34#include "ldfile.h"
35#include "ldmisc.h"
36
37
38/* IMPORTS */
39extern char *output_filename;
40extern boolean lang_float_flag;
41
42
43extern enum bfd_architecture ldfile_output_architecture;
44extern unsigned long ldfile_output_machine;
45extern char *ldfile_output_machine_name;
46
47extern bfd *output_bfd;
48
49
50
51#ifdef GNU960
52
53static void
54gld960_before_parse()
55{
56 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
57 char **p;
58 char *env ;
59
60 for ( p = env_variables; *p; p++ ){
61 env = (char *) getenv(*p);
62 if (env) {
63 ldfile_add_library_path(concat(env,"/lib/libbout",""));
64 }
65 }
66 ldfile_output_architecture = bfd_arch_i960;
67}
68
69#else /* not GNU960 */
70
71static void gld960_before_parse()
72{
73 char *env ;
74 env = getenv("G960LIB");
75 if (env) {
76 ldfile_add_library_path(env);
77 }
78 env = getenv("G960BASE");
79 if (env) {
80 ldfile_add_library_path(concat(env,"/lib",""));
81 }
82 ldfile_output_architecture = bfd_arch_i960;
83}
84
85#endif /* GNU960 */
86
87
88static void
89gld960_set_output_arch()
90{
91 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
92}
93
94static char *
95gld960_choose_target()
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 "$DEFAULT_EMULATION" = "$EMULATION_NAME"
121then
122# Scripts compiled in.
123
124# sed commands to quote an ld script as a C string.
125sc='s/["\\]/\\&/g
126s/$/\\n\\/
1271s/^/"{/
128$s/$/n}"/
129'
130
131cat >>em_${EMULATION_NAME}.c <<EOF
132{
133 extern ld_config_type config;
134
135 *isfile = 0;
136
137 if (config.relocateable_output == true && config.build_constructors == true)
138 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
139 else if (config.relocateable_output == true)
140 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
141 else if (!config.text_read_only)
142 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
143 else if (!config.magic_demand_paged)
144 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
145 else
146 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
147}
148EOF
149
150else
151# Scripts read from the filesystem.
152
153cat >>em_${EMULATION_NAME}.c <<EOF
154{
155 extern ld_config_type config;
156
157 *isfile = 1;
158
159 if (config.relocateable_output == true && config.build_constructors == true)
160 return "ldscripts/${EMULATION_NAME}.xu";
161 else if (config.relocateable_output == true)
162 return "ldscripts/${EMULATION_NAME}.xr";
163 else if (!config.text_read_only)
164 return "ldscripts/${EMULATION_NAME}.xbn";
165 else if (!config.magic_demand_paged)
166 return "ldscripts/${EMULATION_NAME}.xn";
167 else
168 return "ldscripts/${EMULATION_NAME}.x";
169}
170EOF
171
172fi
173
174cat >>em_${EMULATION_NAME}.c <<EOF
175
176struct ld_emulation_xfer_struct ld_gld960_emulation =
177{
178 gld960_before_parse,
179 syslib_default,
180 hll_default,
181 after_parse_default,
182 after_allocation_default,
183 gld960_set_output_arch,
184 gld960_choose_target,
185 before_allocation_default,
186 gld960_get_script,
187 "960",
188 ""
189};
190EOF
This page took 0.17725 seconds and 4 git commands to generate.