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
25 #define MY(OP) CONCAT2 (sparc_aout_lynx_,OP)
26 #define TARGETNAME "a.out-sparc-lynx"
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"
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:
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.
67 The name put into the target vector.
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;
81 /* Some Sun3s make magic numbers without cpu types in them, so
82 we'll default to the 68000. */
84 machine = bfd_mach_m68000;
90 machine = bfd_mach_m68010;
96 machine = bfd_mach_m68020;
100 arch = bfd_arch_sparc;
106 arch = bfd_arch_i386;
111 arch = bfd_arch_m68k;
116 arch = bfd_arch_obscure;
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. */
130 choose_reloc_size (bfd *abfd)
132 switch (bfd_get_arch (abfd))
135 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
138 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
143 /* Write an object file in LynxOS format.
144 Section contents have already been written. We write the
145 file header, symbols, and relocation. */
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))
157 switch (bfd_get_mach (abfd))
159 case bfd_mach_m68010:
160 N_SET_MACHTYPE (execp, M_68010);
163 case bfd_mach_m68020:
164 N_SET_MACHTYPE (execp, M_68020);
169 N_SET_MACHTYPE (execp, M_SPARC);
172 N_SET_MACHTYPE (execp, M_386);
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);
187 #define MY_set_sizes sparclynx_set_sizes
188 static bfd_boolean sparclynx_set_sizes (bfd *);
191 sparclynx_set_sizes (bfd *abfd)
193 switch (bfd_get_arch (abfd))
198 adata (abfd).page_size = 0x2000;
199 adata (abfd).segment_size = 0x2000;
200 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
203 adata (abfd).page_size = 0x2000;
204 adata (abfd).segment_size = 0x20000;
205 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
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
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"