home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / bfd / aoutf1.h < prev    next >
C/C++ Source or Header  |  1994-02-03  |  20KB  |  614 lines

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