Use new makeinfo -o option. Rest of this Makefile needs work to make it fit
[deliverable/binutils-gdb.git] / bfd / aout.c
index d91bb12ed4a571e711d004c0064159533482058e..8a795e28df2c788911eb3db4a0cb300e9c55ce0f 100755 (executable)
@@ -1,4 +1,4 @@
-/*** bfd backend for sunos binaries */
+/* BFD semi-generic back-end for a.out binaries */
 
 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
 
@@ -18,108 +18,72 @@ You should have received a copy of the GNU General Public License
 along with BFD; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-/* $Id$
- *
- */
-
-#define TARGET_BYTE_ORDER_BIG_P 1
 
 #include <ansidecl.h>
-#include "sysdep.h"
+#include <sysdep.h>
 #include "bfd.h"
 #include "libbfd.h"
 
-
-void (*bfd_error_trap)();
-
-/*SUPPRESS558*/
-/*SUPPRESS529*/
-
-
-
-
-
-/* These values are correct for the SPARC.  I dunno about anything else */
-#define PAGE_SIZE 0x02000
-#define SEGMENT_SIZE PAGE_SIZE
-#define TEXT_START_ADDR PAGE_SIZE
 #include "a.out.gnu.h"
 #include "stab.gnu.h"
 #include "ar.h"
 #include "liba.out.h"           /* BFD a.out internal data structures */
 
