Remove some forward declarations in ldemul.h and ldfile.h, and
[deliverable/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 (C) 1991, 93, 94, 95, 99, 2000 Free Software Foundation, Inc.
5
6 This file is part of GLD, the Gnu Linker.
7
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 1, or (at your option)
11 any later version.
12
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22 /*
23 * emulate the Intels port of gld
24 */
25
26
27 #include "bfd.h"
28 #include "sysdep.h"
29 #include "libiberty.h"
30 #include "bfdlink.h"
31
32 #include "ld.h"
33 #include "ldmisc.h"
34 #include "ldmain.h"
35
36 #include "ldexp.h"
37 #include "ldlang.h"
38 #include "ldfile.h"
39 #include "ldemul.h"
40
41 #ifdef GNU960
42
43 static void
44 gld960_before_parse()
45 {
46 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
47 char **p;
48 char *env ;
49
50 for ( p = env_variables; *p; p++ ){
51 env = (char *) getenv(*p);
52 if (env) {
53 ldfile_add_library_path (concat (env,
54 "/lib/libbout",
55 (const char *) NULL),
56 false);
57 }
58 }
59 ldfile_output_architecture = bfd_arch_i960;
60 }
61
62 #else /* not GNU960 */
63
64 static void gld960_before_parse()
65 {
66 char *env ;
67 env = getenv("G960LIB");
68 if (env) {
69 ldfile_add_library_path(env, false);
70 }
71 env = getenv("G960BASE");
72 if (env)
73 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), false);
74 ldfile_output_architecture = bfd_arch_i960;
75 }
76
77 #endif /* GNU960 */
78
79
80 static void
81 gld960_set_output_arch()
82 {
83 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
84 }
85
86 static char *
87 gld960_choose_target()
88 {
89 #ifdef GNU960
90
91 output_filename = "b.out";
92 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
93
94 #else
95
96 char *from_outside = getenv(TARGET_ENVIRON);
97 output_filename = "b.out";
98
99 if (from_outside != (char *)NULL)
100 return from_outside;
101
102 return "b.out.little";
103
104 #endif
105 }
106
107 static char *
108 gld960_get_script(isfile)
109 int *isfile;
110 EOF
111
112 if test -n "$COMPILE_IN"
113 then
114 # Scripts compiled in.
115
116 # sed commands to quote an ld script as a C string.
117 sc="-f stringify.sed"
118
119 cat >>e${EMULATION_NAME}.c <<EOF
120 {
121 *isfile = 0;
122
123 if (link_info.relocateable == true && config.build_constructors == true)
124 return
125 EOF
126 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
127 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
128 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
129 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
130 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
131 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
132 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
133 echo ' ; else return' >> e${EMULATION_NAME}.c
134 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
135 echo '; }' >> e${EMULATION_NAME}.c
136
137 else
138 # Scripts read from the filesystem.
139
140 cat >>e${EMULATION_NAME}.c <<EOF
141 {
142 *isfile = 1;
143
144 if (link_info.relocateable == true && config.build_constructors == true)
145 return "ldscripts/${EMULATION_NAME}.xu";
146 else if (link_info.relocateable == true)
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 }
155 EOF
156
157 fi
158
159 cat >>e${EMULATION_NAME}.c <<EOF
160
161 struct ld_emulation_xfer_struct ld_gld960_emulation =
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",
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 */
181 NULL, /* unrecognized file */
182 NULL, /* list options */
183 NULL, /* recognized file */
184 NULL /* find_potential_libraries */
185 };
186 EOF
This page took 0.037987 seconds and 5 git commands to generate.