1 /* Copyright (C) 1991 Free Software Foundation, Inc.
3 This file is part of GLD, the Gnu Linker.
5 GLD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
10 GLD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GLD; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 Written by Steve Chamberlain steve@cygnus.com
27 * intel coff loader emulation specific stuff
33 /*#include "archures.h"*/
41 extern boolean lang_float_flag
;
42 extern bfd
*output_bfd
;
46 extern enum bfd_architecture ldfile_output_architecture
;
47 extern unsigned long ldfile_output_machine
;
48 extern char *ldfile_output_machine_name
;
51 typedef struct lib_list
{
53 struct lib_list
*next
;
56 static lib_list_type
*hll_list
;
57 static lib_list_type
**hll_list_tail
= &hll_list
;
59 static lib_list_type
*syslib_list
;
60 static lib_list_type
**syslib_list_tail
= &syslib_list
;
65 lib_list_type
***list
;
68 lib_list_type
*element
=
69 (lib_list_type
*)(ldmalloc(sizeof(lib_list_type
)));
72 element
->next
= (lib_list_type
*)NULL
;
74 *list
= &element
->next
;
78 static boolean had_hll
= false;
79 static boolean had_hll_name
= false;
85 if (name
!= (char *)NULL
) {
87 append(&hll_list_tail
, name
);
95 append(&syslib_list_tail
,name
);
103 lnk960_before_parse()
105 static char *env_variables
[] = { "G960LIB", "G960BASE", 0 };
109 for ( p
= env_variables
; *p
; p
++ ){
110 env
= (char *) getenv(*p
);
112 ldfile_add_library_path(concat(env
,"/lib/libcoff",""));
116 env
= (char *) getenv("I960BASE");
118 ldfile_add_library_path(concat(env
,"/lib",""));
121 ldfile_output_architecture
= bfd_arch_i960
;
122 ldfile_output_machine
= bfd_mach_i960_core
;
125 #else /* not GNU960 */
128 lnk960_before_parse()
130 char *name
= getenv("I960BASE");
132 if (name
== (char *)NULL
) {
133 name
= getenv("G960BASE");
134 if (name
== (char *)NULL
) {
135 info("%P%F I960BASE and G960BASE not set\n");
140 ldfile_add_library_path(concat(name
,"/lib",""));
141 ldfile_output_architecture
= bfd_arch_i960
;
142 ldfile_output_machine
= bfd_mach_i960_core
;
151 lang_input_file_enum_type search
;
154 lang_add_input_file(list
->name
,
160 static void lnk960_after_parse()
163 /* If there has been no arch, default to -KB */
164 if (ldfile_output_machine_name
[0] ==0) {
165 ldfile_add_arch("KB");
168 /* if there has been no hll list then add our own */
170 if(had_hll
&& !had_hll_name
) {
171 append(&hll_list_tail
,"cg");
172 if (ldfile_output_machine
== bfd_mach_i960_ka_sa
||
173 ldfile_output_machine
== bfd_mach_i960_ca
) {
175 append(&hll_list_tail
,"fpg");
180 add_on(hll_list
, lang_input_file_is_l_enum
);
181 add_on(syslib_list
, lang_input_file_is_search_file_enum
);
185 lnk960_before_allocation()
189 lnk960_after_allocation()
191 extern ld_config_type config
;
192 if (config
.relocateable_output
== false) {
193 lang_abs_symbol_at_end_of(".text","_etext");
194 lang_abs_symbol_at_end_of(".data","_edata");
195 lang_abs_symbol_at_beginning_of(".bss","_bss_start");
196 lang_abs_symbol_at_end_of(".bss","_end");
203 unsigned long number
;
207 bfd_mach_i960_core
,"CORE",
208 bfd_mach_i960_kb_sb
,"KB",
209 bfd_mach_i960_kb_sb
,"SB",
210 bfd_mach_i960_mc
,"MC",
211 bfd_mach_i960_xa
,"XA",
212 bfd_mach_i960_ca
,"CA",
213 bfd_mach_i960_ka_sa
,"KA",
214 bfd_mach_i960_ka_sa
,"SA",
216 bfd_mach_i960_core
,"core",
217 bfd_mach_i960_kb_sb
,"kb",
218 bfd_mach_i960_kb_sb
,"sb",
219 bfd_mach_i960_mc
,"mc",
220 bfd_mach_i960_xa
,"xa",
221 bfd_mach_i960_ca
,"ca",
222 bfd_mach_i960_ka_sa
,"ka",
223 bfd_mach_i960_ka_sa
,"sa",
228 lnk960_set_output_arch()
230 /* Set the output architecture and machine if possible */
232 ldfile_output_machine
= bfd_mach_i960_core
;
233 for (i
= 0; machine_table
[i
].name
!= (char*)NULL
; i
++) {
234 if (strcmp(ldfile_output_machine_name
,machine_table
[i
].name
)==0) {
235 ldfile_output_machine
= machine_table
[i
].number
;
239 bfd_set_arch_mach(output_bfd
, ldfile_output_architecture
, ldfile_output_machine
);
243 lnk960_choose_target()
247 return bfd_make_targ_name(BFD_COFF_FORMAT
,HOST_BYTE_ORDER_BIG_P
);
251 char *from_outside
= getenv(TARGET_ENVIRON
);
252 if (from_outside
!= (char *)NULL
)
254 return LNK960_TARGET
;
259 /* The default script if none is offered */
260 static char *lnk960_script
=
261 #include "ld-lnk960.x"
265 static char *lnk960_script_relocateable
=
266 #include "ld-lnk960-r.x"
269 static char *lnk960_get_script()
271 extern ld_config_type config
;
272 if (config
.relocateable_output
) {
273 return lnk960_script_relocateable
;
275 return lnk960_script
;
277 struct ld_emulation_xfer_struct ld_lnk960_emulation
=
283 lnk960_after_allocation
,
284 lnk960_set_output_arch
,
285 lnk960_choose_target
,
286 lnk960_before_allocation
,