-#include "a.out.sun4.h"
+void (*bfd_error_trap)();
+
+/*SUPPRESS558*/
+/*SUPPRESS529*/
 
 #define CTOR_TABLE_RELOC_IDX 2
 static  reloc_howto_type howto_table_ext[] = 
 {
-  /* type                   rs   size bsz  pcrel bitpos  abs ovrf sf name partial inplace mask*/
-{ (unsigned int) RELOC_8,      0,  0,          8,  false, 0, true,  true,0,"8",        false, 0,0x000000ff},
-{ (unsigned int) RELOC_16,     0,  1,  16, false, 0, true,  true,0,"16",       false, 0,0x0000ffff},
-{ (unsigned int) RELOC_32,     0,  2,  32, false, 0, true,  true,0,"32",       false, 0,0xffffffff},
-{ (unsigned int) RELOC_DISP8,  0,  0,  8,  true,  0, false, true,0,"DISP8",    false, 0,0x000000ff},
-{ (unsigned int) RELOC_DISP16, 0,  1,  16, true,  0, false, true,0,"DISP16",   false, 0,0x0000ffff},
-{ (unsigned int) RELOC_DISP32, 0,  2,  32, true,  0, false, true,0,"DISP32",   false, 0,0xffffffff},
-{ (unsigned int) RELOC_WDISP30,2,  2,  30, true,  0, false, true,0,"WDISP30",  false, 0,0x3fffffff},
-{ (unsigned int) RELOC_WDISP22,2,  2,  22, true,  0, false, true,0,"WDISP22",  false, 0,0x003fffff},
-{ (unsigned int) RELOC_HI22,   10, 2,  22, false, 0, false, true,0,"HI22",     false, 0,0x003fffff},
-{ (unsigned int) RELOC_22,      0, 2,  22, false, 0, false, true,0,"22",       false, 0,0x003fffff},
-{ (unsigned int) RELOC_13,     0, 2,   13, false, 0, false, true,0,"13",       false, 0,0x00001fff},
-{ (unsigned int) RELOC_LO10,   0, 2,   10, false, 0, false, true,0,"LO10",     false, 0,0x000003ff},
-{ (unsigned int) RELOC_SFA_BASE,0, 2,  32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff},
-{ (unsigned int) RELOC_SFA_OFF13,0,2,  32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff},
-{ (unsigned int) RELOC_BASE10, 0,  2,  16, false, 0, false, true,0,"BASE10",   false, 0,0x0000ffff},
-{ (unsigned int) RELOC_BASE13, 0,  2,  13, false, 0, false, true,0,"BASE13",   false, 0,0x00001fff},
-{ (unsigned int) RELOC_BASE22, 0,  2,  0,  false, 0, false, true,0,"BASE22",   false, 0,0x00000000},
-{ (unsigned int) RELOC_PC10,   0,  2,  10, false, 0, false, true,0,"PC10",     false, 0,0x000003ff},
-{ (unsigned int) RELOC_PC22,   0,  2,  22, false, 0, false, true,0,"PC22",     false, 0,0x003fffff},
-{ (unsigned int) RELOC_JMP_TBL,0,  2,  32, false, 0, false, true,0,"JMP_TBL",  false, 0,0xffffffff},
-{ (unsigned int) RELOC_SEGOFF16,0, 2,  0,  false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000},
-{ (unsigned int) RELOC_GLOB_DAT,0, 2,  0,  false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000},
-{ (unsigned int) RELOC_JMP_SLOT,0, 2,  0,  false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000},
-{ (unsigned int) RELOC_RELATIVE,0, 2,  0,  false, 0, false, true,0,"RELATIVE", false, 0,0x00000000},
-{ (unsigned int) RELOC_JUMPTARG,2, 13, 16, true,  0, false, true,0,"JUMPTARG", false, 0,0x0000ffff},
-{ (unsigned int) RELOC_CONST,  0, 13,  16, false, 0, false, true,0,"CONST",    false, 0,0x0000ffff},
-{ (unsigned int) RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH",   false, 0,0x0000ffff},
+  HOWTO(RELOC_8,      0,  0,   8,  false, 0, true,  true,0,"8",      false, 0,0x000000ff, false),
+  HOWTO(RELOC_16,     0,  1,   16, false, 0, true,  true,0,"16",      false, 0,0x0000ffff, false),
+  HOWTO(RELOC_32,     0,  2,   32, false, 0, true,  true,0,"32",      false, 0,0xffffffff, false),
+  HOWTO(RELOC_DISP8,  0,  0,   8,  true,  0, false, true,0,"DISP8",    false, 0,0x000000ff, false),
+  HOWTO(RELOC_DISP16, 0,  1,   16, true,  0, false, true,0,"DISP16",   false, 0,0x0000ffff, false),
+  HOWTO(RELOC_DISP32, 0,  2,   32, true,  0, false, true,0,"DISP32",   false, 0,0xffffffff, false),
+  HOWTO(RELOC_WDISP30,2,  2,   30, true,  0, false, true,0,"WDISP30",  false, 0,0x3fffffff, false),
+  HOWTO(RELOC_WDISP22,2,  2,   22, true,  0, false, true,0,"WDISP22",  false, 0,0x003fffff, false),
+  HOWTO(RELOC_HI22,   10, 2,   22, false, 0, false, true,0,"HI22",     false, 0,0x003fffff, false),
+  HOWTO(RELOC_22,      0, 2,   22, false, 0, false, true,0,"22",       false, 0,0x003fffff, false),
+  HOWTO(RELOC_13,      0, 2,   13, false, 0, false, true,0,"13",       false, 0,0x00001fff, false),
+  HOWTO(RELOC_LO10,    0, 2,   10, false, 0, false, true,0,"LO10",     false, 0,0x000003ff, false),
+  HOWTO(RELOC_SFA_BASE,0, 2,   32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff, false),
+  HOWTO(RELOC_SFA_OFF13,0,2,   32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff, false),
+  HOWTO(RELOC_BASE10, 0,  2,   16, false, 0, false, true,0,"BASE10",   false, 0,0x0000ffff, false),
+  HOWTO(RELOC_BASE13, 0,  2,   13, false, 0, false, true,0,"BASE13",   false, 0,0x00001fff, false),
+  HOWTO(RELOC_BASE22, 0,  2,   0,  false, 0, false, true,0,"BASE22",   false, 0,0x00000000, false),
+  HOWTO(RELOC_PC10,   0,  2,   10, false, 0, false, true,0,"PC10",     false, 0,0x000003ff, false),
+  HOWTO(RELOC_PC22,   0,  2,   22, false, 0, false, true,0,"PC22",     false, 0,0x003fffff, false),
+  HOWTO(RELOC_JMP_TBL,0,  2,   32, false, 0, false, true,0,"JMP_TBL",  false, 0,0xffffffff, false),
+  HOWTO(RELOC_SEGOFF16,0, 2,   0,  false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000, false),
+  HOWTO(RELOC_GLOB_DAT,0, 2,   0,  false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000, false),
+  HOWTO(RELOC_JMP_SLOT,0, 2,   0,  false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false),
+  HOWTO(RELOC_RELATIVE,0, 2,   0,  false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false),
+  HOWTO(RELOC_JUMPTARG,2, 13,  16, true,  0, false, true,0,"JUMPTARG", false, 0,0x0000ffff, false),
+  HOWTO(RELOC_CONST,   0, 13,  16, false, 0, false, true,0,"CONST",    false, 0,0x0000ffff, false),
+  HOWTO(RELOC_CONSTH, 16, 13,  16, false, 0, false, true,0,"CONSTH",   false, 0,0x0000ffff, false),
 };
 
 /* Convert standard reloc records to "arelent" format (incl byte swap).  */
 
 static  reloc_howto_type howto_table_std[] = {
-  /* type                   rs   size bsz  pcrel bitpos  abs ovrf sf name*/
-{ (unsigned int) 0,           0,  0,   8,  false, 0, true,  true,0,"8",        true, 0x000000ff,0x000000ff},
-{ (unsigned int) 1,           0,  1,   16, false, 0, true,  true,0,"16",       true, 0x0000ffff,0x0000ffff},
-{ (unsigned int) 2,           0,  2,   32, false, 0, true,  true,0,"32",       true, 0xffffffff,0xffffffff},
-{ (unsigned int) 3,           0,  3,   64, false, 0, true,  true,0,"64",       true, 0xdeaddead,0xdeaddead},
-{ (unsigned int) 4,           0,  0,   8,  true,  0, false, true,0,"DISP8",    true, 0x000000ff,0x000000ff},
-{ (unsigned int) 5,           0,  1,   16, true,  0, false, true,0,"DISP16",   true, 0x0000ffff,0x0000ffff},
-{ (unsigned int) 6,           0,  2,   32, true,  0, false, true,0,"DISP32",   true, 0xffffffff,0xffffffff},
-{ (unsigned int) 7,           0,  3,   64, true,  0, false, true,0,"DISP64",   true, 0xfeedface,0xfeedface},
+  /* type           rs   size bsz  pcrel bitpos  abs ovrf sf name    part_inpl   readmask  setmask  pcdone */
+HOWTO( 0,             0,  0,   8,  false, 0, true,  true,0,"8",        true, 0x000000ff,0x000000ff, false),
+HOWTO( 1,             0,  1,   16, false, 0, true,  true,0,"16",       true, 0x0000ffff,0x0000ffff, false),
+HOWTO( 2,             0,  2,   32, false, 0, true,  true,0,"32",       true, 0xffffffff,0xffffffff, false),
+HOWTO( 3,             0,  3,   64, false, 0, true,  true,0,"64",       true, 0xdeaddead,0xdeaddead, false),
+HOWTO( 4,             0,  0,   8,  true,  0, false, true,0,"DISP8",    true, 0x000000ff,0x000000ff, false),
+HOWTO( 5,             0,  1,   16, true,  0, false, true,0,"DISP16",   true, 0x0000ffff,0x0000ffff, false),
+HOWTO( 6,             0,  2,   32, true,  0, false, true,0,"DISP32",   true, 0xffffffff,0xffffffff, false),
+HOWTO( 7,             0,  3,   64, true,  0, false, true,0,"DISP64",   true, 0xfeedface,0xfeedface, false),
 };
 
 
 bfd_error_vector_type bfd_error_vector;
-/** a.out files */
-
-
-PROTO (void , sunos4_write_syms, ());
-PROTO (static boolean,sunos4_squirt_out_relocs,(bfd *abfd, asection *section));
-
-
-static size_t
-reloc_size_func(abfd)
-bfd *abfd;
-{
-  switch (bfd_get_architecture (abfd)) {
-  case bfd_arch_sparc:
-  case bfd_arch_a29k:
-    return  RELOC_EXT_SIZE;
-  default:
-    return  RELOC_STD_SIZE;
-  }
-}
 
-static void
+void
 DEFUN(bfd_aout_swap_exec_header_in,(abfd, raw_bytes, execp),
       bfd *abfd AND
       unsigned char *raw_bytes AND
@@ -138,7 +102,7 @@ DEFUN(bfd_aout_swap_exec_header_in,(abfd, raw_bytes, execp),
   execp->a_drsize = bfd_h_getlong (abfd, bytes->a_drsize);
 }
 
-static void
+void
 DEFUN(bfd_aout_swap_exec_header_out,(abfd, execp, raw_bytes),
      bfd *abfd AND
      struct exec *execp AND 
@@ -157,67 +121,24 @@ DEFUN(bfd_aout_swap_exec_header_out,(abfd, execp, raw_bytes),
   bfd_h_putlong (abfd, execp->a_drsize, bytes->a_drsize);
 }
 
-/* Steve wants some way to frob this stuff from Saber while he's debugging
-   ld, so we have these funny shadow functions */
-/* ZMAGIC's start at 0 (making the exec part of the text section),
-  other formats start after the exec
-*/
-static unsigned int n_txtoff(ptr)
-struct exec *ptr;
-{return N_MAGIC(*ptr)== ZMAGIC ? 0: sizeof(struct exec);}
-
-static unsigned int n_datoff(ptr)
-struct exec *ptr;
-{return n_txtoff(ptr) + ptr->a_text;}
-
-static unsigned int n_treloff(ptr)
-struct exec *ptr;
-{return n_datoff(ptr) + ptr->a_data;}
-
-static unsigned int n_dreloff(ptr)
-struct exec *ptr;
-{return n_treloff(ptr) + ptr->a_trsize;}
-
-static unsigned int n_symoff(ptr)
-struct exec *ptr;
-{return n_dreloff(ptr) + ptr->a_drsize;}
-
-static unsigned int n_stroff(ptr)
-struct exec *ptr;
-{return n_symoff(ptr) + ptr->a_syms;}
-
-static
-unsigned int n_badmag(ptr)
-     struct exec *ptr;
-{
-  switch (N_MAGIC(*ptr)) {
-  case OMAGIC: case NMAGIC: case ZMAGIC: return 0;
-  default: return 1;
-  }
-}
-
+/* Some A.OUT variant thinks that the file whose format we're checking
+   is an a.out file.  Do some more checking, and set up for access if
+   it really is.  Call back to the calling environment's "finish up"
+   function just before returning, to handle any last-minute setup.  */
 bfd_target *
-sunos4_object_p (abfd)
+some_aout_object_p (abfd, callback_to_real_object_p)
      bfd *abfd;
+     bfd_target *(*callback_to_real_object_p) ();
 {
-  unsigned char magicbuf[4];   /* Raw bytes of magic number from file */
-  unsigned long magic;         /* Swapped magic number */
   unsigned char exec_bytes[EXEC_BYTES_SIZE];   /* Raw bytes of exec hdr */
   struct exec *execp;
   PTR rawptr;
 
-  bfd_error = system_call_error;
-
-  if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
-      sizeof (magicbuf))
+  if (bfd_seek (abfd, 0L, false) < 0) {
+    bfd_error = system_call_error;
     return 0;
-  magic = bfd_h_getlong (abfd, magicbuf);
-
-  /* Baroque syntax to mask deficiencies of the Sun compiler */
-  /* if (N_BADMAG (*((struct exec *) &magic))) return 0; */
-  if (n_badmag ((struct exec *) &magic)) return 0;
-
-  if (bfd_seek (abfd, 0L, false) < 0) return 0;
+  }
 
   if (bfd_read ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
       != EXEC_BYTES_SIZE) {
@@ -226,16 +147,16 @@ sunos4_object_p (abfd)
   }
 
   /* Use an intermediate variable for clarity */
-  rawptr = (PTR) bfd_zalloc (abfd, sizeof (struct sunexdata) + sizeof (struct exec));
+  rawptr = (PTR) bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec));
 
   if (rawptr == NULL) {
     bfd_error = no_memory;
     return 0;
   }
 
-  set_tdata (abfd, ((struct sunexdata *) rawptr));
+  set_tdata (abfd, ((struct aoutdata *) rawptr));
   exec_hdr (abfd) = execp =
-    (struct exec *) ((char *)rawptr + sizeof (struct sunexdata));
+    (struct exec *) ((char *)rawptr + sizeof (struct aoutdata));
 
   bfd_aout_swap_exec_header_in (abfd, exec_bytes, execp);
 
@@ -248,73 +169,43 @@ sunos4_object_p (abfd)
   if (execp->a_syms) 
     abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
 
-
   if (N_MAGIC (*execp) == ZMAGIC) abfd->flags |= D_PAGED;
   if (N_MAGIC (*execp) == NMAGIC) abfd->flags |= WP_TEXT;
 
-  /* Determine the architecture and machine type of the object file.  */
-  abfd->obj_arch = bfd_arch_unknown;   /* Default values */
-  abfd->obj_machine = 0;
-  switch (N_MACHTYPE (*execp)) {
-
-  case M_UNKNOWN:
-       break;
-
-  case M_68010:
-       abfd->obj_arch = bfd_arch_m68k;
-       abfd->obj_machine = 68010;
-       break;
-
-  case M_68020:
-       abfd->obj_arch = bfd_arch_m68k;
-       abfd->obj_machine = 68020;
-       break;
-
-  case M_SPARC:
-       abfd->obj_arch = bfd_arch_sparc;
-       break;
-
-  case M_386:
-       abfd->obj_arch = bfd_arch_i386;
-       break;
-
-  case M_29K:
-       abfd->obj_arch = bfd_arch_a29k;
-       break;
+  bfd_get_start_address (abfd) = execp->a_entry;
 
-  default:
-       abfd->obj_arch = bfd_arch_obscure;
-       break;
-  }
+  obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
+  bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct nlist);
 
-  bfd_get_start_address (abfd) = execp->a_entry;
+  /* Set the default architecture and machine type.  These can be
+     overridden in the callback routine.  */
+  abfd->obj_arch = bfd_arch_unknown;
+  abfd->obj_machine = 0;
 
