1 /* A.out "format 1" file handling code for BFD.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
3 2001, 2002, 2003, 2004, 2005
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #include "aout/sun4.h"
28 #include "libaout.h" /* BFD a.out internal data structures. */
30 #include "aout/aout64.h"
31 #include "aout/stab_gnu.h"
34 /* This is needed to reject a NewsOS file, e.g. in
35 gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
36 I needed to add M_UNKNOWN to recognize a 68000 object, so this will
37 probably no longer reject a NewsOS object. <ian@cygnus.com>. */
39 #define MACHTYPE_OK(mtype) \
40 (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
41 || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
42 && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
45 /* The file @code{aoutf1.h} contains the code for BFD's
46 a.out back end. Control over the generated back end is given by these
47 two preprocessor names:
50 This value should be either 32 or 64, depending upon the size of an
51 int in the target format. It changes the sizes of the structs which
52 perform the memory/disk mapping of structures.
54 The 64 bit backend may only be used if the host compiler supports 64
55 ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
56 With this name defined, @emph{all} bfd operations are performed with 64bit
57 arithmetic, not just those to a 64bit target.
60 The name put into the target vector.
65 #define sunos_set_arch_mach sunos_64_set_arch_mach
66 #define sunos_write_object_contents aout_64_sunos4_write_object_contents
68 #define sunos_set_arch_mach sunos_32_set_arch_mach
69 #define sunos_write_object_contents aout_32_sunos4_write_object_contents
72 /* Merge backend data into the output file.
73 This is necessary on sparclet-aout where we want the resultant machine
74 number to be M_SPARCLET if any input file is M_SPARCLET. */
76 #define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
79 sunos_merge_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
81 if (bfd_get_flavour (ibfd
) != bfd_target_aout_flavour
82 || bfd_get_flavour (obfd
) != bfd_target_aout_flavour
)
85 if (bfd_get_arch (obfd
) == bfd_arch_sparc
)
87 if (bfd_get_mach (obfd
) < bfd_get_mach (ibfd
))
88 bfd_set_arch_mach (obfd
, bfd_arch_sparc
, bfd_get_mach (ibfd
));
94 /* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
95 depending upon ARCH_SIZE. */
98 sunos_set_arch_mach (bfd
*abfd
, enum machine_type machtype
)
100 /* Determine the architecture and machine type of the object file. */
101 enum bfd_architecture arch
;
102 unsigned long machine
;
107 /* Some Sun3s make magic numbers without cpu types in them, so
108 we'll default to the 68000. */
109 arch
= bfd_arch_m68k
;
110 machine
= bfd_mach_m68000
;
115 arch
= bfd_arch_m68k
;
116 machine
= bfd_mach_m68010
;
121 arch
= bfd_arch_m68k
;
122 machine
= bfd_mach_m68020
;
126 arch
= bfd_arch_sparc
;
131 arch
= bfd_arch_sparc
;
132 machine
= bfd_mach_sparc_sparclet
;
136 arch
= bfd_arch_sparc
;
137 machine
= bfd_mach_sparc_sparclite_le
;
142 arch
= bfd_arch_i386
;
147 arch
= bfd_arch_a29k
;
152 arch
= bfd_arch_m68k
;
157 arch
= bfd_arch_obscure
;
161 bfd_set_arch_mach (abfd
, arch
, machine
);
164 #define SET_ARCH_MACH(ABFD, EXEC) \
165 NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
166 choose_reloc_size(ABFD);
168 /* Determine the size of a relocation entry, based on the architecture. */
171 choose_reloc_size (bfd
*abfd
)
173 switch (bfd_get_arch (abfd
))
177 obj_reloc_entry_size (abfd
) = RELOC_EXT_SIZE
;
180 obj_reloc_entry_size (abfd
) = RELOC_STD_SIZE
;
185 /* Write an object file in SunOS format. Section contents have
186 already been written. We write the file header, symbols, and
187 relocation. The real name of this function is either
188 aout_64_sunos4_write_object_contents or
189 aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */
192 sunos_write_object_contents (bfd
*abfd
)
194 struct external_exec exec_bytes
;
195 struct internal_exec
*execp
= exec_hdr (abfd
);
197 /* Magic number, maestro, please! */
198 switch (bfd_get_arch (abfd
))
201 switch (bfd_get_mach (abfd
))
203 case bfd_mach_m68000
:
204 N_SET_MACHTYPE (*execp
, M_UNKNOWN
);
206 case bfd_mach_m68010
:
207 N_SET_MACHTYPE (*execp
, M_68010
);
210 case bfd_mach_m68020
:
211 N_SET_MACHTYPE (*execp
, M_68020
);
216 switch (bfd_get_mach (abfd
))
218 case bfd_mach_sparc_sparclet
:
219 N_SET_MACHTYPE (*execp
, M_SPARCLET
);
221 case bfd_mach_sparc_sparclite_le
:
222 N_SET_MACHTYPE (*execp
, M_SPARCLITE_LE
);
225 N_SET_MACHTYPE (*execp
, M_SPARC
);
230 N_SET_MACHTYPE (*execp
, M_386
);
233 N_SET_MACHTYPE (*execp
, M_29K
);
236 N_SET_MACHTYPE (*execp
, M_UNKNOWN
);
239 choose_reloc_size (abfd
);
241 N_SET_FLAGS (*execp
, aout_backend_info (abfd
)->exec_hdr_flags
);
243 N_SET_DYNAMIC (*execp
, (long)(bfd_get_file_flags (abfd
) & DYNAMIC
));
245 WRITE_HEADERS (abfd
, execp
);
252 #define CORE_MAGIC 0x080456
253 #define CORE_NAMELEN 16
255 /* The core structure is taken from the Sun documentation.
256 Unfortunately, they don't document the FPA structure, or at least I
257 can't find it easily. Fortunately the core header contains its own
258 length. So this shouldn't cause problems, except for c_ucode, which
259 so far we don't use but is easy to find with a little arithmetic. */
261 /* But the reg structure can be gotten from the SPARC processor handbook.
262 This really should be in a GNU include file though so that gdb can use
287 /* Taken from Sun documentation: */
289 /* FIXME: It's worse than we expect. This struct contains TWO substructs
290 neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
291 even portably access the stuff in between! */
293 struct external_sparc_core
295 int c_magic
; /* Corefile magic number. */
296 int c_len
; /* Sizeof (struct core). */
297 #define SPARC_CORE_LEN 432
298 int c_regs
[19]; /* General purpose registers -- MACHDEP SIZE. */
299 struct external_exec c_aouthdr
; /* A.out header. */
300 int c_signo
; /* Killing signal, if any. */
301 int c_tsize
; /* Text size (bytes). */
302 int c_dsize
; /* Data size (bytes). */
303 int c_ssize
; /* Stack size (bytes). */
304 char c_cmdname
[CORE_NAMELEN
+ 1]; /* Command name. */
305 double fp_stuff
[1]; /* External FPU state (size unknown by us). */
306 /* The type "double" is critical here, for alignment.
307 SunOS declares a struct here, but the struct's
308 alignment is double since it contains doubles. */
309 int c_ucode
; /* Exception no. from u_code. */
310 /* This member is not accessible by name since
311 we don't portably know the size of fp_stuff. */
314 /* Core files generated by the BCP (the part of Solaris which allows
315 it to run SunOS4 a.out files). */
316 struct external_solaris_bcp_core
318 int c_magic
; /* Corefile magic number. */
319 int c_len
; /* Sizeof (struct core). */
320 #define SOLARIS_BCP_CORE_LEN 456
321 int c_regs
[19]; /* General purpose registers -- MACHDEP SIZE. */
322 int c_exdata_vp
; /* Exdata structure. */
327 int c_exdata_nshlibs
;
330 int c_exdata_toffset
;
331 int c_exdata_doffset
;
332 int c_exdata_loffset
;
336 int c_signo
; /* Killing signal, if any. */
337 int c_tsize
; /* Text size (bytes). */
338 int c_dsize
; /* Data size (bytes). */
339 int c_ssize
; /* Stack size (bytes). */
340 char c_cmdname
[CORE_NAMELEN
+ 1]; /* Command name. */
341 double fp_stuff
[1]; /* External FPU state (size unknown by us). */
342 /* The type "double" is critical here, for alignment.
343 SunOS declares a struct here, but the struct's
344 alignment is double since it contains doubles. */
345 int c_ucode
; /* Exception no. from u_code. */
346 /* This member is not accessible by name since
347 we don't portably know the size of fp_stuff. */
350 struct external_sun3_core
352 int c_magic
; /* Corefile magic number. */
353 int c_len
; /* Sizeof (struct core). */
354 #define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1. */
355 int c_regs
[18]; /* General purpose registers -- MACHDEP SIZE. */
356 struct external_exec c_aouthdr
; /* A.out header. */
357 int c_signo
; /* Killing signal, if any. */
358 int c_tsize
; /* Text size (bytes). */
359 int c_dsize
; /* Data size (bytes). */
360 int c_ssize
; /* Stack size (bytes). */
361 char c_cmdname
[CORE_NAMELEN
+ 1]; /* Command name. */
362 double fp_stuff
[1]; /* External FPU state (size unknown by us). */
363 /* The type "double" is critical here, for alignment.
364 SunOS declares a struct here, but the struct's
365 alignment is double since it contains doubles. */
366 int c_ucode
; /* Exception no. from u_code. */
367 /* This member is not accessible by name since
368 we don't portably know the size of fp_stuff. */
371 struct internal_sunos_core
373 int c_magic
; /* Corefile magic number. */
374 int c_len
; /* Sizeof (struct core). */
375 long c_regs_pos
; /* File offset of General purpose registers. */
376 int c_regs_size
; /* Size of General purpose registers. */
377 struct internal_exec c_aouthdr
; /* A.out header. */
378 int c_signo
; /* Killing signal, if any. */
379 int c_tsize
; /* Text size (bytes). */
380 int c_dsize
; /* Data size (bytes). */
381 bfd_vma c_data_addr
; /* Data start (address). */
382 int c_ssize
; /* Stack size (bytes). */
383 bfd_vma c_stacktop
; /* Stack top (address). */
384 char c_cmdname
[CORE_NAMELEN
+ 1]; /* Command name. */
385 long fp_stuff_pos
; /* File offset of external FPU state (regs). */
386 int fp_stuff_size
; /* Size of it. */
387 int c_ucode
; /* Exception no. from u_code. */
390 /* Byte-swap in the Sun-3 core structure. */
393 swapcore_sun3 (bfd
*abfd
, char *ext
, struct internal_sunos_core
*intcore
)
395 struct external_sun3_core
*extcore
= (struct external_sun3_core
*) ext
;
397 intcore
->c_magic
= H_GET_32 (abfd
, &extcore
->c_magic
);
398 intcore
->c_len
= H_GET_32 (abfd
, &extcore
->c_len
);
399 intcore
->c_regs_pos
= (long) (((struct external_sun3_core
*) 0)->c_regs
);
400 intcore
->c_regs_size
= sizeof (extcore
->c_regs
);
402 aout_64_swap_exec_header_in
404 aout_32_swap_exec_header_in
406 (abfd
, &extcore
->c_aouthdr
, &intcore
->c_aouthdr
);
407 intcore
->c_signo
= H_GET_32 (abfd
, &extcore
->c_signo
);
408 intcore
->c_tsize
= H_GET_32 (abfd
, &extcore
->c_tsize
);
409 intcore
->c_dsize
= H_GET_32 (abfd
, &extcore
->c_dsize
);
410 intcore
->c_data_addr
= N_DATADDR (intcore
->c_aouthdr
);
411 intcore
->c_ssize
= H_GET_32 (abfd
, &extcore
->c_ssize
);
412 memcpy (intcore
->c_cmdname
, extcore
->c_cmdname
, sizeof (intcore
->c_cmdname
));
413 intcore
->fp_stuff_pos
= (long) (((struct external_sun3_core
*) 0)->fp_stuff
);
414 /* FP stuff takes up whole rest of struct, except c_ucode. */
415 intcore
->fp_stuff_size
= intcore
->c_len
- (sizeof extcore
->c_ucode
) -
416 (file_ptr
) (((struct external_sun3_core
*) 0)->fp_stuff
);
417 /* Ucode is the last thing in the struct -- just before the end. */
418 intcore
->c_ucode
= H_GET_32 (abfd
,
420 - sizeof (extcore
->c_ucode
)
421 + (unsigned char *) extcore
));
422 intcore
->c_stacktop
= 0x0E000000; /* By experimentation. */
425 /* Byte-swap in the Sparc core structure. */
428 swapcore_sparc (bfd
*abfd
, char *ext
, struct internal_sunos_core
*intcore
)
430 struct external_sparc_core
*extcore
= (struct external_sparc_core
*) ext
;
432 intcore
->c_magic
= H_GET_32 (abfd
, &extcore
->c_magic
);
433 intcore
->c_len
= H_GET_32 (abfd
, &extcore
->c_len
);
434 intcore
->c_regs_pos
= (long) (((struct external_sparc_core
*) 0)->c_regs
);
435 intcore
->c_regs_size
= sizeof (extcore
->c_regs
);
437 aout_64_swap_exec_header_in
439 aout_32_swap_exec_header_in
441 (abfd
, &extcore
->c_aouthdr
, &intcore
->c_aouthdr
);
442 intcore
->c_signo
= H_GET_32 (abfd
, &extcore
->c_signo
);
443 intcore
->c_tsize
= H_GET_32 (abfd
, &extcore
->c_tsize
);
444 intcore
->c_dsize
= H_GET_32 (abfd
, &extcore
->c_dsize
);
445 intcore
->c_data_addr
= N_DATADDR (intcore
->c_aouthdr
);
446 intcore
->c_ssize
= H_GET_32 (abfd
, &extcore
->c_ssize
);
447 memcpy (intcore
->c_cmdname
, extcore
->c_cmdname
, sizeof (intcore
->c_cmdname
));
448 intcore
->fp_stuff_pos
= (long) (((struct external_sparc_core
*) 0)->fp_stuff
);
449 /* FP stuff takes up whole rest of struct, except c_ucode. */
450 intcore
->fp_stuff_size
= intcore
->c_len
- (sizeof extcore
->c_ucode
) -
451 (file_ptr
) (((struct external_sparc_core
*) 0)->fp_stuff
);
452 /* Ucode is the last thing in the struct -- just before the end. */
453 intcore
->c_ucode
= H_GET_32 (abfd
,
455 - sizeof (extcore
->c_ucode
)
456 + (unsigned char *) extcore
));
458 /* Supposedly the user stack grows downward from the bottom of kernel memory.
459 Presuming that this remains true, this definition will work. */
460 /* Now sun has provided us with another challenge. The value is different
461 for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
462 the other based on the current value of the stack pointer. This
463 loses (a) if the stack pointer has been clobbered, or (b) if the stack
464 is larger than 128 megabytes.
466 It's times like these you're glad they're switching to ELF.
468 Note that using include files or nlist on /vmunix would be wrong,
469 because we want the value for this core file, no matter what kind of
470 machine we were compiled on or are running on. */
471 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
472 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
474 bfd_vma sp
= H_GET_32 (abfd
, &((struct regs
*) &extcore
->c_regs
[0])->r_o6
);
475 if (sp
< SPARC_USRSTACK_SPARC10
)
476 intcore
->c_stacktop
= SPARC_USRSTACK_SPARC10
;
478 intcore
->c_stacktop
= SPARC_USRSTACK_SPARC2
;
482 /* Byte-swap in the Solaris BCP core structure. */
485 swapcore_solaris_bcp (bfd
*abfd
, char *ext
, struct internal_sunos_core
*intcore
)
487 struct external_solaris_bcp_core
*extcore
=
488 (struct external_solaris_bcp_core
*) ext
;
490 intcore
->c_magic
= H_GET_32 (abfd
, &extcore
->c_magic
);
491 intcore
->c_len
= H_GET_32 (abfd
, &extcore
->c_len
);
492 intcore
->c_regs_pos
= (long) (((struct external_solaris_bcp_core
*) 0)->c_regs
);
493 intcore
->c_regs_size
= sizeof (extcore
->c_regs
);
495 /* The Solaris BCP exdata structure does not contain an a_syms field,
496 so we are unable to synthesize an internal exec header.
497 Luckily we are able to figure out the start address of the data section,
498 which is the only thing needed from the internal exec header,
499 from the exdata structure.
501 As of Solaris 2.3, BCP core files for statically linked executables
502 are buggy. The exdata structure is not properly filled in, and
503 the data section is written from address zero instead of the data
505 memset ((void *) &intcore
->c_aouthdr
, 0, sizeof (struct internal_exec
));
506 intcore
->c_data_addr
= H_GET_32 (abfd
, &extcore
->c_exdata_datorg
);
507 intcore
->c_signo
= H_GET_32 (abfd
, &extcore
->c_signo
);
508 intcore
->c_tsize
= H_GET_32 (abfd
, &extcore
->c_tsize
);
509 intcore
->c_dsize
= H_GET_32 (abfd
, &extcore
->c_dsize
);
510 intcore
->c_ssize
= H_GET_32 (abfd
, &extcore
->c_ssize
);
511 memcpy (intcore
->c_cmdname
, extcore
->c_cmdname
, sizeof (intcore
->c_cmdname
));
512 intcore
->fp_stuff_pos
=
513 (long) (((struct external_solaris_bcp_core
*) 0)->fp_stuff
);
514 /* FP stuff takes up whole rest of struct, except c_ucode. */
515 intcore
->fp_stuff_size
= intcore
->c_len
- (sizeof extcore
->c_ucode
) -
516 (file_ptr
) (((struct external_solaris_bcp_core
*) 0)->fp_stuff
);
517 /* Ucode is the last thing in the struct -- just before the end */
518 intcore
->c_ucode
= H_GET_32 (abfd
,
520 - sizeof (extcore
->c_ucode
)
521 + (unsigned char *) extcore
));
523 /* Supposedly the user stack grows downward from the bottom of kernel memory.
524 Presuming that this remains true, this definition will work. */
525 /* Now sun has provided us with another challenge. The value is different
526 for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
527 the other based on the current value of the stack pointer. This
528 loses (a) if the stack pointer has been clobbered, or (b) if the stack
529 is larger than 128 megabytes.
531 It's times like these you're glad they're switching to ELF.
533 Note that using include files or nlist on /vmunix would be wrong,
534 because we want the value for this core file, no matter what kind of
535 machine we were compiled on or are running on. */
536 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
537 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
539 bfd_vma sp
= H_GET_32 (abfd
, &((struct regs
*) &extcore
->c_regs
[0])->r_o6
);
540 if (sp
< SPARC_USRSTACK_SPARC10
)
541 intcore
->c_stacktop
= SPARC_USRSTACK_SPARC10
;
543 intcore
->c_stacktop
= SPARC_USRSTACK_SPARC2
;
547 /* Need this cast because ptr is really void *. */
548 #define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
549 #define core_datasec(bfd) (core_hdr (bfd)->data_section)
550 #define core_stacksec(bfd) (core_hdr (bfd)->stack_section)
551 #define core_regsec(bfd) (core_hdr (bfd)->reg_section)
552 #define core_reg2sec(bfd) (core_hdr (bfd)->reg2_section)
554 /* These are stored in the bfd's tdata. */
555 struct sun_core_struct
557 struct internal_sunos_core
*hdr
; /* Core file header. */
558 asection
*data_section
;
559 asection
*stack_section
;
560 asection
*reg_section
;
561 asection
*reg2_section
;
564 static const bfd_target
*
565 sunos4_core_file_p (bfd
*abfd
)
567 unsigned char longbuf
[4]; /* Raw bytes of various header fields. */
568 bfd_size_type core_size
, amt
;
569 unsigned long core_mag
;
570 struct internal_sunos_core
*core
;
574 struct sun_core_struct suncoredata
;
575 struct internal_sunos_core internal_sunos_core
;
576 char external_core
[1];
579 if (bfd_bread ((void *) longbuf
, (bfd_size_type
) sizeof (longbuf
), abfd
)
582 core_mag
= H_GET_32 (abfd
, longbuf
);
584 if (core_mag
!= CORE_MAGIC
)
587 /* SunOS core headers can vary in length; second word is size; */
588 if (bfd_bread ((void *) longbuf
, (bfd_size_type
) sizeof (longbuf
), abfd
)
591 core_size
= H_GET_32 (abfd
, longbuf
);
593 if (core_size
> 20000)
596 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
599 amt
= core_size
+ sizeof (struct mergem
);
600 mergem
= bfd_zalloc (abfd
, amt
);
604 extcore
= mergem
->external_core
;
606 if ((bfd_bread ((void *) extcore
, core_size
, abfd
)) != core_size
)
609 bfd_release (abfd
, (char *) mergem
);
610 abfd
->tdata
.any
= NULL
;
611 bfd_section_list_clear (abfd
);
615 /* Validate that it's a core file we know how to handle, due to sun
616 botching the positioning of registers and other fields in a machine
618 core
= &mergem
->internal_sunos_core
;
622 swapcore_sparc (abfd
, extcore
, core
);
625 swapcore_sun3 (abfd
, extcore
, core
);
627 case SOLARIS_BCP_CORE_LEN
:
628 swapcore_solaris_bcp (abfd
, extcore
, core
);
631 bfd_set_error (bfd_error_system_call
); /* FIXME. */
635 abfd
->tdata
.sun_core_data
= &mergem
->suncoredata
;
636 abfd
->tdata
.sun_core_data
->hdr
= core
;
638 /* Create the sections. */
639 core_stacksec (abfd
) = bfd_make_section_anyway (abfd
, ".stack");
640 if (core_stacksec (abfd
) == NULL
)
641 /* bfd_release frees everything allocated after it's arg. */
644 core_datasec (abfd
) = bfd_make_section_anyway (abfd
, ".data");
645 if (core_datasec (abfd
) == NULL
)
648 core_regsec (abfd
) = bfd_make_section_anyway (abfd
, ".reg");
649 if (core_regsec (abfd
) == NULL
)
652 core_reg2sec (abfd
) = bfd_make_section_anyway (abfd
, ".reg2");
653 if (core_reg2sec (abfd
) == NULL
)
656 core_stacksec (abfd
)->flags
= SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
;
657 core_datasec (abfd
)->flags
= SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
;
658 core_regsec (abfd
)->flags
= SEC_HAS_CONTENTS
;
659 core_reg2sec (abfd
)->flags
= SEC_HAS_CONTENTS
;
661 core_stacksec (abfd
)->size
= core
->c_ssize
;
662 core_datasec (abfd
)->size
= core
->c_dsize
;
663 core_regsec (abfd
)->size
= core
->c_regs_size
;
664 core_reg2sec (abfd
)->size
= core
->fp_stuff_size
;
666 core_stacksec (abfd
)->vma
= (core
->c_stacktop
- core
->c_ssize
);
667 core_datasec (abfd
)->vma
= core
->c_data_addr
;
668 core_regsec (abfd
)->vma
= 0;
669 core_reg2sec (abfd
)->vma
= 0;
671 core_stacksec (abfd
)->filepos
= core
->c_len
+ core
->c_dsize
;
672 core_datasec (abfd
)->filepos
= core
->c_len
;
673 /* We'll access the regs afresh in the core file, like any section: */
674 core_regsec (abfd
)->filepos
= (file_ptr
) core
->c_regs_pos
;
675 core_reg2sec (abfd
)->filepos
= (file_ptr
) core
->fp_stuff_pos
;
677 /* Align to word at least. */
678 core_stacksec (abfd
)->alignment_power
= 2;
679 core_datasec (abfd
)->alignment_power
= 2;
680 core_regsec (abfd
)->alignment_power
= 2;
681 core_reg2sec (abfd
)->alignment_power
= 2;
687 sunos4_core_file_failing_command (bfd
*abfd
)
689 return core_hdr (abfd
)->hdr
->c_cmdname
;
693 sunos4_core_file_failing_signal (bfd
*abfd
)
695 return core_hdr (abfd
)->hdr
->c_signo
;
699 sunos4_core_file_matches_executable_p (bfd
*core_bfd
, bfd
*exec_bfd
)
701 if (core_bfd
->xvec
!= exec_bfd
->xvec
)
703 bfd_set_error (bfd_error_system_call
);
707 /* Solaris core files do not include an aouthdr. */
708 if ((core_hdr (core_bfd
)->hdr
)->c_len
== SOLARIS_BCP_CORE_LEN
)
711 return memcmp ((char *) &((core_hdr (core_bfd
)->hdr
)->c_aouthdr
),
712 (char *) exec_hdr (exec_bfd
),
713 sizeof (struct internal_exec
)) == 0;
716 #define MY_set_sizes sunos4_set_sizes
719 sunos4_set_sizes (bfd
*abfd
)
721 switch (bfd_get_arch (abfd
))
726 adata (abfd
).page_size
= 0x2000;
727 adata (abfd
).segment_size
= 0x2000;
728 adata (abfd
).exec_bytes_size
= EXEC_BYTES_SIZE
;
731 adata (abfd
).page_size
= 0x2000;
732 adata (abfd
).segment_size
= 0x20000;
733 adata (abfd
).exec_bytes_size
= EXEC_BYTES_SIZE
;
738 /* We default to setting the toolversion field to 1, as is required by
740 #ifndef MY_exec_hdr_flags
741 #define MY_exec_hdr_flags 1
744 #ifndef MY_entry_is_text_address
745 #define MY_entry_is_text_address 0
747 #ifndef MY_add_dynamic_symbols
748 #define MY_add_dynamic_symbols 0
750 #ifndef MY_add_one_symbol
751 #define MY_add_one_symbol 0
753 #ifndef MY_link_dynamic_object
754 #define MY_link_dynamic_object 0
756 #ifndef MY_write_dynamic_symbol
757 #define MY_write_dynamic_symbol 0
759 #ifndef MY_check_dynamic_reloc
760 #define MY_check_dynamic_reloc 0
762 #ifndef MY_finish_dynamic_link
763 #define MY_finish_dynamic_link 0
766 static const struct aout_backend_data sunos4_aout_backend
=
768 0, /* Zmagic files are not contiguous. */
769 1, /* Text includes header. */
770 MY_entry_is_text_address
,
772 0, /* Default text vma. */
774 0, /* Header is counted in zmagic text. */
775 MY_add_dynamic_symbols
,
777 MY_link_dynamic_object
,
778 MY_write_dynamic_symbol
,
779 MY_check_dynamic_reloc
,
780 MY_finish_dynamic_link
783 #define MY_core_file_failing_command sunos4_core_file_failing_command
784 #define MY_core_file_failing_signal sunos4_core_file_failing_signal
785 #define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
787 #define MY_bfd_debug_info_start bfd_void
788 #define MY_bfd_debug_info_end bfd_void
789 #define MY_bfd_debug_info_accumulate (void (*) (bfd *, struct bfd_section *)) bfd_void
790 #define MY_core_file_p sunos4_core_file_p
791 #define MY_write_object_contents NAME(aout, sunos4_write_object_contents)
792 #define MY_backend_data & sunos4_aout_backend
794 #ifndef TARGET_IS_LITTLE_ENDIAN_P
795 #define TARGET_IS_BIG_ENDIAN_P
798 #include "aout-target.h"