1 /* A.out "format 1" file handling code for BFD.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
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))
46 The file @code{aoutf1.h} contains the code for BFD's
47 a.out back end. Control over the generated back end is given by these
48 two preprocessor names:
51 This value should be either 32 or 64, depending upon the size of an
52 int in the target format. It changes the sizes of the structs which
53 perform the memory/disk mapping of structures.
55 The 64 bit backend may only be used if the host compiler supports 64
56 ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
57 With this name defined, @emph{all} bfd operations are performed with 64bit
58 arithmetic, not just those to a 64bit target.
61 The name put into the target vector.
71 #define sunos_set_arch_mach sunos_64_set_arch_mach
72 #define sunos_write_object_contents aout_64_sunos4_write_object_contents
74 #define sunos_set_arch_mach sunos_32_set_arch_mach
75 #define sunos_write_object_contents aout_32_sunos4_write_object_contents
78 static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
79 static void sunos_set_arch_mach PARAMS ((bfd *, enum machine_type));
80 static void choose_reloc_size PARAMS ((bfd *));
81 static boolean sunos_write_object_contents PARAMS ((bfd *));
82 static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
83 static char *sunos4_core_file_failing_command PARAMS ((bfd *));
84 static int sunos4_core_file_failing_signal PARAMS ((bfd *));
85 static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
86 static boolean sunos4_set_sizes PARAMS ((bfd *));
88 /* Merge backend data into the output file.
89 This is necessary on sparclet-aout where we want the resultant machine
90 number to be M_SPARCLET if any input file is M_SPARCLET. */
92 #define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
95 sunos_merge_private_bfd_data (ibfd, obfd)
98 if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
99 || bfd_get_flavour (obfd) != bfd_target_aout_flavour)
102 if (bfd_get_arch (obfd) == bfd_arch_sparc)
104 if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
105 bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
111 /* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
112 depending upon ARCH_SIZE. */
115 sunos_set_arch_mach (abfd, machtype)
117 enum machine_type machtype;
119 /* Determine the architecture and machine type of the object file. */
120 enum bfd_architecture arch;
121 unsigned long machine;
126 /* Some Sun3s make magic numbers without cpu types in them, so
127 we'll default to the 68000. */
128 arch = bfd_arch_m68k;
129 machine = bfd_mach_m68000;
134 arch = bfd_arch_m68k;
135 machine = bfd_mach_m68010;
140 arch = bfd_arch_m68k;
141 machine = bfd_mach_m68020;
145 arch = bfd_arch_sparc;
150 arch = bfd_arch_sparc;
151 machine = bfd_mach_sparc_sparclet;
155 arch = bfd_arch_sparc;
156 machine = bfd_mach_sparc_sparclite_le;
161 arch = bfd_arch_i386;
166 arch = bfd_arch_a29k;
171 arch = bfd_arch_m68k;
176 arch = bfd_arch_obscure;
180 bfd_set_arch_mach (abfd, arch, machine);
183 #define SET_ARCH_MACH(ABFD, EXEC) \
184 NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
185 choose_reloc_size(ABFD);
187 /* Determine the size of a relocation entry, based on the architecture */
189 choose_reloc_size (abfd)
192 switch (bfd_get_arch (abfd))
196 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
199 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
204 /* Write an object file in SunOS format. Section contents have
205 already been written. We write the file header, symbols, and
206 relocation. The real name of this function is either
207 aout_64_sunos4_write_object_contents or
208 aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE. */
211 sunos_write_object_contents (abfd)
214 struct external_exec exec_bytes;
215 struct internal_exec *execp = exec_hdr (abfd);
217 /* Magic number, maestro, please! */
218 switch (bfd_get_arch (abfd))
221 switch (bfd_get_mach (abfd))
223 case bfd_mach_m68000:
224 N_SET_MACHTYPE (*execp, M_UNKNOWN);
226 case bfd_mach_m68010:
227 N_SET_MACHTYPE (*execp, M_68010);
230 case bfd_mach_m68020:
231 N_SET_MACHTYPE (*execp, M_68020);
236 switch (bfd_get_mach (abfd))
238 case bfd_mach_sparc_sparclet:
239 N_SET_MACHTYPE (*execp, M_SPARCLET);
241 case bfd_mach_sparc_sparclite_le:
242 N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);
245 N_SET_MACHTYPE (*execp, M_SPARC);
250 N_SET_MACHTYPE (*execp, M_386);
253 N_SET_MACHTYPE (*execp, M_29K);
256 N_SET_MACHTYPE (*execp, M_UNKNOWN);
259 choose_reloc_size (abfd);
261 N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
263 N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC));
265 WRITE_HEADERS (abfd, execp);
272 #define CORE_MAGIC 0x080456
273 #define CORE_NAMELEN 16
275 /* The core structure is taken from the Sun documentation.
276 Unfortunately, they don't document the FPA structure, or at least I
277 can't find it easily. Fortunately the core header contains its own
278 length. So this shouldn't cause problems, except for c_ucode, which
279 so far we don't use but is easy to find with a little arithmetic. */
281 /* But the reg structure can be gotten from the SPARC processor handbook.
282 This really should be in a GNU include file though so that gdb can use
307 /* Taken from Sun documentation: */
309 /* FIXME: It's worse than we expect. This struct contains TWO substructs
310 neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
311 even portably access the stuff in between! */
313 struct external_sparc_core
315 int c_magic; /* Corefile magic number */
316 int c_len; /* Sizeof (struct core) */
317 #define SPARC_CORE_LEN 432
318 int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
319 struct external_exec c_aouthdr; /* A.out header */
320 int c_signo; /* Killing signal, if any */
321 int c_tsize; /* Text size (bytes) */
322 int c_dsize; /* Data size (bytes) */
323 int c_ssize; /* Stack size (bytes) */
324 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
325 double fp_stuff[1]; /* external FPU state (size unknown by us) */
326 /* The type "double" is critical here, for alignment.
327 SunOS declares a struct here, but the struct's alignment
328 is double since it contains doubles. */
329 int c_ucode; /* Exception no. from u_code */
330 /* (this member is not accessible by name since we don't
331 portably know the size of fp_stuff.) */
334 /* Core files generated by the BCP (the part of Solaris which allows
335 it to run SunOS4 a.out files). */
336 struct external_solaris_bcp_core
338 int c_magic; /* Corefile magic number */
339 int c_len; /* Sizeof (struct core) */
340 #define SOLARIS_BCP_CORE_LEN 456
341 int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
342 int c_exdata_vp; /* exdata structure */
347 int c_exdata_nshlibs;
350 int c_exdata_toffset;
351 int c_exdata_doffset;
352 int c_exdata_loffset;
356 int c_signo; /* Killing signal, if any */
357 int c_tsize; /* Text size (bytes) */
358 int c_dsize; /* Data size (bytes) */
359 int c_ssize; /* Stack size (bytes) */
360 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
361 double fp_stuff[1]; /* external FPU state (size unknown by us) */
362 /* The type "double" is critical here, for alignment.
363 SunOS declares a struct here, but the struct's alignment
364 is double since it contains doubles. */
365 int c_ucode; /* Exception no. from u_code */
366 /* (this member is not accessible by name since we don't
367 portably know the size of fp_stuff.) */
370 struct external_sun3_core
372 int c_magic; /* Corefile magic number */
373 int c_len; /* Sizeof (struct core) */
374 #define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
375 int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
376 struct external_exec c_aouthdr; /* A.out header */
377 int c_signo; /* Killing signal, if any */
378 int c_tsize; /* Text size (bytes) */
379 int c_dsize; /* Data size (bytes) */
380 int c_ssize; /* Stack size (bytes) */
381 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
382 double fp_stuff[1]; /* external FPU state (size unknown by us) */
383 /* The type "double" is critical here, for alignment.
384 SunOS declares a struct here, but the struct's alignment
385 is double since it contains doubles. */
386 int c_ucode; /* Exception no. from u_code */
387 /* (this member is not accessible by name since we don't
388 portably know the size of fp_stuff.) */
391 struct internal_sunos_core
393 int c_magic; /* Corefile magic number */
394 int c_len; /* Sizeof (struct core) */
395 long c_regs_pos; /* file offset of General purpose registers */
396 int c_regs_size; /* size of General purpose registers */
397 struct internal_exec c_aouthdr; /* A.out header */
398 int c_signo; /* Killing signal, if any */
399 int c_tsize; /* Text size (bytes) */
400 int c_dsize; /* Data size (bytes) */
401 bfd_vma c_data_addr; /* Data start (address) */
402 int c_ssize; /* Stack size (bytes) */
403 bfd_vma c_stacktop; /* Stack top (address) */
404 char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
405 long fp_stuff_pos; /* file offset of external FPU state (regs) */
406 int fp_stuff_size; /* Size of it */
407 int c_ucode; /* Exception no. from u_code */
410 static void swapcore_sun3
411 PARAMS ((bfd *, char *, struct internal_sunos_core *));
412 static void swapcore_sparc
413 PARAMS ((bfd *, char *, struct internal_sunos_core *));
414 static void swapcore_solaris_bcp
415 PARAMS ((bfd *, char *, struct internal_sunos_core *));
417 /* byte-swap in the Sun-3 core structure */
419 swapcore_sun3 (abfd, ext, intcore)
422 struct internal_sunos_core *intcore;
424 struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
426 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
427 intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
428 intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
429 intcore->c_regs_size = sizeof (extcore->c_regs);
431 aout_64_swap_exec_header_in
433 aout_32_swap_exec_header_in
435 (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
436 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
437 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
438 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
439 intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
440 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
441 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
442 intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
443 /* FP stuff takes up whole rest of struct, except c_ucode. */
444 intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
445 (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
446 /* Ucode is the last thing in the struct -- just before the end */
447 intcore->c_ucode = H_GET_32 (abfd,
449 - sizeof (extcore->c_ucode)
450 + (unsigned char *) extcore));
451 intcore->c_stacktop = 0x0E000000; /* By experimentation */
454 /* byte-swap in the Sparc core structure */
456 swapcore_sparc (abfd, ext, intcore)
459 struct internal_sunos_core *intcore;
461 struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
463 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
464 intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
465 intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
466 intcore->c_regs_size = sizeof (extcore->c_regs);
468 aout_64_swap_exec_header_in
470 aout_32_swap_exec_header_in
472 (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
473 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
474 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
475 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
476 intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
477 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
478 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
479 intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
480 /* FP stuff takes up whole rest of struct, except c_ucode. */
481 intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
482 (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
483 /* Ucode is the last thing in the struct -- just before the end */
484 intcore->c_ucode = H_GET_32 (abfd,
486 - sizeof (extcore->c_ucode)
487 + (unsigned char *) extcore));
489 /* Supposedly the user stack grows downward from the bottom of kernel memory.
490 Presuming that this remains true, this definition will work. */
491 /* Now sun has provided us with another challenge. The value is different
492 for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
493 the other based on the current value of the stack pointer. This
494 loses (a) if the stack pointer has been clobbered, or (b) if the stack
495 is larger than 128 megabytes.
497 It's times like these you're glad they're switching to ELF.
499 Note that using include files or nlist on /vmunix would be wrong,
500 because we want the value for this core file, no matter what kind of
501 machine we were compiled on or are running on. */
502 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
503 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
505 bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
506 if (sp < SPARC_USRSTACK_SPARC10)
507 intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
509 intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
513 /* byte-swap in the Solaris BCP core structure */
515 swapcore_solaris_bcp (abfd, ext, intcore)
518 struct internal_sunos_core *intcore;
520 struct external_solaris_bcp_core *extcore =
521 (struct external_solaris_bcp_core *) ext;
523 intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
524 intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
525 intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
526 intcore->c_regs_size = sizeof (extcore->c_regs);
528 /* The Solaris BCP exdata structure does not contain an a_syms field,
529 so we are unable to synthesize an internal exec header.
530 Luckily we are able to figure out the start address of the data section,
531 which is the only thing needed from the internal exec header,
532 from the exdata structure.
534 As of Solaris 2.3, BCP core files for statically linked executables
535 are buggy. The exdata structure is not properly filled in, and
536 the data section is written from address zero instead of the data
538 memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
539 intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
540 intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
541 intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
542 intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
543 intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
544 memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
545 intcore->fp_stuff_pos =
546 (long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
547 /* FP stuff takes up whole rest of struct, except c_ucode. */
548 intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
549 (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
550 /* Ucode is the last thing in the struct -- just before the end */
551 intcore->c_ucode = H_GET_32 (abfd,
553 - sizeof (extcore->c_ucode)
554 + (unsigned char *) extcore));
556 /* Supposedly the user stack grows downward from the bottom of kernel memory.
557 Presuming that this remains true, this definition will work. */
558 /* Now sun has provided us with another challenge. The value is different
559 for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
560 the other based on the current value of the stack pointer. This
561 loses (a) if the stack pointer has been clobbered, or (b) if the stack
562 is larger than 128 megabytes.
564 It's times like these you're glad they're switching to ELF.
566 Note that using include files or nlist on /vmunix would be wrong,
567 because we want the value for this core file, no matter what kind of
568 machine we were compiled on or are running on. */
569 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
570 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
572 bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
573 if (sp < SPARC_USRSTACK_SPARC10)
574 intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
576 intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
580 /* need this cast because ptr is really void * */
581 #define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
582 #define core_datasec(bfd) (core_hdr(bfd)->data_section)
583 #define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
584 #define core_regsec(bfd) (core_hdr(bfd)->reg_section)
585 #define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
587 /* These are stored in the bfd's tdata */
588 struct sun_core_struct
590 struct internal_sunos_core *hdr; /* core file header */
591 asection *data_section;
592 asection *stack_section;
593 asection *reg_section;
594 asection *reg2_section;
597 static const bfd_target *
598 sunos4_core_file_p (abfd)
601 unsigned char longbuf[4]; /* Raw bytes of various header fields */
602 bfd_size_type core_size, amt;
603 unsigned long core_mag;
604 struct internal_sunos_core *core;
608 struct sun_core_struct suncoredata;
609 struct internal_sunos_core internal_sunos_core;
610 char external_core[1];
613 if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
616 core_mag = H_GET_32 (abfd, longbuf);
618 if (core_mag != CORE_MAGIC)
621 /* SunOS core headers can vary in length; second word is size; */
622 if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
625 core_size = H_GET_32 (abfd, longbuf);
627 if (core_size > 20000)
630 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
633 amt = core_size + sizeof (struct mergem);
634 mergem = (struct mergem *) bfd_zalloc (abfd, amt);
638 extcore = mergem->external_core;
640 if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
643 bfd_release (abfd, (char *) mergem);
644 abfd->tdata.any = NULL;
645 bfd_section_list_clear (abfd);
649 /* Validate that it's a core file we know how to handle, due to sun
650 botching the positioning of registers and other fields in a machine
652 core = &mergem->internal_sunos_core;
656 swapcore_sparc (abfd, extcore, core);
659 swapcore_sun3 (abfd, extcore, core);
661 case SOLARIS_BCP_CORE_LEN:
662 swapcore_solaris_bcp (abfd, extcore, core);
665 bfd_set_error (bfd_error_system_call); /* FIXME */
669 abfd->tdata.sun_core_data = &mergem->suncoredata;
670 abfd->tdata.sun_core_data->hdr = core;
672 /* Create the sections. */
673 core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
674 if (core_stacksec (abfd) == NULL)
675 /* bfd_release frees everything allocated after it's arg. */
678 core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
679 if (core_datasec (abfd) == NULL)
682 core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
683 if (core_regsec (abfd) == NULL)
686 core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
687 if (core_reg2sec (abfd) == NULL)
690 core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
691 core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
692 core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
693 core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
695 core_stacksec (abfd)->_raw_size = core->c_ssize;
696 core_datasec (abfd)->_raw_size = core->c_dsize;
697 core_regsec (abfd)->_raw_size = core->c_regs_size;
698 core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
700 core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
701 core_datasec (abfd)->vma = core->c_data_addr;
702 core_regsec (abfd)->vma = 0;
703 core_reg2sec (abfd)->vma = 0;
705 core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
706 core_datasec (abfd)->filepos = core->c_len;
707 /* We'll access the regs afresh in the core file, like any section: */
708 core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
709 core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
711 /* Align to word at least */
712 core_stacksec (abfd)->alignment_power = 2;
713 core_datasec (abfd)->alignment_power = 2;
714 core_regsec (abfd)->alignment_power = 2;
715 core_reg2sec (abfd)->alignment_power = 2;
721 sunos4_core_file_failing_command (abfd)
724 return core_hdr (abfd)->hdr->c_cmdname;
728 sunos4_core_file_failing_signal (abfd)
731 return core_hdr (abfd)->hdr->c_signo;
735 sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
739 if (core_bfd->xvec != exec_bfd->xvec)
741 bfd_set_error (bfd_error_system_call);
745 /* Solaris core files do not include an aouthdr. */
746 if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
749 return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
750 (char *) exec_hdr (exec_bfd),
751 sizeof (struct internal_exec)) == 0) ? true : false;
754 #define MY_set_sizes sunos4_set_sizes
756 sunos4_set_sizes (abfd)
759 switch (bfd_get_arch (abfd))
764 adata (abfd).page_size = 0x2000;
765 adata (abfd).segment_size = 0x2000;
766 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
769 adata (abfd).page_size = 0x2000;
770 adata (abfd).segment_size = 0x20000;
771 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
776 /* We default to setting the toolversion field to 1, as is required by
778 #ifndef MY_exec_hdr_flags
779 #define MY_exec_hdr_flags 1
782 #ifndef MY_entry_is_text_address
783 #define MY_entry_is_text_address 0
785 #ifndef MY_add_dynamic_symbols
786 #define MY_add_dynamic_symbols 0
788 #ifndef MY_add_one_symbol
789 #define MY_add_one_symbol 0
791 #ifndef MY_link_dynamic_object
792 #define MY_link_dynamic_object 0
794 #ifndef MY_write_dynamic_symbol
795 #define MY_write_dynamic_symbol 0
797 #ifndef MY_check_dynamic_reloc
798 #define MY_check_dynamic_reloc 0
800 #ifndef MY_finish_dynamic_link
801 #define MY_finish_dynamic_link 0
804 static const struct aout_backend_data sunos4_aout_backend =
806 0, /* zmagic files are not contiguous */
807 1, /* text includes header */
808 MY_entry_is_text_address,
810 0, /* default text vma */
812 0, /* header is counted in zmagic text */
813 MY_add_dynamic_symbols,
815 MY_link_dynamic_object,
816 MY_write_dynamic_symbol,
817 MY_check_dynamic_reloc,
818 MY_finish_dynamic_link
821 #define MY_core_file_failing_command sunos4_core_file_failing_command
822 #define MY_core_file_failing_signal sunos4_core_file_failing_signal
823 #define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
825 #define MY_bfd_debug_info_start bfd_void
826 #define MY_bfd_debug_info_end bfd_void
827 #define MY_bfd_debug_info_accumulate \
828 (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
829 #define MY_core_file_p sunos4_core_file_p
830 #define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
831 #define MY_backend_data &sunos4_aout_backend
833 #ifndef TARGET_IS_LITTLE_ENDIAN_P
834 #define TARGET_IS_BIG_ENDIAN_P
837 #include "aout-target.h"