-  /* Remember the positions of the string table and symbol table.  */
-  obj_str_filepos (abfd) = n_stroff (execp);
-  obj_sym_filepos (abfd) = n_symoff (execp);
+  /* The default relocation entry size is that of traditional V7 Unix.  */
+  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
 
   /* create the sections.  This is raunchy, but bfd_close wants to reclaim
      them */
   obj_textsec (abfd) = (asection *)NULL;
   obj_datasec (abfd) = (asection *)NULL;
   obj_bsssec (abfd) = (asection *)NULL;
-  obj_aout_symbols(abfd) = (aout_symbol_type *)NULL;
   (void)bfd_make_section(abfd, ".text");
   (void)bfd_make_section(abfd, ".data");
   (void)bfd_make_section(abfd, ".bss");
 
+  abfd->sections = obj_textsec (abfd);
+  obj_textsec (abfd)->next = obj_datasec (abfd);
+  obj_datasec (abfd)->next = obj_bsssec (abfd);
+
   obj_datasec (abfd)->size = execp->a_data;
   obj_bsssec (abfd)->size = execp->a_bss;
   obj_textsec (abfd)->size = execp->a_text;
-  obj_datasec (abfd)->vma = N_DATADDR(*execp);
-  obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
-  obj_textsec (abfd)->vma = N_TXTADDR(*execp);
-
-  obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
-  obj_datasec (abfd)->filepos = N_DATOFF(*execp);
 
-  obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
-  obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
+  if (abfd->flags & D_PAGED) {
+    obj_textsec (abfd)->size -=  EXEC_BYTES_SIZE;
+  }
+    
 
   obj_textsec (abfd)->flags = (execp->a_trsize != 0 ?
                                (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
@@ -324,15 +215,71 @@ sunos4_object_p (abfd)
                                (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
   obj_bsssec (abfd)->flags = SEC_ALLOC;
 
-  abfd->sections = obj_textsec (abfd);
-  obj_textsec (abfd)->next = obj_datasec (abfd);
-  obj_datasec (abfd)->next = obj_bsssec (abfd);
-  return abfd->xvec;
+#ifdef THIS_IS_ONLY_DOCUMENTATION
+  /* Call back to the format-dependent code to fill in the rest of the 
+     fields and do any further cleanup.  Things that should be filled
+     in by the callback:  */
+
+        struct exec *execp = exec_hdr (abfd);
+
+       /* The virtual memory addresses of the sections */
+       obj_datasec (abfd)->vma = N_DATADDR(*execp);
+       obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
+       obj_textsec (abfd)->vma = N_TXTADDR(*execp);
+
+       /* The file offsets of the sections */
+       obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
+       obj_datasec (abfd)->filepos = N_DATOFF(*execp);
+
+       /* The file offsets of the relocation info */
+       obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
+       obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
+
+       /* The file offsets of the string table and symbol table.  */
+       obj_str_filepos (abfd) = N_STROFF (*execp);
+       obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+
+     /* This common code can't fill in those things because they depend
+     on either the start address of the text segment, the rounding
+     up of virtual addersses between segments, or the starting file 
+     position of the text segment -- all of which varies among different
+     versions of a.out.  */
+
+       /* Determine the architecture and machine type of the object file.  */
+       switch (N_MACHTYPE (*exec_hdr (abfd))) {
+       default:
+             abfd->obj_arch = bfd_arch_obscure;
+             break;
+       }
+
+       /* Determine the size of a relocation entry */
+       switch (abfd->obj_arch) {
+       case bfd_arch_sparc:
+       case bfd_arch_a29k:
+         obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
+       default:
+         obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+       }
+
+       return abfd->xvec;
+
+     /* The architecture is encoded in various ways in various a.out variants,
+     or is not encoded at all in some of them.  The relocation size depends
+     on the architecture and the a.out variant.  Finally, the return value
+     is the bfd_target vector in use.  If an error occurs, return zero and
+     set bfd_error to the appropriate error code.
+
+     Formats such as b.out, which have additional fields in the a.out
+     header, should cope with them in this callback as well.  */
+#endif /* DOCUMENTATION */
+
+
+  return (*callback_to_real_object_p)(abfd);
 }
 
 
 boolean
-sunos4_mkobject (abfd)
+aout_mkobject (abfd)
      bfd *abfd;
 {
   char *rawptr;
@@ -340,15 +287,15 @@ sunos4_mkobject (abfd)
   bfd_error = system_call_error;
 
   /* Use an intermediate variable for clarity */
-  rawptr =  bfd_zalloc (abfd,sizeof (struct sunexdata) + sizeof (struct exec));
+  rawptr = bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec));
 
   if (rawptr == NULL) {
     bfd_error = no_memory;
     return false;
   }
 
-  abfd->tdata = (PTR)((struct sunexdata *) rawptr);
-  exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct sunexdata));
+  set_tdata (abfd, (struct aoutdata *) rawptr);
+  exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct aoutdata));
 
   /* For simplicity's sake we just make all the sections right here. */
 
@@ -369,7 +316,7 @@ sunos4_mkobject (abfd)
    If the architecture is understood, machine type 0 (default) should
    always be understood.  */
 
-static enum machine_type
+enum machine_type
 aout_machine_type (arch, machine)
      enum bfd_architecture arch;
      unsigned long machine;
@@ -409,7 +356,7 @@ aout_machine_type (arch, machine)
 }
 
 boolean
-sunos4_set_arch_mach (abfd, arch, machine)
+aout_set_arch_mach (abfd, arch, machine)
      bfd *abfd;
      enum bfd_architecture arch;
      unsigned long machine;
@@ -421,358 +368,11 @@ sunos4_set_arch_mach (abfd, arch, machine)
     return false;              /* We can't represent this type */
   return true;                 /* We're easy ... */
 }
