* ecoff.c: First cut at new style of linker backend for
[deliverable/binutils-gdb.git] / bfd / aoutf1.h
CommitLineData
250351fc 1/* A.out "format 1" file handling code for BFD.
4c3721d5 2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3c8a3c56 3 Written by Cygnus Support.
7ed4093a 4
3c8a3c56 5This file is part of BFD, the Binary File Descriptor library.
7ed4093a 6
3c8a3c56 7This program is free software; you can redistribute it and/or modify
7ed4093a 8it under the terms of the GNU General Public License as published by
3c8a3c56
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
7ed4093a 11
3c8a3c56 12This program is distributed in the hope that it will be useful,
7ed4093a
SC
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
3c8a3c56
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
6f715d66 20
7ed4093a 21#include "bfd.h"
bbc8d484 22#include "sysdep.h"
7ed4093a
SC
23#include "libbfd.h"
24
c3eb25fc
SC
25#include "aout/sun4.h"
26#include "libaout.h" /* BFD a.out internal data structures */
bbc8d484 27
c3eb25fc
SC
28#include "aout/aout64.h"
29#include "aout/stab_gnu.h"
30#include "aout/ar.h"
7ed4093a 31
a40fe908 32/* This is needed to reject a NewsOS file, e.g. in
4c3721d5
ILT
33 gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
34 I needed to add M_UNKNOWN to recognize a 68000 object, so this will
35 probably no longer reject a NewsOS object. <ian@cygnus.com>. */
36#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
37 || (mtype) == M_68010 \
38 || (mtype) == M_68020 \
a40fe908
JK
39 || (mtype) == M_SPARC)
40
6f715d66 41/*
6f715d66
SC
42The file @code{aoutf1.h} contains the code for BFD's
43a.out back end. Control over the generated back end is given by these
4f8b8627 44two preprocessor names:
6f715d66 45@table @code
4f8b8627 46@item ARCH_SIZE
6f715d66
SC
47This value should be either 32 or 64, depending upon the size of an
48int in the target format. It changes the sizes of the structs which
49perform the memory/disk mapping of structures.
50
51The 64 bit backend may only be used if the host compiler supports 64
4f8b8627
JG
52ints (eg long long with gcc), by defining the name @code{HOST_64_BIT} in @code{bfd.h}.
53With this name defined, @emph{all} bfd operations are performed with 64bit
6f715d66
SC
54arithmetic, not just those to a 64bit target.
55
56@item TARGETNAME
4f8b8627 57The name put into the target vector.
6f715d66 58@item
4f8b8627 59@end table
6f715d66
SC
60
61*/
7ed4093a 62
7ed4093a
SC
63/*SUPPRESS558*/
64/*SUPPRESS529*/
65
214f8f23
KR
66void
67DEFUN(NAME(sunos,set_arch_mach), (abfd, machtype),
68 bfd *abfd AND int machtype)
7ed4093a 69{
214f8f23 70 /* Determine the architecture and machine type of the object file. */
9e2dad8e
JG
71 enum bfd_architecture arch;
72 long machine;
214f8f23 73 switch (machtype) {
9e2dad8e 74
7ed4093a 75 case M_UNKNOWN:
c3eb25fc 76 /* Some Sun3s make magic numbers without cpu types in them, so
4c3721d5 77 we'll default to the 68000. */
c3eb25fc 78 arch = bfd_arch_m68k;
4c3721d5 79 machine = 68000;
7ed4093a
SC
80 break;
81
82 case M_68010:
522e0ead 83 case M_HP200:
9e2dad8e
JG
84 arch = bfd_arch_m68k;
85 machine = 68010;
7ed4093a
SC
86 break;
87
88 case M_68020:
522e0ead 89 case M_HP300:
9e2dad8e
JG
90 arch = bfd_arch_m68k;
91 machine = 68020;
7ed4093a
SC
92 break;
93
94 case M_SPARC:
9e2dad8e
JG
95 arch = bfd_arch_sparc;
96 machine = 0;
7ed4093a
SC
97 break;
98
99 case M_386:
4c3721d5 100 case M_386_DYNIX:
9e2dad8e
JG
101 arch = bfd_arch_i386;
102 machine = 0;
7ed4093a
SC
103 break;
104
105 case M_29K:
9e2dad8e
JG
106 arch = bfd_arch_a29k;
107 machine = 0;
7ed4093a
SC
108 break;
109
522e0ead
SC
110 case M_HPUX:
111 arch = bfd_arch_m68k;
112 machine = 0;
113 break;
114
7ed4093a 115 default:
9e2dad8e
JG
116 arch = bfd_arch_obscure;
117 machine = 0;
7ed4093a
SC
118 break;
119 }
9e2dad8e 120 bfd_set_arch_mach(abfd, arch, machine);
7ed4093a
SC
121}
122
214f8f23
KR
123#define SET_ARCH_MACH(ABFD, EXEC) \
124 NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
125 choose_reloc_size(ABFD);
126
127/* Determine the size of a relocation entry, based on the architecture */
128static void
129DEFUN(choose_reloc_size,(abfd),
130bfd *abfd)
131{
132 switch (bfd_get_arch(abfd)) {
133 case bfd_arch_sparc:
134 case bfd_arch_a29k:
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}
7ed4093a
SC
142
143/* Write an object file in SunOS format.
9e2dad8e
JG
144 Section contents have already been written. We write the
145 file header, symbols, and relocation. */
7ed4093a 146
c3eb25fc 147static boolean
9e2dad8e
JG
148DEFUN(NAME(aout,sunos4_write_object_contents),
149 (abfd),
7ed4093a 150 bfd *abfd)
9e2dad8e 151{
9e2dad8e
JG
152 struct external_exec exec_bytes;
153 struct internal_exec *execp = exec_hdr (abfd);
7ed4093a 154
9e2dad8e
JG
155 /* Magic number, maestro, please! */
156 switch (bfd_get_arch(abfd)) {
157 case bfd_arch_m68k:
158 switch (bfd_get_mach(abfd)) {
159 case 68010:
160 N_SET_MACHTYPE(*execp, M_68010);
7ed4093a
SC
161 break;
162 default:
9e2dad8e
JG
163 case 68020:
164 N_SET_MACHTYPE(*execp, M_68020);
165 break;
7ed4093a 166 }
9e2dad8e
JG
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 case bfd_arch_a29k:
175 N_SET_MACHTYPE(*execp, M_29K);
176 break;
177 default:
178 N_SET_MACHTYPE(*execp, M_UNKNOWN);
179 }
7ed4093a 180
9e2dad8e 181 choose_reloc_size(abfd);
250351fc 182
a40fe908 183#if 0
250351fc
JK
184 /* Some tools want this to be 0, some tools want this to be one.
185 Today, it seems that 0 is the most important setting (PR1927) */
186 N_SET_FLAGS (*execp, 0x0);
a40fe908
JK
187#else
188
189 /* Fri Jun 11 14:23:31 PDT 1993
190 FIXME
191 Today's optimal setting is 1. This is a pain, since it
192 reopens 1927. This should be readdressed by creating a new
193 target for each each supported, giving perhaps sun3/m68k
194 and sun4/sparc a.out formats.
195 */
196 N_SET_FLAGS (*execp, 1);
197#endif
9e2dad8e
JG
198
199 WRITE_HEADERS(abfd, execp);
214f8f23 200
7ed4093a
SC
201 return true;
202}
203\f
204/* core files */
205
206#define CORE_MAGIC 0x080456
207#define CORE_NAMELEN 16
208
209/* The core structure is taken from the Sun documentation.
9e2dad8e
JG
210 Unfortunately, they don't document the FPA structure, or at least I
211 can't find it easily. Fortunately the core header contains its own
212 length. So this shouldn't cause problems, except for c_ucode, which
213 so far we don't use but is easy to find with a little arithmetic. */
7ed4093a
SC
214
215/* But the reg structure can be gotten from the SPARC processor handbook.
9e2dad8e
JG
216 This really should be in a GNU include file though so that gdb can use
217 the same info. */
7ed4093a
SC
218struct regs {
219 int r_psr;
220 int r_pc;
221 int r_npc;
222 int r_y;
223 int r_g1;
224 int r_g2;
225 int r_g3;
226 int r_g4;
227 int r_g5;
228 int r_g6;
229 int r_g7;
230 int r_o0;
231 int r_o1;
232 int r_o2;
233 int r_o3;
234 int r_o4;
235 int r_o5;
236 int r_o6;
237 int r_o7;
238};
239
240/* Taken from Sun documentation: */
241
242/* FIXME: It's worse than we expect. This struct contains TWO substructs
9e2dad8e
JG
243 neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
244 even portably access the stuff in between! */
7ed4093a 245
4f8b8627 246struct external_sparc_core {
7ed4093a
SC
247 int c_magic; /* Corefile magic number */
248 int c_len; /* Sizeof (struct core) */
4f8b8627
JG
249#define SPARC_CORE_LEN 432
250 int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
9e2dad8e
JG
251 struct external_exec c_aouthdr; /* A.out header */
252 int c_signo; /* Killing signal, if any */
253 int c_tsize; /* Text size (bytes) */
254 int c_dsize; /* Data size (bytes) */
255 int c_ssize; /* Stack size (bytes) */
7ed4093a
SC
256 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
257 double fp_stuff[1]; /* external FPU state (size unknown by us) */
258 /* The type "double" is critical here, for alignment.
259 SunOS declares a struct here, but the struct's alignment
260 is double since it contains doubles. */
261 int c_ucode; /* Exception no. from u_code */
262 /* (this member is not accessible by name since we don't
263 portably know the size of fp_stuff.) */
264};
265
4f8b8627
JG
266struct external_sun3_core {
267 int c_magic; /* Corefile magic number */
268 int c_len; /* Sizeof (struct core) */
269#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
270 int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
271 struct external_exec c_aouthdr; /* A.out header */
272 int c_signo; /* Killing signal, if any */
273 int c_tsize; /* Text size (bytes) */
274 int c_dsize; /* Data size (bytes) */
275 int c_ssize; /* Stack size (bytes) */
276 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
277 double fp_stuff[1]; /* external FPU state (size unknown by us) */
278 /* The type "double" is critical here, for alignment.
279 SunOS declares a struct here, but the struct's alignment
280 is double since it contains doubles. */
281 int c_ucode; /* Exception no. from u_code */
282 /* (this member is not accessible by name since we don't
283 portably know the size of fp_stuff.) */
284};
285
286struct internal_sunos_core {
287 int c_magic; /* Corefile magic number */
288 int c_len; /* Sizeof (struct core) */
289 long c_regs_pos; /* file offset of General purpose registers */
290 int c_regs_size; /* size of General purpose registers */
9e2dad8e
JG
291 struct internal_exec c_aouthdr; /* A.out header */
292 int c_signo; /* Killing signal, if any */
293 int c_tsize; /* Text size (bytes) */
294 int c_dsize; /* Data size (bytes) */
295 int c_ssize; /* Stack size (bytes) */
250351fc 296 bfd_vma c_stacktop; /* Stack top (address) */
4f8b8627
JG
297 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
298 long fp_stuff_pos; /* file offset of external FPU state (regs) */
299 int fp_stuff_size; /* Size of it */
300 int c_ucode; /* Exception no. from u_code */
301};
7ed4093a 302
4f8b8627
JG
303/* byte-swap in the Sun-3 core structure */
304static void
305DEFUN(swapcore_sun3,(abfd, ext, intcore),
306 bfd *abfd AND
12e7087f 307 char *ext AND
4f8b8627
JG
308 struct internal_sunos_core *intcore)
309{
4f8b8627 310 struct external_sun3_core *extcore = (struct external_sun3_core *)ext;
9e2dad8e 311
4f8b8627
JG
312 intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);
313 intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len );
314 intcore->c_regs_pos = (long) (((struct external_sun3_core *)0)->c_regs);
315 intcore->c_regs_size = sizeof (extcore->c_regs);
316 NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr);
317 intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo);
318 intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize);
319 intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize);
320 intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize);
214f8f23 321 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
4f8b8627
JG
322 intcore->fp_stuff_pos = (long) (((struct external_sun3_core *)0)->fp_stuff);
323 /* FP stuff takes up whole rest of struct, except c_ucode. */
324 intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
325 (file_ptr)(((struct external_sun3_core *)0)->fp_stuff);
326 /* Ucode is the last thing in the struct -- just before the end */
9e2dad8e
JG
327 intcore->c_ucode =
328 bfd_h_get_32 (abfd,
329 intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore);
330 intcore->c_stacktop = 0x0E000000; /* By experimentation */
4f8b8627
JG
331}
332
333
fb3be09b 334/* byte-swap in the Sparc core structure */
4f8b8627
JG
335static void
336DEFUN(swapcore_sparc,(abfd, ext, intcore),
337 bfd *abfd AND
12e7087f 338 char *ext AND
4f8b8627
JG
339 struct internal_sunos_core *intcore)
340{
341 struct external_sparc_core *extcore = (struct external_sparc_core *)ext;
342
343 intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic);
344 intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len );
345 intcore->c_regs_pos = (long) (((struct external_sparc_core *)0)->c_regs);
346 intcore->c_regs_size = sizeof (extcore->c_regs);
347 NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr);
348 intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo);
349 intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize);
350 intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize);
351 intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize);
214f8f23 352 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
4f8b8627
JG
353 intcore->fp_stuff_pos = (long) (((struct external_sparc_core *)0)->fp_stuff);
354 /* FP stuff takes up whole rest of struct, except c_ucode. */
355 intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
356 (file_ptr)(((struct external_sparc_core *)0)->fp_stuff);
357 /* Ucode is the last thing in the struct -- just before the end */
9e2dad8e
JG
358 intcore->c_ucode =
359 bfd_h_get_32 (abfd,
360 intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore);
250351fc 361
4f8b8627 362 /* Supposedly the user stack grows downward from the bottom of kernel memory.
250351fc
JK
363 Presuming that this remains true, this definition will work. */
364 /* Now sun has provided us with another challenge. The value is different
365 for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
366 the other based on the current value of the stack pointer. This
367 loses (a) if the stack pointer has been clobbered, or (b) if the stack
368 is larger than 128 megabytes.
369
370 It's times like these you're glad they're switching to ELF.
371
372 Note that using include files or nlist on /vmunix would be wrong,
373 because we want the value for this core file, no matter what kind of
374 machine we were compiled on or are running on. */
375#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
376#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
377 {
378 bfd_vma sp = bfd_h_get_32
379 (abfd, (unsigned char *)&((struct regs *)&extcore->c_regs[0])->r_o6);
380 if (sp < SPARC_USRSTACK_SPARC10)
381 intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
382 else
383 intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
384 }
4f8b8627 385}
7ed4093a 386
4f8b8627 387/* need this cast because ptr is really void * */
214f8f23
KR
388#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
389#define core_datasec(bfd) (core_hdr(bfd)->data_section)
390#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
391#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
392#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
7ed4093a
SC
393
394/* These are stored in the bfd's tdata */
214f8f23 395struct sun_core_struct {
4f8b8627
JG
396 struct internal_sunos_core *hdr; /* core file header */
397 asection *data_section;
398 asection *stack_section;
399 asection *reg_section;
400 asection *reg2_section;
7ed4093a
SC
401};
402
403static bfd_target *
404DEFUN(sunos4_core_file_p,(abfd),
405 bfd *abfd)
406{
407 unsigned char longbuf[4]; /* Raw bytes of various header fields */
408 int core_size;
409 int core_mag;
4f8b8627
JG
410 struct internal_sunos_core *core;
411 char *extcore;
4f8b8627 412 struct mergem {
214f8f23 413 struct sun_core_struct suncoredata;
4f8b8627
JG
414 struct internal_sunos_core internal_sunos_core;
415 char external_core[1];
416 } *mergem;
7ed4093a 417
7ed4093a
SC
418 if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) !=
419 sizeof (longbuf))
420 return 0;
421 core_mag = bfd_h_get_32 (abfd, longbuf);
422
423 if (core_mag != CORE_MAGIC) return 0;
424
425 /* SunOS core headers can vary in length; second word is size; */
426 if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) !=
427 sizeof (longbuf))
428 return 0;
429 core_size = bfd_h_get_32 (abfd, longbuf);
430 /* Sanity check */
431 if (core_size > 20000)
432 return 0;
433
f8e01940 434 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0) return 0;
7ed4093a 435
4f8b8627
JG
436 mergem = (struct mergem *)bfd_zalloc (abfd, core_size + sizeof (struct mergem));
437 if (mergem == NULL) {
7ed4093a
SC
438 bfd_error = no_memory;
439 return 0;
440 }
441
4f8b8627 442 extcore = mergem->external_core;
7ed4093a 443
4f8b8627 444 if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size) {
7ed4093a 445 bfd_error = system_call_error;
4f8b8627
JG
446 bfd_release (abfd, (char *)mergem);
447 return 0;
448 }
449
450 /* Validate that it's a core file we know how to handle, due to sun
451 botching the positioning of registers and other fields in a machine
452 dependent way. */
453 core = &mergem->internal_sunos_core;
454 switch (core_size) {
455 case SPARC_CORE_LEN:
456 swapcore_sparc (abfd, extcore, core);
457 break;
458 case SUN3_CORE_LEN:
459 swapcore_sun3 (abfd, extcore, core);
460 break;
461 default:
462 bfd_error = system_call_error; /* FIXME */
463 bfd_release (abfd, (char *)mergem);
7ed4093a
SC
464 return 0;
465 }
466
214f8f23
KR
467 abfd->tdata.sun_core_data = &mergem->suncoredata;
468 abfd->tdata.sun_core_data->hdr = core;
7ed4093a
SC
469
470 /* create the sections. This is raunchy, but bfd_close wants to reclaim
471 them */
472 core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
473 if (core_stacksec (abfd) == NULL) {
474 loser:
475 bfd_error = no_memory;
fb3be09b 476 bfd_release (abfd, (char *)mergem);
7ed4093a
SC
477 return 0;
478 }
479 core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
480 if (core_datasec (abfd) == NULL) {
481 loser1:
482 bfd_release (abfd, core_stacksec (abfd));
483 goto loser;
484 }
485 core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
486 if (core_regsec (abfd) == NULL) {
487 loser2:
488 bfd_release (abfd, core_datasec (abfd));
489 goto loser1;
490 }
491 core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
492 if (core_reg2sec (abfd) == NULL) {
493 bfd_release (abfd, core_regsec (abfd));
494 goto loser2;
495 }
496
497 core_stacksec (abfd)->name = ".stack";
498 core_datasec (abfd)->name = ".data";
499 core_regsec (abfd)->name = ".reg";
500 core_reg2sec (abfd)->name = ".reg2";
501
12e7087f
JG
502 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
503 core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
504 core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
505 core_reg2sec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
7ed4093a 506
214f8f23
KR
507 core_stacksec (abfd)->_raw_size = core->c_ssize;
508 core_datasec (abfd)->_raw_size = core->c_dsize;
509 core_regsec (abfd)->_raw_size = core->c_regs_size;
510 core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
7ed4093a 511
4f8b8627 512 core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
7ed4093a 513 core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr);
522e0ead
SC
514 core_regsec (abfd)->vma = 0;
515 core_reg2sec (abfd)->vma = 0;
7ed4093a
SC
516
517 core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
518 core_datasec (abfd)->filepos = core->c_len;
4f8b8627
JG
519 /* We'll access the regs afresh in the core file, like any section: */
520 core_regsec (abfd)->filepos = (file_ptr)core->c_regs_pos;
521 core_reg2sec (abfd)->filepos = (file_ptr)core->fp_stuff_pos;
7ed4093a
SC
522
523 /* Align to word at least */
524 core_stacksec (abfd)->alignment_power = 2;
525 core_datasec (abfd)->alignment_power = 2;
526 core_regsec (abfd)->alignment_power = 2;
527 core_reg2sec (abfd)->alignment_power = 2;
528
529 abfd->sections = core_stacksec (abfd);
530 core_stacksec (abfd)->next = core_datasec (abfd);
531 core_datasec (abfd)->next = core_regsec (abfd);
532 core_regsec (abfd)->next = core_reg2sec (abfd);
533
534 abfd->section_count = 4;
535
536 return abfd->xvec;
537}
538
539static char *sunos4_core_file_failing_command (abfd)
540bfd *abfd;
541 {
214f8f23 542 return core_hdr (abfd)->hdr->c_cmdname;
7ed4093a
SC
543}
544
545static int
546DEFUN(sunos4_core_file_failing_signal,(abfd),
547 bfd *abfd)
548{
214f8f23 549 return core_hdr (abfd)->hdr->c_signo;
7ed4093a
SC
550}
551
552static boolean
553DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd),
554 bfd *core_bfd AND
555 bfd *exec_bfd)
556{
557 if (core_bfd->xvec != exec_bfd->xvec) {
558 bfd_error = system_call_error;
559 return false;
560 }
561
214f8f23
KR
562 return (memcmp ((char *)&((core_hdr (core_bfd)->hdr)->c_aouthdr),
563 (char *) exec_hdr (exec_bfd),
564 sizeof (struct internal_exec)) == 0) ? true : false;
565}
566
250351fc 567#define MY_set_sizes sunos4_set_sizes
214f8f23
KR
568static boolean
569DEFUN (sunos4_set_sizes, (abfd),
570 bfd *abfd)
571{
572 switch (bfd_get_arch (abfd))
573 {
574 default:
575 return false;
576 case bfd_arch_sparc:
577 adata(abfd).page_size = 0x2000;
578 adata(abfd).segment_size = 0x2000;
579 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
580 return true;
581 case bfd_arch_m68k:
582 adata(abfd).page_size = 0x2000;
583 adata(abfd).segment_size = 0x20000;
584 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
585 return true;
586 }
587}
588
589static CONST struct aout_backend_data sunos4_aout_backend = {
7f90aa8b 590 0, 1, 0, sunos4_set_sizes, 0,
214f8f23 591};
7ed4093a 592\f
c3eb25fc
SC
593#define MY_core_file_failing_command sunos4_core_file_failing_command
594#define MY_core_file_failing_signal sunos4_core_file_failing_signal
595#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
6f715d66 596
c3eb25fc
SC
597#define MY_bfd_debug_info_start bfd_void
598#define MY_bfd_debug_info_end bfd_void
250351fc
JK
599#define MY_bfd_debug_info_accumulate \
600 (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
601#define MY_core_file_p sunos4_core_file_p
602#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
214f8f23 603#define MY_backend_data &sunos4_aout_backend
6f715d66 604
c3eb25fc 605#define TARGET_IS_BIG_ENDIAN_P
6f715d66 606
c3eb25fc 607#include "aout-target.h"
This page took 0.114172 seconds and 4 git commands to generate.