Convert i960 COFF to use COFF backend linker.
[deliverable/binutils-gdb.git] / bfd / sparclynx.c
1 /* BFD support for Sparc binaries under LynxOS.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #define ARCH 32
21
22 #if 0
23 #define BYTES_IN_WORD 4
24 #define N_SHARED_LIB(x) 0
25
26 #define TEXT_START_ADDR 0
27 #define PAGE_SIZE 4096
28 #define SEGMENT_SIZE PAGE_SIZE
29 #define DEFAULT_ARCH bfd_arch_sparc
30
31 #endif
32
33 #define MY(OP) CAT(sparclynx_aout_,OP)
34 #define TARGETNAME "a.out-sparc-lynx"
35
36 #include "bfd.h"
37 #include "sysdep.h"
38 #include "libbfd.h"
39
40 #include "aout/sun4.h"
41 #include "libaout.h" /* BFD a.out internal data structures */
42
43 #include "aout/aout64.h"
44 #include "aout/stab_gnu.h"
45 #include "aout/ar.h"
46
47 /* This is needed to reject a NewsOS file, e.g. in
48 gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
49 I needed to add M_UNKNOWN to recognize a 68000 object, so this will
50 probably no longer reject a NewsOS object. <ian@cygnus.com>. */
51 #define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
52 || (mtype) == M_68010 \
53 || (mtype) == M_68020 \
54 || (mtype) == M_SPARC)
55
56 /*
57 The file @code{aoutf1.h} contains the code for BFD's
58 a.out back end. Control over the generated back end is given by these
59 two preprocessor names:
60 @table @code
61 @item ARCH_SIZE
62 This value should be either 32 or 64, depending upon the size of an
63 int in the target format. It changes the sizes of the structs which
64 perform the memory/disk mapping of structures.
65
66 The 64 bit backend may only be used if the host compiler supports 64
67 ints (eg long long with gcc), by defining the name @code{HOST_64_BIT} in @code{bfd.h}.
68 With this name defined, @emph{all} bfd operations are performed with 64bit
69 arithmetic, not just those to a 64bit target.
70
71 @item TARGETNAME
72 The name put into the target vector.
73 @item
74 @end table
75
76 */
77
78 /*SUPPRESS558*/
79 /*SUPPRESS529*/
80
81 void
82 DEFUN(NAME(lynxos,set_arch_mach), (abfd, machtype),
83 bfd *abfd AND int machtype)
84 {
85 /* Determine the architecture and machine type of the object file. */
86 enum bfd_architecture arch;
87 long machine;
88 switch (machtype) {
89
90 case M_UNKNOWN:
91 /* Some Sun3s make magic numbers without cpu types in them, so
92 we'll default to the 68000. */
93 arch = bfd_arch_m68k;
94 machine = 68000;
95 break;
96
97 case M_68010:
98 case M_HP200:
99 arch = bfd_arch_m68k;
100 machine = 68010;
101 break;
102
103 case M_68020:
104 case M_HP300:
105 arch = bfd_arch_m68k;
106 machine = 68020;
107 break;
108
109 case M_SPARC:
110 arch = bfd_arch_sparc;
111 machine = 0;
112 break;
113
114 case M_386:
115 case M_386_DYNIX:
116 arch = bfd_arch_i386;
117 machine = 0;
118 break;
119
120 case M_29K:
121 arch = bfd_arch_a29k;
122 machine = 0;
123 break;
124
125 case M_HPUX:
126 arch = bfd_arch_m68k;
127 machine = 0;
128 break;
129
130 default:
131 arch = bfd_arch_obscure;
132 machine = 0;
133 break;
134 }
135 bfd_set_arch_mach(abfd, arch, machine);
136 }
137
138 #define SET_ARCH_MACH(ABFD, EXEC) \
139 NAME(lynxos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
140 choose_reloc_size(ABFD);
141
142 /* Determine the size of a relocation entry, based on the architecture */
143 static void
144 DEFUN(choose_reloc_size,(abfd),
145 bfd *abfd)
146 {
147 switch (bfd_get_arch(abfd)) {
148 case bfd_arch_sparc:
149 case bfd_arch_a29k:
150 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
151 break;
152 default:
153 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
154 break;
155 }
156 }
157
158 /* Write an object file in Lynxos format.
159 Section contents have already been written. We write the
160 file header, symbols, and relocation. */
161
162 static boolean
163 DEFUN(NAME(aout,sparclynx_write_object_contents),
164 (abfd),
165 bfd *abfd)
166 {
167 struct external_exec exec_bytes;
168 struct internal_exec *execp = exec_hdr (abfd);
169
170 /* Magic number, maestro, please! */
171 switch (bfd_get_arch(abfd)) {
172 case bfd_arch_m68k:
173 switch (bfd_get_mach(abfd)) {
174 case 68010:
175 N_SET_MACHTYPE(*execp, M_68010);
176 break;
177 default:
178 case 68020:
179 N_SET_MACHTYPE(*execp, M_68020);
180 break;
181 }
182 break;
183 case bfd_arch_sparc:
184 N_SET_MACHTYPE(*execp, M_SPARC);
185 break;
186 case bfd_arch_i386:
187 N_SET_MACHTYPE(*execp, M_386);
188 break;
189 case bfd_arch_a29k:
190 N_SET_MACHTYPE(*execp, M_29K);
191 break;
192 default:
193 N_SET_MACHTYPE(*execp, M_UNKNOWN);
194 }
195
196 choose_reloc_size(abfd);
197
198 #if 0
199 /* Some tools want this to be 0, some tools want this to be one.
200 Today, it seems that 0 is the most important setting (PR1927) */
201 N_SET_FLAGS (*execp, 0x0);
202 #else
203
204 /* Fri Jun 11 14:23:31 PDT 1993
205 FIXME
206 Today's optimal setting is 1. This is a pain, since it
207 reopens 1927. This should be readdressed by creating a new
208 target for each each supported, giving perhaps sun3/m68k
209 and sun4/sparc a.out formats.
210 */
211 N_SET_FLAGS (*execp, 1);
212 #endif
213
214 WRITE_HEADERS(abfd, execp);
215
216 return true;
217 }
218
219 #define MY_set_sizes sparclynx_set_sizes
220 static boolean
221 DEFUN (sparclynx_set_sizes, (abfd),
222 bfd *abfd)
223 {
224 switch (bfd_get_arch (abfd))
225 {
226 default:
227 return false;
228 case bfd_arch_sparc:
229 adata(abfd).page_size = 0x2000;
230 adata(abfd).segment_size = 0x2000;
231 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
232 return true;
233 case bfd_arch_m68k:
234 adata(abfd).page_size = 0x2000;
235 adata(abfd).segment_size = 0x20000;
236 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
237 return true;
238 }
239 }
240
241 static CONST struct aout_backend_data sparclynx_aout_backend = {
242 0, 1, 0, sparclynx_set_sizes, 0,
243 };
244 \f
245
246 #define MY_bfd_debug_info_start bfd_void
247 #define MY_bfd_debug_info_end bfd_void
248 #define MY_bfd_debug_info_accumulate \
249 (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
250
251 #define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
252 #define MY_backend_data &sparclynx_aout_backend
253
254 #define TARGET_IS_BIG_ENDIAN_P
255
256 #ifdef HOST_LYNX
257
258 char *lynx_core_file_failing_command();
259 int lynx_core_file_failing_signal();
260 boolean lynx_core_file_matches_executable_p();
261 bfd_target *lynx_core_file_p();
262
263 #define MY_core_file_failing_command lynx_core_file_failing_command
264 #define MY_core_file_failing_signal lynx_core_file_failing_signal
265 #define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
266 #define MY_core_file_p lynx_core_file_p
267
268 #endif /* HOST_LYNX */
269
270 #include "aout-target.h"
This page took 0.0344 seconds and 4 git commands to generate.