-
-boolean
-sunos4_write_object_contents (abfd)
-     bfd *abfd;
-{
-  size_t data_pad = 0;
-  unsigned char exec_bytes[EXEC_BYTES_SIZE];
-  struct exec *execp = exec_hdr (abfd);
-
-  execp->a_text = obj_textsec (abfd)->size;
-
-  /* Magic number, maestro, please!  */
-  switch (bfd_get_architecture(abfd)) {
-  case bfd_arch_m68k:
-    switch (bfd_get_machine(abfd)) {
-    case 68010:
-      N_SET_MACHTYPE(*execp, M_68010);
-      break;
-    default:
-    case 68020:
-      N_SET_MACHTYPE(*execp, M_68020);
-      break;
-    }
-    break;
-  case bfd_arch_sparc:
-    N_SET_MACHTYPE(*execp, M_SPARC);
-    break;
-  case bfd_arch_i386:
-    N_SET_MACHTYPE(*execp, M_386);
-    break;
-  case bfd_arch_a29k:
-    N_SET_MACHTYPE(*execp, M_29K);
-    break;
-  default:
-    N_SET_MACHTYPE(*execp, M_UNKNOWN);
-  }
-
-  N_SET_MAGIC (*execp, OMAGIC);
-  if (abfd->flags & D_PAGED) {
-    execp->a_text = obj_textsec (abfd)->size + sizeof(struct exec);
-    N_SET_MAGIC (*execp, ZMAGIC);
-  } else if (abfd->flags & WP_TEXT) {
-    N_SET_MAGIC (*execp, NMAGIC);
-  }
-  N_SET_FLAGS (*execp, 0x1);   /* copied from ld.c; who the hell knows? */
-
-  if (abfd->flags & D_PAGED) 
-      {
-       data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1)
-                   & (- PAGE_SIZE)) - obj_datasec(abfd)->size;
-
-       if (data_pad > obj_bsssec(abfd)->size)
-         execp->a_bss = 0;
-       else 
-         execp->a_bss = obj_bsssec(abfd)->size - data_pad;
-       execp->a_data = obj_datasec(abfd)->size + data_pad;
-
-      }
-  else {
-    execp->a_data = obj_datasec (abfd)->size;
-    execp->a_bss = obj_bsssec (abfd)->size;
-  }
-
-  execp->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
-  execp->a_entry = bfd_get_start_address (abfd);
-
-  execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
-                    reloc_size_func(abfd));
-                      
-  execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
-                    reloc_size_func(abfd));
-
-  bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes);
-
-  bfd_seek (abfd, 0L, false);
-  bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
-
-  /* Now write out reloc info, followed by syms and strings */
-
-  if (bfd_get_symcount (abfd) != 0) 
-    {
-      bfd_seek (abfd,
-               (long)(N_SYMOFF(*execp)), false);
-
-      sunos4_write_syms (abfd);
-
-      bfd_seek (abfd,  (long)(N_TROFF(*execp)), false);
-
-      if (!sunos4_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
-      bfd_seek (abfd, (long)(N_DROFF(*execp)), false);
-
-      if (!sunos4_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
-    }
-  return true;
-}
-
-/** core files */
-/** core files */
-
-#define CORE_MAGIC 0x080456
-#define CORE_NAMELEN 16
-
-/* The core structure is taken from the Sun documentation.
-   Unfortunately, they don't document the FPA structure, or at least I
-   can't find it easily.  Fortunately the core header contains its own
-   length.  So this shouldn't cause problems, except for c_ucode, which
-   so far we don't use but is easy to find with a little arithmetic. */
-
-/* But the reg structure can be gotten from the SPARC processor handbook.
-   This really should be in a GNU include file though so that gdb can use
-   the same info. */
-struct regs {
-  int r_psr;
-  int r_pc;
-  int r_npc;
-  int r_y;
-  int r_g1;
-  int r_g2;
-  int r_g3;
-  int r_g4;
-  int r_g5;
-  int r_g6;
-  int r_g7;
-  int r_o0;
-  int r_o1;
-  int r_o2;
-  int r_o3;
-  int r_o4;
-  int r_o5;
-  int r_o6;
-  int r_o7;
-};
-
-/* Taken from Sun documentation: */
-
-/* FIXME:  It's worse than we expect.  This struct contains TWO substructs
-   neither of whose size we know, WITH STUFF IN BETWEEN THEM!  We can't
-   even portably access the stuff in between!  */
-
-struct core {
-  int c_magic;                 /* Corefile magic number */
-  int c_len;                   /* Sizeof (struct core) */
-  struct regs c_regs;          /* General purpose registers */
-  struct exec c_aouthdr;       /* A.out header */
-  int c_signo;                 /* Killing signal, if any */
-  int c_tsize;                 /* Text size (bytes) */
-  int c_dsize;                 /* Data size (bytes) */
-  int c_ssize;                 /* Stack size (bytes) */
-  char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
-  double fp_stuff[1];          /* external FPU state (size unknown by us) */
-               /* The type "double" is critical here, for alignment.
-                  SunOS declares a struct here, but the struct's alignment
-                  is double since it contains doubles.  */
-  int c_ucode;                 /* Exception no. from u_code */
-               /* (this member is not accessible by name since we don't
-                   portably know the size of fp_stuff.) */
-};
-
-/* Supposedly the user stack grows downward from the bottom of kernel memory.
-   Presuming that this remains true, this definition will work. */
-#define USRSTACK (-(128*1024*1024))
-
-PROTO (static void, swapcore, (bfd *abfd, struct core *core));
-
-/* need this cast b/c ptr is really void * */
-#define core_hdr(bfd) (((struct suncordata *) (bfd->tdata))->hdr)
-#define core_datasec(bfd) (((struct suncordata *) ((bfd)->tdata))->data_section)
-#define core_stacksec(bfd) (((struct suncordata*)((bfd)->tdata))->stack_section)
-#define core_regsec(bfd) (((struct suncordata *) ((bfd)->tdata))->reg_section)
-#define core_reg2sec(bfd) (((struct suncordata *) ((bfd)->tdata))->reg2_section)
-
-/* These are stored in the bfd's tdata */
-struct suncordata {
-  struct core *hdr;             /* core file header */
-  asection *data_section;
-  asection *stack_section;
-  asection *reg_section;
-  asection *reg2_section;
-};
-
-bfd_target *
-sunos4_core_file_p (abfd)
-     bfd *abfd;
-{
-  unsigned char longbuf[4];    /* Raw bytes of various header fields */
-  int core_size;
-  int core_mag;
-  struct core *core;
-  char *rawptr;
-
-  bfd_error = system_call_error;
-
-  if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) !=
-        sizeof (longbuf))
-    return 0;
-  core_mag = bfd_h_getlong (abfd, longbuf);
-
-  if (core_mag != CORE_MAGIC) return 0;
-
-  /* SunOS core headers can vary in length; second word is size; */
-  if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) !=
-        sizeof (longbuf))
-    return 0;
-  core_size = bfd_h_getlong (abfd, longbuf);
-  /* Sanity check */
-  if (core_size > 20000)
-    return 0;
-
-  if (bfd_seek (abfd, 0L, false) < 0) return 0;
-
-  rawptr = bfd_zalloc (abfd, core_size + sizeof (struct suncordata));
-  if (rawptr == NULL) {
-    bfd_error = no_memory;
-    return 0;
-  }
-
-  core = (struct core *) (rawptr + sizeof (struct suncordata));
-
-  if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size) {
-    bfd_error = system_call_error;
-    free ((PTR)rawptr);
-    return 0;
-  }
-
-  swapcore (abfd, core);
-  set_tdata (abfd, ((struct suncordata *) rawptr));
-  core_hdr (abfd) = core;
-
-  /* create the sections.  This is raunchy, but bfd_close wants to reclaim
-     them */
-  core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
-  if (core_stacksec (abfd) == NULL) {
-loser:
-    bfd_error = no_memory;
-    free ((PTR)rawptr);
-    return 0;
-  }
-  core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
-  if (core_datasec (abfd) == NULL) {
-loser1:
-    free ((PTR)core_stacksec (abfd));
-    goto loser;
-  }
-  core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
-  if (core_regsec (abfd) == NULL) {
-loser2:
-    free ((PTR)core_datasec (abfd));
-    goto loser1;
-  }
-  core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
-  if (core_reg2sec (abfd) == NULL) {
-    free ((PTR)core_regsec (abfd));
-    goto loser2;
-  }
-
-  core_stacksec (abfd)->name = ".stack";
-  core_datasec (abfd)->name = ".data";
-  core_regsec (abfd)->name = ".reg";
-  core_reg2sec (abfd)->name = ".reg2";
-
-  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
-  core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
-  core_regsec (abfd)->flags = SEC_ALLOC;
-  core_reg2sec (abfd)->flags = SEC_ALLOC;
-
-  core_stacksec (abfd)->size = core->c_ssize;
-  core_datasec (abfd)->size = core->c_dsize;
-  core_regsec (abfd)->size = (sizeof core->c_regs);
-  /* Float regs take up end of struct, except c_ucode.  */
-  core_reg2sec (abfd)->size = core_size - (sizeof core->c_ucode) -
-                             (file_ptr)(((struct core *)0)->fp_stuff);
-
-  core_stacksec (abfd)->vma = (USRSTACK - core->c_ssize);
-  core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr);
-  core_regsec (abfd)->vma = -1;
-  core_reg2sec (abfd)->vma = -1;
-
-  core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
-  core_datasec (abfd)->filepos = core->c_len;
-                        /* In file header: */
-  core_regsec (abfd)->filepos = (file_ptr)(&((struct core *)0)->c_regs);
-  core_reg2sec (abfd)->filepos = (file_ptr)(((struct core *)0)->fp_stuff);
-
-  /* Align to word at least */
-  core_stacksec (abfd)->alignment_power = 2;
-  core_datasec (abfd)->alignment_power = 2;
-  core_regsec (abfd)->alignment_power = 2;
-  core_reg2sec (abfd)->alignment_power = 2;
-
-  abfd->sections = core_stacksec (abfd);
-  core_stacksec (abfd)->next = core_datasec (abfd);
-  core_datasec (abfd)->next = core_regsec (abfd);
-  core_regsec (abfd)->next = core_reg2sec (abfd);
-
-  abfd->section_count = 4;
-
-  return abfd->xvec;
-}
-
-char *
-sunos4_core_file_failing_command (abfd)
-     bfd *abfd;
-{
-  return core_hdr (abfd)->c_cmdname;
-}
-
-int
-sunos4_core_file_failing_signal (abfd)
-     bfd *abfd;
-{
-  return core_hdr (abfd)->c_signo;
-}
-
-boolean
-sunos4_core_file_matches_executable_p  (core_bfd, exec_bfd)
-     bfd *core_bfd, *exec_bfd;
-{
-  if (core_bfd->xvec != exec_bfd->xvec) {
-    bfd_error = system_call_error;
-    return false;
-  }
-
-  return (bcmp ((char *)&core_hdr (core_bfd), (char*) &exec_hdr (exec_bfd),
-                sizeof (struct exec)) == 0) ? true : false;
-}
-
-/* byte-swap core structure */
-/* FIXME, this needs more work to swap IN a core struct from raw bytes */
-static void
-swapcore (abfd, core)
-     bfd *abfd;
-     struct core *core;
-{
-  unsigned char exec_bytes[EXEC_BYTES_SIZE];
-
-  core->c_magic = bfd_h_getlong (abfd, (unsigned char *)&core->c_magic);
-  core->c_len   = bfd_h_getlong (abfd, (unsigned char *)&core->c_len  );
-  /* Leave integer registers in target byte order.  */
-  bcopy ((char *)&(core->c_aouthdr), (char *)exec_bytes, EXEC_BYTES_SIZE);
-  bfd_aout_swap_exec_header_in (abfd, exec_bytes, &core->c_aouthdr);
-  core->c_signo = bfd_h_getlong (abfd, (unsigned char *)&core->c_signo);
-  core->c_tsize = bfd_h_getlong (abfd, (unsigned char *)&core->c_tsize);
-  core->c_dsize = bfd_h_getlong (abfd, (unsigned char *)&core->c_dsize);
-  core->c_ssize = bfd_h_getlong (abfd, (unsigned char *)&core->c_ssize);
-  /* Leave FP registers in target byte order.  */
-  /* Leave "c_ucode" unswapped for now, since we can't find it easily.  */
-}
 \f
-/** exec and core file sections */
+/* exec and core file sections */
 
 boolean
