1 /* BFD support for Sparc binaries under LynxOS.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
23 #define BYTES_IN_WORD 4
24 #define N_SHARED_LIB(x) 0
26 #define TEXT_START_ADDR 0
27 #define PAGE_SIZE 4096
28 #define SEGMENT_SIZE PAGE_SIZE
29 #define DEFAULT_ARCH bfd_arch_sparc
33 #define MY(OP) CAT(sparclynx_aout_,OP)
34 #define TARGETNAME "a.out-sparc-lynx"
40 #include "aout/sun4.h"
41 #include "libaout.h" /* BFD a.out internal data structures */
43 #include "aout/aout64.h"
44 #include "aout/stab_gnu.h"
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)
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:
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.
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.
72 The name put into the target vector.
82 DEFUN(NAME(lynxos,set_arch_mach), (abfd, machtype),
83 bfd *abfd AND int machtype)
85 /* Determine the architecture and machine type of the object file. */
86 enum bfd_architecture arch;
91 /* Some Sun3s make magic numbers without cpu types in them, so
92 we'll default to the 68000. */
105 arch = bfd_arch_m68k;
110 arch = bfd_arch_sparc;
116 arch = bfd_arch_i386;
121 arch = bfd_arch_a29k;
126 arch = bfd_arch_m68k;
131 arch = bfd_arch_obscure;
135 bfd_set_arch_mach(abfd, arch, machine);
138 #define SET_ARCH_MACH(ABFD, EXEC) \
139 NAME(lynxos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
140 choose_reloc_size(ABFD);
142 /* Determine the size of a relocation entry, based on the architecture */
144 DEFUN(choose_reloc_size,(abfd),
147 switch (bfd_get_arch(abfd)) {
150 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
153 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
158 /* Write an object file in Lynxos format.
159 Section contents have already been written. We write the
160 file header, symbols, and relocation. */
163 DEFUN(NAME(aout,sparclynx_write_object_contents),
167 struct external_exec exec_bytes;
168 struct internal_exec *execp = exec_hdr (abfd);
170 /* Magic number, maestro, please! */
171 switch (bfd_get_arch(abfd)) {
173 switch (bfd_get_mach(abfd)) {
175 N_SET_MACHTYPE(*execp, M_68010);
179 N_SET_MACHTYPE(*execp, M_68020);
184 N_SET_MACHTYPE(*execp, M_SPARC);
187 N_SET_MACHTYPE(*execp, M_386);
190 N_SET_MACHTYPE(*execp, M_29K);
193 N_SET_MACHTYPE(*execp, M_UNKNOWN);
196 choose_reloc_size(abfd);
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);
204 /* Fri Jun 11 14:23:31 PDT 1993
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.
211 N_SET_FLAGS (*execp, 1);
214 WRITE_HEADERS(abfd, execp);
219 #define MY_set_sizes sparclynx_set_sizes
221 DEFUN (sparclynx_set_sizes, (abfd),
224 switch (bfd_get_arch (abfd))
229 adata(abfd).page_size = 0x2000;
230 adata(abfd).segment_size = 0x2000;
231 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
234 adata(abfd).page_size = 0x2000;
235 adata(abfd).segment_size = 0x20000;
236 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
241 static CONST struct aout_backend_data sparclynx_aout_backend = {
242 0, 1, 0, sparclynx_set_sizes, 0,
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
251 #define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
252 #define MY_backend_data &sparclynx_aout_backend
254 #define TARGET_IS_BIG_ENDIAN_P
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();
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
268 #endif /* HOST_LYNX */
270 #include "aout-target.h"