Replace MINUS_G by CFLAGS.
[deliverable/binutils-gdb.git] / ld / ldlnk960.c
CommitLineData
2d1a2445
PB
1/* intel coff loader emulation specific stuff
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Steve Chamberlain steve@cygnus.com
15ed1567
SC
4
5This file is part of GLD, the Gnu Linker.
6
7GLD is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
2d1a2445 9the Free Software Foundation; either version 2, or (at your option)
15ed1567
SC
10any later version.
11
12GLD is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GLD; see the file COPYING. If not, write to
19the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21/*
22 $Id$
23*/
24
15ed1567 25#include "bfd.h"
f177a611 26#include "sysdep.h"
15ed1567
SC
27
28/*#include "archures.h"*/
29#include "ld.h"
30#include "config.h"
31#include "ldemul.h"
32#include "ldmisc.h"
33#include "ldlang.h"
34#include "ldfile.h"
35
36extern boolean lang_float_flag;
37extern bfd *output_bfd;
38
39
40
41extern enum bfd_architecture ldfile_output_architecture;
42extern unsigned long ldfile_output_machine;
43extern char *ldfile_output_machine_name;
44
45
46typedef struct lib_list {
47 char *name;
48 struct lib_list *next;
49} lib_list_type;
50
51static lib_list_type *hll_list;
52static lib_list_type **hll_list_tail = &hll_list;
53
54static lib_list_type *syslib_list;
55static lib_list_type **syslib_list_tail = &syslib_list;
56
57
58static void
59append(list, name)
60lib_list_type ***list;
61char *name;
62{
63 lib_list_type *element =
64 (lib_list_type *)(ldmalloc(sizeof(lib_list_type)));
65
66 element->name = name;
67 element->next = (lib_list_type *)NULL;
68 **list = element;
69 *list = &element->next;
70
71}
72
73static boolean had_hll = false;
74static boolean had_hll_name = false;
75static void
76lnk960_hll(name)
77char *name;
78{
79 had_hll = true;
80 if (name != (char *)NULL) {
81 had_hll_name = true;
82 append(&hll_list_tail, name);
83 }
84}
85
86static void
87lnk960_syslib(name)
88char *name;
89{
90 append(&syslib_list_tail,name);
91}
92
93
94
95#ifdef GNU960
96
97static void
98lnk960_before_parse()
99{
100 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
101 char **p;
102 char *env ;
103
104 for ( p = env_variables; *p; p++ ){
105 env = (char *) getenv(*p);
106 if (env) {
107 ldfile_add_library_path(concat(env,"/lib/libcoff",""));
108 }
109 }
110
111 env= (char *) getenv("I960BASE");
112 if ( env ) {
113 ldfile_add_library_path(concat(env,"/lib",""));
114 }
115
116 ldfile_output_architecture = bfd_arch_i960;
117 ldfile_output_machine = bfd_mach_i960_core;
118}
119
120#else /* not GNU960 */
121
122static void
123lnk960_before_parse()
124{
125 char *name = getenv("I960BASE");
126
127 if (name == (char *)NULL) {
128 name = getenv("G960BASE");
129 if (name == (char *)NULL) {
1c9e4b15 130 einfo("%P%F I960BASE and G960BASE not set\n");
15ed1567
SC
131 }
132 }
133
134
135 ldfile_add_library_path(concat(name,"/lib",""));
136 ldfile_output_architecture = bfd_arch_i960;
137 ldfile_output_machine = bfd_mach_i960_core;
138}
139
140#endif /* GNU960 */
141
142
143static void
144add_on(list, search)
145lib_list_type *list;
146lang_input_file_enum_type search;
147{
148 while (list) {
149 lang_add_input_file(list->name,
150 search,
151 (char *)NULL);
152 list = list->next;
153 }
154}
155static void lnk960_after_parse()
156{
157
158 /* If there has been no arch, default to -KB */
159 if (ldfile_output_machine_name[0] ==0) {
160 ldfile_add_arch("KB");
161 }
162
163 /* if there has been no hll list then add our own */
164
165 if(had_hll && !had_hll_name) {
166 append(&hll_list_tail,"cg");
167 if (ldfile_output_machine == bfd_mach_i960_ka_sa ||
168 ldfile_output_machine == bfd_mach_i960_ca) {
169 {
170 append(&hll_list_tail,"fpg");
171 }
172 }
173 }
174
175 add_on(hll_list, lang_input_file_is_l_enum);
176 add_on(syslib_list, lang_input_file_is_search_file_enum);
177}
178
179static void
180lnk960_before_allocation()
181{
182}
183static void
184lnk960_after_allocation()
185{
186 extern ld_config_type config;
187 if (config.relocateable_output == false) {
188 lang_abs_symbol_at_end_of(".text","_etext");
189 lang_abs_symbol_at_end_of(".data","_edata");
190 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
191 lang_abs_symbol_at_end_of(".bss","_end");
192 }
193}
194
195
196static struct
197 {
198 unsigned long number;
199 char *name;
200 }
201machine_table[] = {
202 bfd_mach_i960_core ,"CORE",
203 bfd_mach_i960_kb_sb ,"KB",
204 bfd_mach_i960_kb_sb ,"SB",
205 bfd_mach_i960_mc ,"MC",
206 bfd_mach_i960_xa ,"XA",
207 bfd_mach_i960_ca ,"CA",
208 bfd_mach_i960_ka_sa ,"KA",
209 bfd_mach_i960_ka_sa ,"SA",
210
211 bfd_mach_i960_core ,"core",
212 bfd_mach_i960_kb_sb ,"kb",
213 bfd_mach_i960_kb_sb ,"sb",
214 bfd_mach_i960_mc ,"mc",
215 bfd_mach_i960_xa ,"xa",
216 bfd_mach_i960_ca ,"ca",
217 bfd_mach_i960_ka_sa ,"ka",
218 bfd_mach_i960_ka_sa ,"sa",
219 0,(char *)NULL
220};
221
222static void
223lnk960_set_output_arch()
224{
225 /* Set the output architecture and machine if possible */
226 unsigned int i;
227 ldfile_output_machine = bfd_mach_i960_core;
228 for (i= 0; machine_table[i].name != (char*)NULL; i++) {
229 if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) {
230 ldfile_output_machine = machine_table[i].number;
231 break;
232 }
233 }
234 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine);
235}
236
237static char *
238lnk960_choose_target()
239{
240#ifdef GNU960
241
19b03b7a 242 return bfd_make_targ_name(BFD_COFF_FORMAT, 0);
15ed1567
SC
243
244#else
245
246 char *from_outside = getenv(TARGET_ENVIRON);
247 if (from_outside != (char *)NULL)
248 return from_outside;
0cc6a796
SC
249#ifdef LNK960_LITTLE
250 return LNK960_TARGET_LITTLE
251#else
15ed1567 252 return LNK960_TARGET;
15ed1567 253#endif
0cc6a796
SC
254#endif
255
15ed1567
SC
256}
257
258/* The default script if none is offered */
259static char *lnk960_script =
260#include "ldlnk960.x"
261;
262
263
264static char *lnk960_script_relocateable =
e1e5fbfc 265#include "ldlnk960.xr"
15ed1567
SC
266;
267
268static char *lnk960_get_script()
269{
270 extern ld_config_type config;
271 if (config.relocateable_output) {
272 return lnk960_script_relocateable;
273 }
274 return lnk960_script;
275}
276struct ld_emulation_xfer_struct ld_lnk960_emulation =
277{
278 lnk960_before_parse,
279 lnk960_syslib,
280 lnk960_hll,
281 lnk960_after_parse,
282 lnk960_after_allocation,
283 lnk960_set_output_arch,
284 lnk960_choose_target,
285 lnk960_before_allocation,
286 lnk960_get_script,
287};
This page took 0.08586 seconds and 4 git commands to generate.