-sunos4_new_section_hook (abfd, newsect)
+aout_new_section_hook (abfd, newsect)
      bfd *abfd;
      asection *newsect;
 {
@@ -801,75 +401,46 @@ sunos4_new_section_hook (abfd, newsect)
 }
 
 boolean
-sunos4_set_section_contents (abfd, section, location, offset, count)
+aout_set_section_contents (abfd, section, location, offset, count)
      bfd *abfd;
      sec_ptr section;
-     unsigned char *location;
+     PTR location;
      file_ptr offset;
       int count;
 {
   if (abfd->output_has_begun == false)
       {                                /* set by bfd.c handler */
-       if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL)
-         
-           /*||
-             (obj_textsec (abfd)->size == 0) || (obj_datasec (abfd)->size=
-             0)*/
-           ) 
+       if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL)) 
            {
              bfd_error = invalid_operation;
              return false;
            }
 
+       obj_textsec(abfd)->filepos = sizeof(struct exec);
+       obj_textsec(abfd)->size = align_power(obj_textsec(abfd)->size,
+                                             obj_textsec(abfd)->alignment_power);
+       obj_datasec(abfd)->filepos =  obj_textsec (abfd)->size + EXEC_BYTES_SIZE;
+       obj_datasec(abfd)->size = align_power(obj_datasec(abfd)->size,
+                                             obj_datasec(abfd)->alignment_power);
 
-#if 0
-       if (abfd->flags & D_PAGED)
-           {
-             obj_textsec (abfd)->filepos = sizeof(struct exec);
-             obj_datasec(abfd)->filepos =  obj_textsec (abfd)->size;
-           }
-       else 
-#endif
-           {
-             obj_textsec (abfd)->filepos = sizeof(struct exec);
-             obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos  + obj_textsec (abfd)->size;
 
-           }
       }
   /* regardless, once we know what we're doing, we might as well get going */
-  if (section != obj_bsssec(abfd)) {
-    bfd_seek (abfd, section->filepos + offset, SEEK_SET);
+  if (section != obj_bsssec(abfd)) 
+      {
+       bfd_seek (abfd, section->filepos + offset, SEEK_SET);
 
-    if (count) {
-      return (bfd_write ((PTR)location, 1, count, abfd) == count) ?
-       true : false;
-    }
-    return false;
-  }
+       if (count) {
+         return (bfd_write ((PTR)location, 1, count, abfd) == count) ?
+           true : false;
+       }
+       return false;
+      }
   return true;
 }
-boolean
-sunos4_get_section_contents (abfd, section, location, offset, count)
-     bfd *abfd;
-     sec_ptr section;
-     PTR location;
-     file_ptr offset;
-     int count;
-{
-  if (count) {
-    if (offset >= section->size) return false;
-
-    bfd_seek (abfd, section->filepos + offset, SEEK_SET);
-
-    return (bfd_read (location, 1, count, abfd) == count) ? true:false;
-  }
-  else return true;
-}
-
 \f
 /* Classify stabs symbols */
 
-
 #define sym_in_text_section(sym) \
      (((sym)->n_type  & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_TEXT)
 
@@ -945,14 +516,12 @@ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd)
       }
       cache_ptr->symbol.section = reloc->relent.section;
       reloc->relent.addend = cache_ptr->symbol.value ;
-      /* 
-        We modify the symbol to belong to a section depending upon the
+
+      /* We modify the symbol to belong to a section depending upon the
         name of the symbol - probably __CTOR__ or __DTOR__ but we don't
         really care, and add to the size of the section to contain a
         pointer to the symbol. Build a reloc entry to relocate to this
-        symbol attached to this section.
-        */
-
+        symbol attached to this section.  */
 
       section->flags = SEC_CONSTRUCTOR;
       section->reloc_count++;
@@ -1051,7 +620,7 @@ translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd)
 {
   asymbol *cache_ptr = (asymbol *)cache_ptr_g;
 
-  /* FIXME check for wrigin bss */
+  /* FIXME check for writing bss */
   if (bfd_get_section(cache_ptr)) {
     if (bfd_get_output_section(cache_ptr) == obj_bsssec (abfd)) {
       sym_pointer->n_type |= N_BSS;
@@ -1063,9 +632,8 @@ translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd)
       sym_pointer->n_type |= N_TEXT;
     }
     else {
-
-      bfd_error_vector.nonrepresentable_section(abfd, bfd_get_output_section(cache_ptr)->name);
-
+      bfd_error_vector.nonrepresentable_section(abfd,
+                                bfd_get_output_section(cache_ptr)->name);
     }
     /* Turn the symbol from section relative to absolute again */
     sym_pointer->n_value +=
@@ -1091,7 +659,6 @@ translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd)
   if (cache_ptr->flags & BSF_DEBUGGING) {
     sym_pointer->n_type = ((aout_symbol_type *)cache_ptr)->type;
   }
-  
 }
 \f
 /* Native-level interface to symbols. */
@@ -1101,7 +668,7 @@ translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd)
    hold them all plus all the cached symbol entries. */
 
 asymbol *
-sunos4_make_empty_symbol (abfd)
+aout_make_empty_symbol (abfd)
 bfd *abfd;
 {
   aout_symbol_type  *new =
@@ -1112,12 +679,12 @@ bfd *abfd;
 }
 
 boolean
-DEFUN(sunos4_slurp_symbol_table, (abfd),
+DEFUN(aout_slurp_symbol_table, (abfd),
       bfd *abfd)
 {
-  unsigned int symbol_count;
   size_t symbol_size;
   size_t string_size;
+  unsigned char string_chars[LONG_SIZE];
   struct nlist *syms;
   char *strings;
   aout_symbol_type *cached;
@@ -1131,19 +698,22 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
   }
 
   bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET);
-  if (bfd_read ((PTR)&string_size, 4, 1, abfd) != 4)
+  if (bfd_read ((PTR)string_chars, LONG_SIZE, 1, abfd) != LONG_SIZE)
     return false;
-  string_size = bfd_h_getlong (abfd, (unsigned char *)&string_size);
-
-  symbol_count = symbol_size / sizeof (struct nlist);
+  string_size = bfd_h_getlong (abfd, string_chars);
 
   strings = bfd_alloc(abfd, string_size + 1);
-  cached = bfd_zalloc(abfd, symbol_count * sizeof(aout_symbol_type));
-  syms = bfd_alloc(abfd, symbol_size);
+  cached = (aout_symbol_type *)
+          bfd_zalloc(abfd, bfd_get_symcount (abfd) * sizeof(aout_symbol_type));
+  /* Alloc this last, so we can free it if obstack is in use.  */
+  syms = (struct nlist *) bfd_alloc(abfd, symbol_size);
 
   bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
   if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) {
   bailout:
+    if (syms)  bfd_release (abfd, syms);
+    if (cached)        bfd_release (abfd, cached);
+    if (strings)bfd_release (abfd, strings);
     return false;
   }
 
@@ -1155,22 +725,21 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
   /* OK, now walk the new symtable, cacheing symbol properties */
     {
       register struct nlist *sym_pointer;
-      register struct nlist *sym_end = syms + symbol_count;
+      register struct nlist *sym_end = syms + bfd_get_symcount (abfd);
       register aout_symbol_type *cache_ptr = cached;
 
       /* run through the table and byte swap if needed */
       for (sym_pointer = syms; sym_pointer < sym_end;  sym_pointer++) {
         sym_pointer->n_un.n_strx =
-         bfd_h_get_x (abfd, &sym_pointer->n_un.n_strx);
+         bfd_h_getlong (abfd, &sym_pointer->n_un.n_strx);
         sym_pointer->n_desc =
-         bfd_h_get_x (abfd, &sym_pointer->n_desc);
+         bfd_h_getshort (abfd, &sym_pointer->n_desc);
         sym_pointer->n_value =
-         bfd_h_get_x (abfd, &sym_pointer->n_value);
+         bfd_h_getlong (abfd, &sym_pointer->n_value);
        sym_pointer->n_other = (char)
-         bfd_h_get_x(abfd, &sym_pointer->n_other);
+         bfd_h_getchar(abfd, &sym_pointer->n_other);
        sym_pointer->n_type = (char)
-         bfd_h_get_x(abfd, &sym_pointer->n_type);
-
+         bfd_h_getchar(abfd, &sym_pointer->n_type);
       }
 
       /* Run through table and copy values */
@@ -1193,7 +762,6 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
     }
 
   obj_aout_symbols (abfd) =  cached;
-  bfd_get_symcount (abfd) = symbol_count;
   bfd_release (abfd, (PTR)syms);
 
   return true;
@@ -1201,7 +769,7 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
 
 
 void
