Update my e-mail address.
[binutils-gdb.git] / bfd / sparclynx.c
blob9fe29f1100dad9f1a9aa155ff461e54fd01221ee
1 /* BFD support for Sparc binaries under LynxOS.
2 Copyright (C) 1990-2017 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
22 /* Do not "beautify" the CONCAT* macro args. Traditional C will not
23 remove whitespace added here, and thus will fail to concatenate
24 the tokens. */
25 #define MY(OP) CONCAT2 (sparc_aout_lynx_,OP)
26 #define TARGETNAME "a.out-sparc-lynx"
28 #include "sysdep.h"
29 #include "bfd.h"
30 #include "libbfd.h"
32 #include "aout/sun4.h"
33 #include "libaout.h" /* BFD a.out internal data structures */
35 #include "aout/aout64.h"
36 #include "aout/stab_gnu.h"
37 #include "aout/ar.h"
39 void NAME (lynx,set_arch_mach) (bfd *, unsigned long);
40 static void choose_reloc_size (bfd *);
41 static bfd_boolean NAME (aout,sparclynx_write_object_contents) (bfd *);
43 /* This is needed to reject a NewsOS file, e.g. in
44 gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
45 I needed to add M_UNKNOWN to recognize a 68000 object, so this will
46 probably no longer reject a NewsOS object. <ian@cygnus.com>. */
47 #define MACHTYPE_OK(mtype) ( (mtype) == M_UNKNOWN \
48 || (mtype) == M_68010 \
49 || (mtype) == M_68020 \
50 || (mtype) == M_SPARC)
52 /* The file @code{aoutf1.h} contains the code for BFD's
53 a.out back end. Control over the generated back end is given by these
54 two preprocessor names:
55 @table @code
56 @item ARCH_SIZE
57 This value should be either 32 or 64, depending upon the size of an
58 int in the target format. It changes the sizes of the structs which
59 perform the memory/disk mapping of structures.
61 The 64 bit backend may only be used if the host compiler supports 64
62 ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
63 With this name defined, @emph{all} bfd operations are performed with 64bit
64 arithmetic, not just those to a 64bit target.
66 @item TARGETNAME
67 The name put into the target vector.
68 @item
69 @end table */
71 void
72 NAME(lynx,set_arch_mach) (bfd *abfd, unsigned long machtype)
74 /* Determine the architecture and machine type of the object file. */
75 enum bfd_architecture arch;
76 unsigned long machine;
78 switch (machtype)
80 case M_UNKNOWN:
81 /* Some Sun3s make magic numbers without cpu types in them, so
82 we'll default to the 68000. */
83 arch = bfd_arch_m68k;
84 machine = bfd_mach_m68000;
85 break;
87 case M_68010:
88 case M_HP200:
89 arch = bfd_arch_m68k;
90 machine = bfd_mach_m68010;
91 break;
93 case M_68020:
94 case M_HP300:
95 arch = bfd_arch_m68k;
96 machine = bfd_mach_m68020;
97 break;
99 case M_SPARC:
100 arch = bfd_arch_sparc;
101 machine = 0;
102 break;
104 case M_386:
105 case M_386_DYNIX:
106 arch = bfd_arch_i386;
107 machine = 0;
108 break;
110 case M_HPUX:
111 arch = bfd_arch_m68k;
112 machine = 0;
113 break;
115 default:
116 arch = bfd_arch_obscure;
117 machine = 0;
118 break;
120 bfd_set_arch_mach (abfd, arch, machine);
123 #define SET_ARCH_MACH(ABFD, EXECP) \
124 NAME(lynx,set_arch_mach) (ABFD, N_MACHTYPE (EXECP)); \
125 choose_reloc_size(ABFD);
127 /* Determine the size of a relocation entry, based on the architecture. */
129 static void
130 choose_reloc_size (bfd *abfd)
132 switch (bfd_get_arch (abfd))
134 case bfd_arch_sparc:
135 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
136 break;
137 default:
138 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
139 break;
143 /* Write an object file in LynxOS format.
144 Section contents have already been written. We write the
145 file header, symbols, and relocation. */
147 static bfd_boolean
148 NAME(aout,sparclynx_write_object_contents) (bfd *abfd)
150 struct external_exec exec_bytes;
151 struct internal_exec *execp = exec_hdr (abfd);
153 /* Magic number, maestro, please! */
154 switch (bfd_get_arch (abfd))
156 case bfd_arch_m68k:
157 switch (bfd_get_mach (abfd))
159 case bfd_mach_m68010:
160 N_SET_MACHTYPE (execp, M_68010);
161 break;
162 default:
163 case bfd_mach_m68020:
164 N_SET_MACHTYPE (execp, M_68020);
165 break;
167 break;
168 case bfd_arch_sparc:
169 N_SET_MACHTYPE (execp, M_SPARC);
170 break;
171 case bfd_arch_i386:
172 N_SET_MACHTYPE (execp, M_386);
173 break;
174 default:
175 N_SET_MACHTYPE (execp, M_UNKNOWN);
178 choose_reloc_size (abfd);
180 N_SET_FLAGS (execp, aout_backend_info (abfd)->exec_hdr_flags);
182 WRITE_HEADERS (abfd, execp);
184 return TRUE;
187 #define MY_set_sizes sparclynx_set_sizes
188 static bfd_boolean sparclynx_set_sizes (bfd *);
190 static bfd_boolean
191 sparclynx_set_sizes (bfd *abfd)
193 switch (bfd_get_arch (abfd))
195 default:
196 return FALSE;
197 case bfd_arch_sparc:
198 adata (abfd).page_size = 0x2000;
199 adata (abfd).segment_size = 0x2000;
200 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
201 return TRUE;
202 case bfd_arch_m68k:
203 adata (abfd).page_size = 0x2000;
204 adata (abfd).segment_size = 0x20000;
205 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
206 return TRUE;
210 static const struct aout_backend_data sparclynx_aout_backend =
212 0, 1, 0, 1, 0, sparclynx_set_sizes, 0,
213 0, /* add_dynamic_symbols */
214 0, /* add_one_symbol */
215 0, /* link_dynamic_object */
216 0, /* write_dynamic_symbol */
217 0, /* check_dynamic_reloc */
218 0 /* finish_dynamic_link */
222 #define MY_bfd_debug_info_start bfd_void
223 #define MY_bfd_debug_info_end bfd_void
224 #define MY_bfd_debug_info_accumulate \
225 (void (*) (bfd *, struct bfd_section *)) bfd_void
227 #define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
228 #define MY_backend_data &sparclynx_aout_backend
230 #define TARGET_IS_BIG_ENDIAN_P
232 #ifdef LYNX_CORE
234 char * lynx_core_file_failing_command ();
235 int lynx_core_file_failing_signal ();
236 bfd_boolean lynx_core_file_matches_executable_p ();
237 const bfd_target * lynx_core_file_p ();
239 #define MY_core_file_failing_command lynx_core_file_failing_command
240 #define MY_core_file_failing_signal lynx_core_file_failing_signal
241 #define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
242 #define MY_core_file_p lynx_core_file_p
244 #endif /* LYNX_CORE */
246 #include "aout-target.h"