Fix AArch32 build attributes for Armv8.4-A.
[deliverable/binutils-gdb.git] / bfd / sparclynx.c
CommitLineData
252b5132 1/* BFD support for Sparc binaries under LynxOS.
219d1afa 2 Copyright (C) 1990-2018 Free Software Foundation, Inc.
252b5132 3
cd123cb7 4 This file is part of BFD, the Binary File Descriptor library.
252b5132 5
cd123cb7
NC
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.
252b5132 10
cd123cb7
NC
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., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
252b5132 20
252b5132 21
e43d48cc
AM
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. */
6d00b590 25#define MY(OP) CONCAT2 (sparc_aout_lynx_,OP)
252b5132
RH
26#define TARGETNAME "a.out-sparc-lynx"
27
252b5132 28#include "sysdep.h"
3db64b00 29#include "bfd.h"
252b5132
RH
30#include "libbfd.h"
31
32#include "aout/sun4.h"
33#include "libaout.h" /* BFD a.out internal data structures */
34
35#include "aout/aout64.h"
36#include "aout/stab_gnu.h"
37#include "aout/ar.h"
38
2c3fc389
NC
39void NAME (lynx,set_arch_mach) (bfd *, unsigned long);
40static void choose_reloc_size (bfd *);
41static bfd_boolean NAME (aout,sparclynx_write_object_contents) (bfd *);
42ef282f 42
252b5132
RH
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
7b82c249 46 probably no longer reject a NewsOS object. <ian@cygnus.com>. */
2c3fc389 47#define MACHTYPE_OK(mtype) ( (mtype) == M_UNKNOWN \
252b5132
RH
48 || (mtype) == M_68010 \
49 || (mtype) == M_68020 \
50 || (mtype) == M_SPARC)
51
42ef282f
NC
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.
60
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.
65
66 @item TARGETNAME
67 The name put into the target vector.
68 @item
69 @end table */
252b5132
RH
70
71void
2c3fc389 72NAME(lynx,set_arch_mach) (bfd *abfd, unsigned long machtype)
252b5132
RH
73{
74 /* Determine the architecture and machine type of the object file. */
75 enum bfd_architecture arch;
dc810e39 76 unsigned long machine;
42ef282f 77
252b5132
RH
78 switch (machtype)
79 {
252b5132
RH
80 case M_UNKNOWN:
81 /* Some Sun3s make magic numbers without cpu types in them, so
7b82c249 82 we'll default to the 68000. */
252b5132
RH
83 arch = bfd_arch_m68k;
84 machine = bfd_mach_m68000;
85 break;
86
87 case M_68010:
88 case M_HP200:
89 arch = bfd_arch_m68k;
90 machine = bfd_mach_m68010;
91 break;
92
93 case M_68020:
94 case M_HP300:
95 arch = bfd_arch_m68k;
96 machine = bfd_mach_m68020;
97 break;
98
99 case M_SPARC:
100 arch = bfd_arch_sparc;
101 machine = 0;
102 break;
103
104 case M_386:
105 case M_386_DYNIX:
106 arch = bfd_arch_i386;
107 machine = 0;
108 break;
109
252b5132
RH
110 case M_HPUX:
111 arch = bfd_arch_m68k;
112 machine = 0;
113 break;
114
115 default:
116 arch = bfd_arch_obscure;
117 machine = 0;
118 break;
119 }
120 bfd_set_arch_mach (abfd, arch, machine);
121}
122
bbb1afc8
AM
123#define SET_ARCH_MACH(ABFD, EXECP) \
124 NAME(lynx,set_arch_mach) (ABFD, N_MACHTYPE (EXECP)); \
252b5132
RH
125 choose_reloc_size(ABFD);
126
42ef282f
NC
127/* Determine the size of a relocation entry, based on the architecture. */
128
252b5132 129static void
2c3fc389 130choose_reloc_size (bfd *abfd)
252b5132
RH
131{
132 switch (bfd_get_arch (abfd))
133 {
134 case bfd_arch_sparc:
252b5132
RH
135 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
136 break;
137 default:
138 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
139 break;
140 }
141}
142
143/* Write an object file in LynxOS format.
144 Section contents have already been written. We write the
145 file header, symbols, and relocation. */
146
b34976b6 147static bfd_boolean
2c3fc389 148NAME(aout,sparclynx_write_object_contents) (bfd *abfd)
252b5132
RH
149{
150 struct external_exec exec_bytes;
151 struct internal_exec *execp = exec_hdr (abfd);
152
153 /* Magic number, maestro, please! */
154 switch (bfd_get_arch (abfd))
155 {
156 case bfd_arch_m68k:
157 switch (bfd_get_mach (abfd))
158 {
159 case bfd_mach_m68010:
bbb1afc8 160 N_SET_MACHTYPE (execp, M_68010);
252b5132
RH
161 break;
162 default:
163 case bfd_mach_m68020:
bbb1afc8 164 N_SET_MACHTYPE (execp, M_68020);
252b5132
RH
165 break;
166 }
167 break;
168 case bfd_arch_sparc:
bbb1afc8 169 N_SET_MACHTYPE (execp, M_SPARC);
252b5132
RH
170 break;
171 case bfd_arch_i386:
bbb1afc8 172 N_SET_MACHTYPE (execp, M_386);
252b5132 173 break;
252b5132 174 default:
bbb1afc8 175 N_SET_MACHTYPE (execp, M_UNKNOWN);
252b5132
RH
176 }
177
178 choose_reloc_size (abfd);
179
bbb1afc8 180 N_SET_FLAGS (execp, aout_backend_info (abfd)->exec_hdr_flags);
252b5132
RH
181
182 WRITE_HEADERS (abfd, execp);
183
b34976b6 184 return TRUE;
252b5132
RH
185}
186
187#define MY_set_sizes sparclynx_set_sizes
2c3fc389 188static bfd_boolean sparclynx_set_sizes (bfd *);
42ef282f 189
b34976b6 190static bfd_boolean
2c3fc389 191sparclynx_set_sizes (bfd *abfd)
252b5132
RH
192{
193 switch (bfd_get_arch (abfd))
194 {
195 default:
b34976b6 196 return FALSE;
252b5132
RH
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;
b34976b6 201 return TRUE;
252b5132
RH
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;
b34976b6 206 return TRUE;
252b5132
RH
207 }
208}
209
dc810e39 210static const struct aout_backend_data sparclynx_aout_backend =
42ef282f
NC
211 {
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 */
219 };
252b5132
RH
220\f
221
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 \
2c3fc389 225 (void (*) (bfd *, struct bfd_section *)) bfd_void
252b5132
RH
226
227#define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
228#define MY_backend_data &sparclynx_aout_backend
229
230#define TARGET_IS_BIG_ENDIAN_P
231
232#ifdef LYNX_CORE
233
b34976b6
AM
234char * lynx_core_file_failing_command ();
235int lynx_core_file_failing_signal ();
236bfd_boolean lynx_core_file_matches_executable_p ();
42ef282f 237const bfd_target * lynx_core_file_p ();
252b5132
RH
238
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
243
244#endif /* LYNX_CORE */
245
246#include "aout-target.h"
This page took 1.043079 seconds and 4 git commands to generate.