-DEFUN(sunos4_write_syms,(abfd),
+DEFUN(aout_write_syms,(abfd),
      bfd *abfd)
 {
   unsigned int count ;
@@ -1258,7 +826,7 @@ DEFUN(sunos4_write_syms,(abfd),
     {
       asymbol *g = *(generic++);
 
-      if (g->name != (char *)NULL) 
+      if (g->name)
        {
          size_t length = strlen(g->name)+1;
          bfd_write((PTR)g->name, 1, length, abfd);
@@ -1271,30 +839,30 @@ DEFUN(sunos4_write_syms,(abfd),
 
 
 void
-DEFUN(sunos4_reclaim_symbol_table,(abfd),
+DEFUN(aout_reclaim_symbol_table,(abfd),
      bfd *abfd)
 {
 
 }
 \f
 unsigned int
-sunos4_get_symtab_upper_bound (abfd)
+aout_get_symtab_upper_bound (abfd)
      bfd *abfd;
 {
-  if (!sunos4_slurp_symbol_table (abfd)) return 0;
+  if (!aout_slurp_symbol_table (abfd)) return 0;
 
   return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *));
 }
 
 unsigned int
-sunos4_get_symtab (abfd, location)
+aout_get_symtab (abfd, location)
      bfd *abfd;
      asymbol **location;
 {
   unsigned int counter = 0;
   aout_symbol_type *symbase;
 
-  if (!sunos4_slurp_symbol_table (abfd)) return 0;
+  if (!aout_slurp_symbol_table (abfd)) return 0;
 
   for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);)
     *(location++) = (asymbol *)( symbase++);
@@ -1307,11 +875,10 @@ sunos4_get_symtab (abfd, location)
 /* Output standard relocation information to a file in target byte order. */
 
 void
-swap_std_reloc_out (abfd, p, natptr, count)
+swap_std_reloc_out (abfd, g, natptr)
      bfd *abfd;
-     arelent **p;              /* Generic relocation struct */
+     arelent *g;               /* Generic relocation struct */
      struct reloc_std_bytes *natptr;
-     unsigned int count;
 {
   int r_index;
   int r_extern;
@@ -1319,83 +886,79 @@ swap_std_reloc_out (abfd, p, natptr, count)
   int r_pcrel;
   int r_baserel, r_jmptable, r_relative;
   unsigned int r_addend;
-  unsigned int idx;
-  for (idx = 0; idx < count; idx++, p++, natptr++) 
-    {
-      arelent *g = *p;
-      bfd_h_putlong (abfd, g->address, natptr->r_address);
 
-      r_length = g->howto->size; /* Size as a power of two */
-      r_pcrel  = (int) g->howto->pc_relative;  /* Relative to PC? */
-      /* r_baserel, r_jmptable, r_relative???  FIXME-soon */
-      r_baserel = 0;
-      r_jmptable = 0;
-      r_relative = 0;
+  bfd_h_putlong (abfd, g->address, natptr->r_address);
 
-      r_addend = g->addend;    /* Start here, see how it goes */
+  r_length = g->howto->size ; /* Size as a power of two */
+  r_pcrel  = (int) g->howto->pc_relative;      /* Relative to PC? */
+  /* r_baserel, r_jmptable, r_relative???  FIXME-soon */
+  r_baserel = 0;
+  r_jmptable = 0;
+  r_relative = 0;
 
-      /* name was clobbered by sunos4_write_syms to be symbol index */
+  r_addend = g->addend;        /* Start here, see how it goes */
 
-      if (g->sym_ptr_ptr != NULL) 
-       {
-         if ((*(g->sym_ptr_ptr))->section) {
-           /* put the section offset into the addend for output */
-           r_addend += (*(g->sym_ptr_ptr))->section->vma;
-         }
+  /* name was clobbered by aout_write_syms to be symbol index */
 
-         r_index = stoi((*(g->sym_ptr_ptr))->name);
-         r_extern = 1;
-       }
-      else {
-       r_extern = 0;
-       if (g->section == NULL) {
-         BFD_ASSERT(0);
-         r_index = N_ABS | N_EXT;
-       }
-       else  if(g->section->output_section == obj_textsec(abfd)) {
-         r_index = N_TEXT | N_EXT;
-         r_addend += g->section->output_section->vma;
-       }
-       else if (g->section->output_section == obj_datasec(abfd)) {
-         r_index = N_DATA | N_EXT;
-         r_addend += g->section->output_section->vma;
-       }
-       else if (g->section->output_section == obj_bsssec(abfd)) {
-         r_index = N_BSS | N_EXT ;
-         r_addend += g->section->output_section->vma;
-       }
-       else {
-         BFD_ASSERT(0);
-       }
-      }
-
-      /* now the fun stuff */
-      if (abfd->xvec->header_byteorder_big_p != false) {
-       natptr->r_index[0] = r_index >> 16;
-       natptr->r_index[1] = r_index >> 8;
-       natptr->r_index[2] = r_index;
-       natptr->r_bits[0] =
-         (r_extern?    RELOC_STD_BITS_EXTERN_BIG: 0)
-           | (r_pcrel?     RELOC_STD_BITS_PCREL_BIG: 0)
-             | (r_baserel?   RELOC_STD_BITS_BASEREL_BIG: 0)
-               | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_BIG: 0)
-                 | (r_relative?  RELOC_STD_BITS_RELATIVE_BIG: 0)
-                   | (r_length <<  RELOC_STD_BITS_LENGTH_SH_BIG);
-      } else {
-       natptr->r_index[2] = r_index >> 16;
-       natptr->r_index[1] = r_index >> 8;
-       natptr->r_index[0] = r_index;
-       natptr->r_bits[0] =
-         (r_extern?    RELOC_STD_BITS_EXTERN_LITTLE: 0)
-           | (r_pcrel?     RELOC_STD_BITS_PCREL_LITTLE: 0)
-             | (r_baserel?   RELOC_STD_BITS_BASEREL_LITTLE: 0)
-               | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_LITTLE: 0)
-                 | (r_relative?  RELOC_STD_BITS_RELATIVE_LITTLE: 0)
-                   | (r_length <<  RELOC_STD_BITS_LENGTH_SH_LITTLE);
+  if (g->sym_ptr_ptr != NULL) 
+    {
+      if ((*(g->sym_ptr_ptr))->section) {
+       /* put the section offset into the addend for output */
+       r_addend += (*(g->sym_ptr_ptr))->section->vma;
       }
 
-
+      r_index = stoi((*(g->sym_ptr_ptr))->name);
+      r_extern = 1;
+    }
+  else {
+    r_extern = 0;
+    if (g->section == NULL) {
+      /* It is possible to have a reloc with nothing, we generate an
+        abs + 0 */
+      r_addend = 0;
+      r_index = N_ABS | N_EXT;
+    }
+    else  if(g->section->output_section == obj_textsec(abfd)) {
+      r_index = N_TEXT | N_EXT;
+      r_addend += g->section->output_section->vma;
+    }
+    else if (g->section->output_section == obj_datasec(abfd)) {
+      r_index = N_DATA | N_EXT;
+      r_addend += g->section->output_section->vma;
+    }
+    else if (g->section->output_section == obj_bsssec(abfd)) {
+      r_index = N_BSS | N_EXT ;
+      r_addend += g->section->output_section->vma;
+    }
+    else {
+      BFD_ASSERT(0);
     }
+  }
+
+  /* now the fun stuff */
+  if (abfd->xvec->header_byteorder_big_p != false) {
+    natptr->r_index[0] = r_index >> 16;
+    natptr->r_index[1] = r_index >> 8;
+    natptr->r_index[2] = r_index;
+    natptr->r_bits[0] =
+      (r_extern?    RELOC_STD_BITS_EXTERN_BIG: 0)
+       | (r_pcrel?     RELOC_STD_BITS_PCREL_BIG: 0)
+         | (r_baserel?   RELOC_STD_BITS_BASEREL_BIG: 0)
+           | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_BIG: 0)
+             | (r_relative?  RELOC_STD_BITS_RELATIVE_BIG: 0)
+               | (r_length <<  RELOC_STD_BITS_LENGTH_SH_BIG);
+  } else {
+    natptr->r_index[2] = r_index >> 16;
+    natptr->r_index[1] = r_index >> 8;
+    natptr->r_index[0] = r_index;
+    natptr->r_bits[0] =
+      (r_extern?    RELOC_STD_BITS_EXTERN_LITTLE: 0)
+       | (r_pcrel?     RELOC_STD_BITS_PCREL_LITTLE: 0)
+         | (r_baserel?   RELOC_STD_BITS_BASEREL_LITTLE: 0)
+           | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_LITTLE: 0)
+             | (r_relative?  RELOC_STD_BITS_RELATIVE_LITTLE: 0)
+               | (r_length <<  RELOC_STD_BITS_LENGTH_SH_LITTLE);
+  }
 }
 
 
@@ -1403,84 +966,79 @@ swap_std_reloc_out (abfd, p, natptr, count)
 /* Output extended relocation information to a file in target byte order. */
 
 void
-swap_ext_reloc_out (abfd, p, natptr, count)
+swap_ext_reloc_out (abfd, g, natptr)
      bfd *abfd;
-     arelent **p;              /* Generic relocation struct */
+     arelent *g;               /* Generic relocation struct */
      register struct reloc_ext_bytes *natptr;
-     unsigned int count;
 {
-
   int r_index;
   int r_extern;
   unsigned int r_type;
   unsigned int r_addend;
-  unsigned int idx;
-  for (idx = 0; idx < count; idx++, p++, natptr++) {
-    arelent *g = *p;
 
-    bfd_h_putlong (abfd, g->address, natptr->r_address);
+  bfd_h_putlong (abfd, g->address, natptr->r_address);
 
-    /* Find a type in the output format which matches the input howto - 
-       at the moment we assume input format == output format FIXME!! */
-    r_type = (enum reloc_type) g->howto->type;
+  /* Find a type in the output format which matches the input howto - 
+     at the moment we assume input format == output format FIXME!! */
+  r_type = (enum reloc_type) g->howto->type;
 
-    r_addend = g->addend;      /* Start here, see how it goes */
+  r_addend = g->addend;        /* Start here, see how it goes */
 
-    /* name was clobbered by sunos4_write_syms to be symbol index*/
-
-    if (g->sym_ptr_ptr != NULL) 
-      {
-       if ((*(g->sym_ptr_ptr))->section) {
-         /* put the section offset into the addend for output */
-         r_addend += (*(g->sym_ptr_ptr))->section->vma;
-       }
+  /* name was clobbered by aout_write_syms to be symbol index*/
 
-       r_index = stoi((*(g->sym_ptr_ptr))->name);
-       r_extern = 1;
-      }
-    else {
-      r_extern = 0;
-      if (g->section == NULL) {
-       BFD_ASSERT(0);
-       r_index = N_ABS | N_EXT;
-      }
-      else  if(g->section->output_section == obj_textsec(abfd)) {
-       r_index = N_TEXT | N_EXT;
-       r_addend += g->section->output_section->vma;
-      }
-      else if (g->section->output_section == obj_datasec(abfd)) {
-       r_index = N_DATA | N_EXT;
-       r_addend += g->section->output_section->vma;
-      }
-      else if (g->section->output_section == obj_bsssec(abfd)) {
-       r_index = N_BSS | N_EXT ;
-       r_addend += g->section->output_section->vma;
-      }
-      else {
-       BFD_ASSERT(0);
+  if (g->sym_ptr_ptr != NULL) 
+    {
+      if ((*(g->sym_ptr_ptr))->section) {
+       /* put the section offset into the addend for output */
+       r_addend += (*(g->sym_ptr_ptr))->section->vma;
       }
-    }
 
-    /* now the fun stuff */
-    if (abfd->xvec->header_byteorder_big_p != false) {
-      natptr->r_index[0] = r_index >> 16;
-      natptr->r_index[1] = r_index >> 8;
-      natptr->r_index[2] = r_index;
-      natptr->r_bits[0] =
-       (r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0)
-         || (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
-    } else {
-      natptr->r_index[2] = r_index >> 16;
-      natptr->r_index[1] = r_index >> 8;
-      natptr->r_index[0] = r_index;
-      natptr->r_bits[0] =
-       (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0)
-         || (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
+      r_index = stoi((*(g->sym_ptr_ptr))->name);
+      r_extern = 1;
+    }
+  else {
+    r_extern = 0;
+    if (g->section == NULL) {
+      BFD_ASSERT(0);
+      r_index = N_ABS | N_EXT;
+    }
+    else  if(g->section->output_section == obj_textsec(abfd)) {
+      r_index = N_TEXT | N_EXT;
+      r_addend += g->section->output_section->vma;
+    }
+    else if (g->section->output_section == obj_datasec(abfd)) {
+      r_index = N_DATA | N_EXT;
+      r_addend += g->section->output_section->vma;
     }
+    else if (g->section->output_section == obj_bsssec(abfd)) {
+      r_index = N_BSS | N_EXT ;
+      r_addend += g->section->output_section->vma;
+    }
+    else {
+      BFD_ASSERT(0);
+    }
+  }
 
-    bfd_h_putlong (abfd, r_addend, natptr->r_addend);
+  /* now the fun stuff */
+  if (abfd->xvec->header_byteorder_big_p != false) {
+    natptr->r_index[0] = r_index >> 16;
+    natptr->r_index[1] = r_index >> 8;
+    natptr->r_index[2] = r_index;
+    natptr->r_bits[0] =
+      (r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0)
+       | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
+  } else {
+    natptr->r_index[2] = r_index >> 16;
+    natptr->r_index[1] = r_index >> 8;
+    natptr->r_index[0] = r_index;
+    natptr->r_bits[0] =
+      (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0)
+       | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
   }
+
+  bfd_h_putlong (abfd, r_addend, natptr->r_addend);
 }
+
 #define MOVE_ADDRESS(ad)                                                       \
   if (r_extern) {                                                      \
     cache_ptr->sym_ptr_ptr = symbols + r_index;                                \
@@ -1506,9 +1064,13 @@ swap_ext_reloc_out (abfd, p, natptr, count)
       break;                                                           \
     case N_ABS:                                                                \
     case N_ABS | N_EXT:                                                        \
+      cache_ptr->section = NULL;       /* No section */                \
+      cache_ptr->addend = ad;          /* FIXME, is this right? */     \
       BFD_ASSERT(1);                                                   \
       break;                                                           \
     default:                                                           \
+      cache_ptr->section = NULL;       /* No section */                \
+      cache_ptr->addend = ad;          /* FIXME, is this right? */     \
       BFD_ASSERT(1);                                                   \
       break;                                                           \
     }                                                                  \
@@ -1524,7 +1086,7 @@ swap_ext_reloc_in (abfd, bytes, cache_ptr, symbols)
   int r_index;
   int r_extern;
   unsigned int r_type;
-  struct sunexdata *su = (struct sunexdata *)(abfd->tdata);
+  struct aoutdata *su = (struct aoutdata *)(abfd->tdata);
 
   cache_ptr->address = bfd_h_getlong (abfd, bytes->r_address);
 
@@ -1547,13 +1109,12 @@ swap_ext_reloc_in (abfd, bytes, cache_ptr, symbols)
 
   cache_ptr->howto =  howto_table_ext + r_type;
   MOVE_ADDRESS(bfd_h_getlong(abfd,bytes->r_addend));
-                                                                        
 }
 
 void
 swap_std_reloc_in (abfd, bytes, cache_ptr, symbols)
      bfd *abfd;
- struct reloc_std_bytes *bytes;
    struct reloc_std_bytes *bytes;
      arelent *cache_ptr;
      asymbol **symbols;
 {
@@ -1562,7 +1123,8 @@ swap_std_reloc_in (abfd, bytes, cache_ptr, symbols)
   unsigned int r_length;
   int r_pcrel;
   int r_baserel, r_jmptable, r_relative;
-  struct sunexdata *su = (struct sunexdata *)(abfd->tdata);
+  struct aoutdata *su = (struct aoutdata *)(abfd->tdata);
+
   cache_ptr->address = bfd_h_getlong (abfd, bytes->r_address);
 
   /* now the fun stuff */
@@ -1576,7 +1138,7 @@ swap_std_reloc_in (abfd, bytes, cache_ptr, symbols)
     r_jmptable= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_JMPTABLE_BIG));
     r_relative= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_RELATIVE_BIG));
     r_length  =       (bytes->r_bits[0] & RELOC_STD_BITS_LENGTH_BIG) 
-      >> RELOC_STD_BITS_LENGTH_SH_BIG;
+                       >> RELOC_STD_BITS_LENGTH_SH_BIG;
   } else {
     r_index =  (bytes->r_index[2] << 16)
       | (bytes->r_index[1] << 8)
@@ -1587,7 +1149,7 @@ swap_std_reloc_in (abfd, bytes, cache_ptr, symbols)
     r_jmptable= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
     r_relative= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_RELATIVE_LITTLE));
     r_length  =       (bytes->r_bits[0] & RELOC_STD_BITS_LENGTH_LITTLE) 
-      >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
+                       >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
   }
 
   cache_ptr->howto =  howto_table_std + r_length + 4 * r_pcrel;
