1 /* intel coff loader emulation specific stuff
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Steve Chamberlain steve@cygnus.com
5 This file is part of GLD, the Gnu Linker.
7 GLD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GLD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GLD; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
28 /*#include "archures.h"*/
36 extern boolean lang_float_flag
;
37 extern bfd
*output_bfd
;
41 extern enum bfd_architecture ldfile_output_architecture
;
42 extern unsigned long ldfile_output_machine
;
43 extern char *ldfile_output_machine_name
;
46 typedef struct lib_list
{
48 struct lib_list
*next
;
51 static lib_list_type
*hll_list
;
52 static lib_list_type
**hll_list_tail
= &hll_list
;
54 static lib_list_type
*syslib_list
;
55 static lib_list_type
**syslib_list_tail
= &syslib_list
;
60 lib_list_type
***list
;
63 lib_list_type
*element
=
64 (lib_list_type
*)(ldmalloc(sizeof(lib_list_type
)));
67 element
->next
= (lib_list_type
*)NULL
;
69 *list
= &element
->next
;
73 static boolean had_hll
= false;
74 static boolean had_hll_name
= false;
80 if (name
!= (char *)NULL
) {
82 append(&hll_list_tail
, name
);
90 append(&syslib_list_tail
,name
);
100 static char *env_variables
[] = { "G960LIB", "G960BASE", 0 };
104 for ( p
= env_variables
; *p
; p
++ ){
105 env
= (char *) getenv(*p
);
107 ldfile_add_library_path(concat(env
,"/lib/libcoff",""));
111 env
= (char *) getenv("I960BASE");
113 ldfile_add_library_path(concat(env
,"/lib",""));
116 ldfile_output_architecture
= bfd_arch_i960
;
117 ldfile_output_machine
= bfd_mach_i960_core
;
120 #else /* not GNU960 */
123 lnk960_before_parse()
125 char *name
= getenv("I960BASE");
127 if (name
== (char *)NULL
) {
128 name
= getenv("G960BASE");
129 if (name
== (char *)NULL
) {
130 einfo("%P%F I960BASE and G960BASE not set\n");
135 ldfile_add_library_path(concat(name
,"/lib",""));
136 ldfile_output_architecture
= bfd_arch_i960
;
137 ldfile_output_machine
= bfd_mach_i960_core
;
146 lang_input_file_enum_type search
;
149 lang_add_input_file(list
->name
,
155 static void lnk960_after_parse()
158 /* If there has been no arch, default to -KB */
159 if (ldfile_output_machine_name
[0] ==0) {
160 ldfile_add_arch("KB");
163 /* if there has been no hll list then add our own */
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
) {
170 append(&hll_list_tail
,"fpg");
175 add_on(hll_list
, lang_input_file_is_l_enum
);
176 add_on(syslib_list
, lang_input_file_is_search_file_enum
);
180 lnk960_before_allocation()
184 lnk960_after_allocation()
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");
198 unsigned long number
;
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",
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",
223 lnk960_set_output_arch()
225 /* Set the output architecture and machine if possible */
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
;
234 bfd_set_arch_mach(output_bfd
, ldfile_output_architecture
, ldfile_output_machine
);
238 lnk960_choose_target()
242 return bfd_make_targ_name(BFD_COFF_FORMAT
, 0);
246 char *from_outside
= getenv(TARGET_ENVIRON
);
247 if (from_outside
!= (char *)NULL
)
250 return LNK960_TARGET_LITTLE
252 return LNK960_TARGET
;
258 /* The default script if none is offered */
259 static char *lnk960_script
=
260 #include "ldlnk960.x"
264 static char *lnk960_script_relocateable
=
265 #include "ldlnk960.xr"
268 static char *lnk960_get_script()
270 extern ld_config_type config
;
271 if (config
.relocateable_output
) {
272 return lnk960_script_relocateable
;
274 return lnk960_script
;
276 struct ld_emulation_xfer_struct ld_lnk960_emulation
=
282 lnk960_after_allocation
,
283 lnk960_set_output_arch
,
284 lnk960_choose_target
,
285 lnk960_before_allocation
,