* pe-dll.c: New file; direct support for PE DLLs
[deliverable/binutils-gdb.git] / ld / emultempl / gld960c.em
CommitLineData
d0d5edba
ILT
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
4/* Copyright (C) 1991, 1993 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22/*
23 * emulate the Intels port of gld
24 */
25
26
27#include <ctype.h>
28#include "bfd.h"
29#include "sysdep.h"
30#include "libiberty.h"
31#include "bfdlink.h"
32
33#include "ld.h"
34#include "ldemul.h"
35#include "ldfile.h"
36#include "ldmisc.h"
37#include "ldmain.h"
38
39#ifdef GNU960
40
41static void
42gld960_before_parse()
43{
44 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
45 char **p;
46 char *env ;
47
48 for ( p = env_variables; *p; p++ ){
49 env = (char *) getenv(*p);
50 if (env) {
51 ldfile_add_library_path (concat (env,
52 "/lib/libcoff",
53 (const char *) NULL),
54 false);
55 }
56 }
57 ldfile_output_architecture = bfd_arch_i960;
58}
59
60#else /* not GNU960 */
61
62static void gld960_before_parse()
63{
64 char *env ;
65 env = getenv("G960LIB");
66 if (env) {
67 ldfile_add_library_path(env, false);
68 }
69 env = getenv("G960BASE");
70 if (env)
71 ldfile_add_library_path (concat (env, "/lib", (const char *) NULL),
72 false);
73 ldfile_output_architecture = bfd_arch_i960;
74}
75
76#endif /* GNU960 */
77
78
79static void
80gld960_set_output_arch()
81{
82 if (ldfile_output_machine_name != NULL
83 && *ldfile_output_machine_name != '\0')
84 {
85 char *s, *s1;
86
87 s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
88 for (s1 = s; *s1 != '\0'; s1++)
89 if (isupper ((unsigned char) *s1))
90 *s1 = tolower ((unsigned char) *s1);
91 ldfile_set_output_arch (s);
92 free (s);
93 }
94
95 set_output_arch_default ();
96}
97
98static char *
99gld960_choose_target()
100{
101#ifdef GNU960
102
103 output_filename = "b.out";
104 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
105
106#else
107
108 char *from_outside = getenv(TARGET_ENVIRON);
109 output_filename = "b.out";
110
111 if (from_outside != (char *)NULL)
112 return from_outside;
113
114 return "coff-Intel-little";
115
116#endif
117}
118
119static char *
120gld960_get_script(isfile)
121 int *isfile;
122EOF
123
124if test -n "$COMPILE_IN"
125then
126# Scripts compiled in.
127
128# sed commands to quote an ld script as a C string.
129sc='s/["\\]/\\&/g
130s/$/\\n\\/
1311s/^/"/
132$s/$/n"/
133'
134
135cat >>e${EMULATION_NAME}.c <<EOF
136{
137 *isfile = 0;
138
139 if (link_info.relocateable == true && config.build_constructors == true)
140 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
141 else if (link_info.relocateable == true)
142 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
143 else if (!config.text_read_only)
144 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
145 else if (!config.magic_demand_paged)
146 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
147 else
148 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
149}
150EOF
151
152else
153# Scripts read from the filesystem.
154
155cat >>e${EMULATION_NAME}.c <<EOF
156{
157 *isfile = 1;
158
159 if (link_info.relocateable == true && config.build_constructors == true)
160 return "ldscripts/${EMULATION_NAME}.xu";
161 else if (link_info.relocateable == 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 >>e${EMULATION_NAME}.c <<EOF
175
176struct ld_emulation_xfer_struct ld_gld960coff_emulation =
177{
178 gld960_before_parse,
179 syslib_default,
180 hll_default,
181 after_parse_default,
182 after_open_default,
183 after_allocation_default,
184 gld960_set_output_arch,
185 gld960_choose_target,
186 before_allocation_default,
187 gld960_get_script,
188 "960coff",
189 ""
190};
191EOF
This page took 0.079362 seconds and 4 git commands to generate.