@@ -1599,7 +1161,7 @@ swap_std_reloc_in (abfd, bytes, cache_ptr, symbols)
 /* Reloc hackery */
 
 boolean
-sunos4_slurp_reloc_table (abfd, asect, symbols)
+aout_slurp_reloc_table (abfd, asect, symbols)
      bfd *abfd;
      sec_ptr asect;
      asymbol **symbols;
@@ -1629,31 +1191,41 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
 
  doit:
   bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
-  each_size = reloc_size_func(abfd);
+  each_size = obj_reloc_entry_size (abfd);
 
   count = reloc_size / each_size;
 
 
   reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof
                                                       (arelent)));
+  if (!reloc_cache) {
+nomem:
+    bfd_error = no_memory;
+    return false;
+  }
+
   relocs =  bfd_alloc (abfd, reloc_size);
+  if (!relocs) {
+    bfd_release (abfd, reloc_cache);
+    goto nomem;
+  }
 
-  if (bfd_read ( relocs, 1, reloc_size, abfd) != reloc_size) {
+  if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size) {
+    bfd_release (abfd, relocs);
+    bfd_release (abfd, reloc_cache);
     bfd_error = system_call_error;
     return false;
   }
 
-  if (each_size == RELOC_EXT_SIZE)
-    {
-      register struct reloc_ext_bytes *rptr = (struct reloc_ext_bytes *) relocs;
-      unsigned int counter = 0;
-      arelent *cache_ptr = reloc_cache;
+  if (each_size == RELOC_EXT_SIZE) {
+    register struct reloc_ext_bytes *rptr = (struct reloc_ext_bytes *) relocs;
+    unsigned int counter = 0;
+    arelent *cache_ptr = reloc_cache;
 
-      for (; counter < count; counter++, rptr++, cache_ptr++) {
-       swap_ext_reloc_in(abfd, rptr, cache_ptr, symbols);
-      }
+    for (; counter < count; counter++, rptr++, cache_ptr++) {
+      swap_ext_reloc_in(abfd, rptr, cache_ptr, symbols);
     }
-  else {
+  else {
     register struct reloc_std_bytes *rptr = (struct reloc_std_bytes *) relocs;
     unsigned int counter = 0;
     arelent *cache_ptr = reloc_cache;
@@ -1663,7 +1235,8 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
     }
 
   }
-bfd_release (abfd,relocs);
+
+  bfd_release (abfd,relocs);
   asect->relocation = reloc_cache;
   asect->reloc_count = count;
   return true;
@@ -1673,13 +1246,13 @@ bfd_release (abfd,relocs);
 
 /* Write out a relocation section into an object file.  */
 
-static boolean
-sunos4_squirt_out_relocs (abfd, section)
+boolean
+aout_squirt_out_relocs (abfd, section)
      bfd *abfd;
      asection *section;
 {
   arelent **generic;
-  unsigned char *native;
+  unsigned char *native, *natptr;
   size_t each_size;
 
   unsigned int count = section->reloc_count;
@@ -1687,7 +1260,7 @@ sunos4_squirt_out_relocs (abfd, section)
 
   if (count == 0) return true;
 
-  each_size = reloc_size_func(abfd);
+  each_size = obj_reloc_entry_size (abfd);
   natsize = each_size * count;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
   if (!native) {
@@ -1699,14 +1272,17 @@ sunos4_squirt_out_relocs (abfd, section)
 
   if (each_size == RELOC_EXT_SIZE) 
     {
-      swap_ext_reloc_out (abfd,
-                         generic,
-                         (struct reloc_ext_bytes *)native,
-                         count);
+      for (natptr = native;
+          count != 0;
+          --count, natptr += each_size, ++generic)
+       swap_ext_reloc_out (abfd, *generic, (struct reloc_ext_bytes *)natptr);
     }
   else 
     {
-      swap_std_reloc_out(abfd, generic, native, count);
+      for (natptr = native;
+          count != 0;
+          --count, natptr += each_size, ++generic)
+       swap_std_reloc_out(abfd, *generic, (struct reloc_std_bytes *)natptr);
     }
 
   if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
@@ -1720,7 +1296,7 @@ sunos4_squirt_out_relocs (abfd, section)
 
 /* This is stupid.  This function should be a boolean predicate */
 unsigned int
-sunos4_canonicalize_reloc (abfd, section, relptr, symbols)
+aout_canonicalize_reloc (abfd, section, relptr, symbols)
      bfd *abfd;
      sec_ptr section;
      arelent **relptr;
@@ -1729,7 +1305,7 @@ sunos4_canonicalize_reloc (abfd, section, relptr, symbols)
   arelent *tblptr = section->relocation;
   unsigned int count;
 
-  if (!(tblptr || sunos4_slurp_reloc_table (abfd, section, symbols)))
+  if (!(tblptr || aout_slurp_reloc_table (abfd, section, symbols)))
     return 0;
 
   if (section->flags & SEC_CONSTRUCTOR) {
@@ -1754,7 +1330,7 @@ sunos4_canonicalize_reloc (abfd, section, relptr, symbols)
 }
 
 unsigned int
-sunos4_get_reloc_upper_bound (abfd, asect)
+aout_get_reloc_upper_bound (abfd, asect)
      bfd *abfd;
      sec_ptr asect;
 {
@@ -1769,12 +1345,12 @@ sunos4_get_reloc_upper_bound (abfd, asect)
 
   if (asect == obj_datasec (abfd))
     return (sizeof (arelent *) *
-            ((exec_hdr(abfd)->a_drsize / reloc_size_func(abfd))
+            ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd))
              +1));
 
   if (asect == obj_textsec (abfd))
     return (sizeof (arelent *) *
-            ((exec_hdr(abfd)->a_trsize / reloc_size_func(abfd))
+            ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
              +1));
 
   bfd_error = invalid_operation;
@@ -1782,36 +1358,38 @@ sunos4_get_reloc_upper_bound (abfd, asect)
 }
 
 void
-sunos4_reclaim_reloc (ignore_abfd, section)
+aout_reclaim_reloc (ignore_abfd, ignore)
      bfd *ignore_abfd;
-     sec_ptr section;
+     sec_ptr ignore;
 {
 
 }
 \f
 
 alent *
-sunos4_get_lineno(ignore_abfd, ignore_symbol)
+aout_get_lineno(ignore_abfd, ignore_symbol)
 bfd *ignore_abfd;
-PTR ignore_symbol;
+asymbol *ignore_symbol;
 {
 return (alent *)NULL;
 }
 
 void 
-sunos4_print_symbol(ignore_abfd, file,  symbol, how)
+aout_print_symbol(ignore_abfd, afile, symbol, how)
 bfd *ignore_abfd;
-FILE *file;
+PTR afile;
 asymbol *symbol;
 bfd_print_symbol_enum_type how;
 {
+  FILE *file = (FILE *)afile;
+
   switch (how) {
   case bfd_print_symbol_name_enum:
     fprintf(file,"%s", symbol->name);
     break;
   case bfd_print_symbol_type_enum:
     fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
-           (unsigned)(   aout_symbol(symbol)->other  & 0xff),
+           (unsigned)(aout_symbol(symbol)->other & 0xff),
            (unsigned)(aout_symbol(symbol)->type));
     break;
   case bfd_print_symbol_all_enum:
@@ -1824,31 +1402,13 @@ bfd_print_symbol_enum_type how;
       fprintf(file," %-5s %04x %02x %02x %s",
              section_name,
              (unsigned)(aout_symbol(symbol)->desc & 0xffff),
-             (unsigned)(aout_symbol(symbol)->other  & 0xff),
+             (unsigned)(aout_symbol(symbol)->other & 0xff),
              (unsigned)(aout_symbol(symbol)->type  & 0xff),
              symbol->name);
     }
     break;
   }
 }
