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. */
23 Revision 1.1 1991/03/21 21:28:28 gumby
26 * Revision 1.2 1991/03/15 18:45:55 rich
29 * Revision 1.1 1991/03/13 00:48:13 chrisb
32 * Revision 1.6 1991/03/10 09:31:20 rich
34 * Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
35 * ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
36 * ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
37 * ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
38 * ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
40 * As of this round of changes, ld now builds on all hosts of (Intel960)
41 * interest and copy passes my copy test on big endian hosts again.
43 * Revision 1.5 1991/03/09 03:23:47 sac
44 * Now looks in G960BASE if I960BASE isn't defined.
46 * Revision 1.4 1991/03/06 02:23:35 sac
47 * Added support for partial linking.
49 * Revision 1.3 1991/02/22 17:14:58 sac
50 * Added RCS keywords and copyrights
56 Written by Steve Chamberlain steve@cygnus.com
58 * intel coff loader emulation specific stuff
64 /*#include "archures.h"*/
72 extern boolean lang_float_flag
;
73 extern bfd
*output_bfd
;
77 extern enum bfd_architecture ldfile_output_architecture
;
78 extern unsigned long ldfile_output_machine
;
79 extern char *ldfile_output_machine_name
;
82 typedef struct lib_list
{
84 struct lib_list
*next
;
87 static lib_list_type
*hll_list
;
88 static lib_list_type
**hll_list_tail
= &hll_list
;
90 static lib_list_type
*syslib_list
;
91 static lib_list_type
**syslib_list_tail
= &syslib_list
;
96 lib_list_type
***list
;
99 lib_list_type
*element
=
100 (lib_list_type
*)(ldmalloc(sizeof(lib_list_type
)));
102 element
->name
= name
;
103 element
->next
= (lib_list_type
*)NULL
;
105 *list
= &element
->next
;
109 static boolean had_hll
= false;
110 static boolean had_hll_name
= false;
116 if (name
!= (char *)NULL
) {
118 append(&hll_list_tail
, name
);
126 append(&syslib_list_tail
,name
);
132 lnk960_before_parse()
134 char *name
= getenv("I960BASE");
136 if (name
== (char *)NULL
) {
137 name
= getenv("G960BASE");
138 if (name
== (char *)NULL
) {
139 info("%P%F I960BASE and G960BASE not set\n");
144 ldfile_add_library_path(concat(name
,"/lib",""));
145 ldfile_output_architecture
= bfd_arch_i960
;
146 ldfile_output_machine
= bfd_mach_i960_core
;
152 lang_input_file_enum_type search
;
155 lang_add_input_file(list
->name
,
161 static void lnk960_after_parse()
164 /* If there has been no arch, default to -KB */
165 if (ldfile_output_machine_name
[0] ==0) {
166 ldfile_add_arch("kb");
169 /* if there has been no hll list then add our own */
171 if(had_hll
&& !had_hll_name
) {
172 append(&hll_list_tail
,"c");
173 if (lang_float_flag
== true) {
174 append(&hll_list_tail
,"m");
177 append(&hll_list_tail
,"mstub");
179 if (ldfile_output_machine
== bfd_mach_i960_ka_sa
||
180 ldfile_output_machine
== bfd_mach_i960_ca
) {
182 append(&hll_list_tail
,"f");
189 add_on(hll_list
, lang_input_file_is_l_enum
);
190 add_on(syslib_list
, lang_input_file_is_search_file_enum
);
196 lnk960_before_allocation()
200 lnk960_after_allocation()
202 lang_abs_symbol_at_end_of(".text","_etext");
203 lang_abs_symbol_at_end_of(".data","_edata");
204 lang_abs_symbol_at_end_of(".bss","_end");
209 unsigned long number
;
213 bfd_mach_i960_core
,"CORE",
214 bfd_mach_i960_kb_sb
,"KB",
215 bfd_mach_i960_kb_sb
,"SB",
216 bfd_mach_i960_mc
,"MC",
217 bfd_mach_i960_xa
,"XA",
218 bfd_mach_i960_ca
,"CA",
219 bfd_mach_i960_ka_sa
,"KA",
220 bfd_mach_i960_ka_sa
,"SA",
222 bfd_mach_i960_core
,"core",
223 bfd_mach_i960_kb_sb
,"kb",
224 bfd_mach_i960_kb_sb
,"sb",
225 bfd_mach_i960_mc
,"mc",
226 bfd_mach_i960_xa
,"xa",
227 bfd_mach_i960_ca
,"ca",
228 bfd_mach_i960_ka_sa
,"ka",
229 bfd_mach_i960_ka_sa
,"sa",
234 lnk960_set_output_arch()
236 /* Set the output architecture and machine if possible */
238 ldfile_output_machine
= bfd_mach_i960_core
;
239 for (i
= 0; machine_table
[i
].name
!= (char*)NULL
; i
++) {
240 if (strcmp(ldfile_output_machine_name
,machine_table
[i
].name
)==0) {
241 ldfile_output_machine
= machine_table
[i
].number
;
245 bfd_set_arch_mach(output_bfd
, ldfile_output_architecture
, ldfile_output_machine
);
249 lnk960_choose_target()
251 char *from_outside
= getenv(TARGET_ENVIRON
);
252 if (from_outside
!= (char *)NULL
)
254 return LNK960_TARGET
;
257 /* The default script if none is offered */
258 static char *lnk960_script
= "\
266 .data SIZEOF(.text) + ADDR(.text):\
271 .bss SIZEOF(.data) + ADDR(.data) : \
281 static char *lnk960_script_relocateable
= "\
292 .bss SIZEOF(.data) + ADDR(.data) : \
300 static char *lnk960_get_script()
302 extern ld_config_type config
;
303 if (config
.relocateable_output
) {
304 return lnk960_script_relocateable
;
306 return lnk960_script
;
310 struct ld_emulation_xfer_struct ld_lnk960_emulation
=
316 lnk960_after_allocation
,
317 lnk960_set_output_arch
,
318 lnk960_choose_target
,
319 lnk960_before_allocation
,