-/* Once we know all the stuff that could be consed, we know how to clean
-   it up.  So why don't we? */
-
-boolean
-sunos4_close_and_cleanup (abfd)
-     bfd *abfd;
-{
-  if (!bfd_read_p (abfd))
-    switch (abfd->format) {
-    case bfd_archive:
-      if (!_bfd_write_archive_contents (abfd)) return false; break;
-    case bfd_object:
-      if (!sunos4_write_object_contents (abfd))  return false; break;
-    default: bfd_error = invalid_operation; return false;
-    }
-
-  return true;
-}
 
 /* 
  provided a bfd, a section and an offset into the section, calculate
@@ -1857,7 +1417,7 @@ sunos4_close_and_cleanup (abfd)
 */
  
 boolean
-DEFUN(sunos4_find_nearest_line,(abfd,
+DEFUN(aout_find_nearest_line,(abfd,
                                section,
                                symbols,
                                offset,
@@ -1932,64 +1492,9 @@ DEFUN(sunos4_find_nearest_line,(abfd,
 
 }
 
-static int 
-DEFUN(sunos4_sizeof_headers,(abfd),
-      bfd *abfd)
+int 
+DEFUN(aout_sizeof_headers,(ignore_abfd),
+      bfd *ignore_abfd)
 {
-return 0;
+  return 0;            /* FIXME, this is the wrong value! */
 }
-
-#define sunos4_openr_next_archived_file bfd_generic_openr_next_archived_file
-#define sunos4_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define sunos4_slurp_armap bfd_slurp_bsd_armap
-#define sunos4_slurp_extended_name_table bfd_true
-#define sunos4_write_armap bsd_write_armap
-#define sunos4_truncate_arname bfd_bsd_truncate_arname
-bfd_target aout_big_vec =
-{
-  "a.out-generic-big",         /* name */
-  bfd_target_aout_flavour_enum,
-  true,                                /* target byte order */
-  true,                                /* target headers byte order */
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-  ' ',                         /* ar_pad_char */
-  16,                          /* ar_max_namelen */
-  _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
-  _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
-
-    {_bfd_dummy_target, sunos4_object_p,
-       bfd_generic_archive_p, sunos4_core_file_p},
-    {bfd_false, sunos4_mkobject,
-       _bfd_generic_mkarchive, bfd_false},
-
-  JUMP_TABLE(sunos4)
-  };
-
-
-bfd_target aout_little_vec =
-{
-  "a.out-generic-little",              /* name */
-  bfd_target_aout_flavour_enum,
-  false,                       /* target byte order */
-  false,                       /* target headers byte order */
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-  ' ',                         /* ar_pad_char */
-  16,                          /* ar_max_namelen */
-  _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
-  _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
-
-
-    {_bfd_dummy_target, sunos4_object_p,
-       bfd_generic_archive_p, sunos4_core_file_p},
-    {bfd_false, sunos4_mkobject,
-       _bfd_generic_mkarchive, bfd_false},
-
-  JUMP_TABLE(sunos4)
-  };
-
This page took 0.043359 seconds and 4 git commands to generate.