* chew.c: Use #include "" instead of <> for local header files.
[deliverable/binutils-gdb.git] / bfd / aoutf1.h
index fdf95b5b11751261713eb23fcc324d1772e5ebdb..0f773a18a8c1a7ed2d38ddbca5ba8b1d973a03fb 100644 (file)
@@ -1,5 +1,6 @@
 /* A.out "format 1" file handling code for BFD.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
+   2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -33,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 /* This is needed to reject a NewsOS file, e.g. in
    gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
    I needed to add M_UNKNOWN to recognize a 68000 object, so this will
-   probably no longer reject a NewsOS object.  <ian@cygnus.com>. */
+   probably no longer reject a NewsOS object.  <ian@cygnus.com>.  */
 #ifndef MACHTYPE_OK
 #define MACHTYPE_OK(mtype) \
   (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
@@ -75,7 +76,7 @@ The name put into the target vector.
 #endif
 
 static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static void sunos_set_arch_mach PARAMS ((bfd *, int));
+static void sunos_set_arch_mach PARAMS ((bfd *, enum machine_type));
 static void choose_reloc_size PARAMS ((bfd *));
 static boolean sunos_write_object_contents PARAMS ((bfd *));
 static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
@@ -113,17 +114,17 @@ sunos_merge_private_bfd_data (ibfd, obfd)
 static void
 sunos_set_arch_mach (abfd, machtype)
      bfd *abfd;
-     int machtype;
+     enum machine_type machtype;
 {
   /* Determine the architecture and machine type of the object file.  */
   enum bfd_architecture arch;
-  long machine;
+  unsigned long machine;
   switch (machtype)
     {
 
     case M_UNKNOWN:
       /* Some Sun3s make magic numbers without cpu types in them, so
-        we'll default to the 68000. */
+        we'll default to the 68000.  */
       arch = bfd_arch_m68k;
       machine = bfd_mach_m68000;
       break;
@@ -180,7 +181,7 @@ sunos_set_arch_mach (abfd, machtype)
 }
 
 #define SET_ARCH_MACH(ABFD, EXEC) \
-  NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
+  NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
   choose_reloc_size(ABFD);
 
 /* Determine the size of a relocation entry, based on the architecture */
@@ -259,7 +260,7 @@ sunos_write_object_contents (abfd)
 
   N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
 
-  N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
+  N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC));
 
   WRITE_HEADERS (abfd, execp);
 
@@ -275,11 +276,11 @@ sunos_write_object_contents (abfd)
   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. */
+  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. */
+  the same info.  */
 struct regs
 {
   int r_psr;
@@ -422,8 +423,8 @@ swapcore_sun3 (abfd, ext, intcore)
 {
   struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
 
-  intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
-  intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
   intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
   intcore->c_regs_size = sizeof (extcore->c_regs);
 #if ARCH_SIZE == 64
@@ -432,24 +433,24 @@ swapcore_sun3 (abfd, ext, intcore)
   aout_32_swap_exec_header_in
 #endif
     (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
-  intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
-  intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
-  intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
   intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
-  intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
   memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
   intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
-  /* FP stuff takes up whole rest of struct, except c_ucode. */
+  /* FP stuff takes up whole rest of struct, except c_ucode.  */
   intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
     (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
   /* Ucode is the last thing in the struct -- just before the end */
-  intcore->c_ucode =
-    bfd_h_get_32 (abfd,
-    intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+  intcore->c_ucode = H_GET_32 (abfd,
+                              (intcore->c_len
+                               - sizeof (extcore->c_ucode)
+                               + (unsigned char *) extcore));
   intcore->c_stacktop = 0x0E000000;    /* By experimentation */
 }
 
-
 /* byte-swap in the Sparc core structure */
 static void
 swapcore_sparc (abfd, ext, intcore)
@@ -459,8 +460,8 @@ swapcore_sparc (abfd, ext, intcore)
 {
   struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
 
-  intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
-  intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
   intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
   intcore->c_regs_size = sizeof (extcore->c_regs);
 #if ARCH_SIZE == 64
@@ -469,20 +470,21 @@ swapcore_sparc (abfd, ext, intcore)
   aout_32_swap_exec_header_in
 #endif
     (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
-  intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
-  intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
-  intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
   intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
-  intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
   memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
   intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
-  /* FP stuff takes up whole rest of struct, except c_ucode. */
+  /* FP stuff takes up whole rest of struct, except c_ucode.  */
   intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
     (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
   /* Ucode is the last thing in the struct -- just before the end */
-  intcore->c_ucode =
-    bfd_h_get_32 (abfd,
-    intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+  intcore->c_ucode = H_GET_32 (abfd,
+                              (intcore->c_len
+                               - sizeof (extcore->c_ucode)
+                               + (unsigned char *) extcore));
 
   /* Supposedly the user stack grows downward from the bottom of kernel memory.
      Presuming that this remains true, this definition will work.  */
@@ -500,8 +502,7 @@ swapcore_sparc (abfd, ext, intcore)
 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
   {
-    bfd_vma sp = bfd_h_get_32
-    (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+    bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
     if (sp < SPARC_USRSTACK_SPARC10)
       intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
     else
@@ -519,8 +520,8 @@ swapcore_solaris_bcp (abfd, ext, intcore)
   struct external_solaris_bcp_core *extcore =
     (struct external_solaris_bcp_core *) ext;
 
-  intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
-  intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
   intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
   intcore->c_regs_size = sizeof (extcore->c_regs);
 
@@ -535,22 +536,22 @@ swapcore_solaris_bcp (abfd, ext, intcore)
      the data section is written from address zero instead of the data
      start address.  */
   memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
-  intcore->c_data_addr =
-    bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
-  intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
-  intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
-  intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
-  intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+  intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
+  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
+  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
   memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
   intcore->fp_stuff_pos =
     (long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
-  /* FP stuff takes up whole rest of struct, except c_ucode. */
+  /* FP stuff takes up whole rest of struct, except c_ucode.  */
   intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
     (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
   /* Ucode is the last thing in the struct -- just before the end */
-  intcore->c_ucode =
-    bfd_h_get_32 (abfd,
-    intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+  intcore->c_ucode = H_GET_32 (abfd,
+                              (intcore->c_len
+                               - sizeof (extcore->c_ucode)
+                               + (unsigned char *) extcore));
 
   /* Supposedly the user stack grows downward from the bottom of kernel memory.
      Presuming that this remains true, this definition will work.  */
@@ -568,8 +569,7 @@ swapcore_solaris_bcp (abfd, ext, intcore)
 #define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
 #define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
   {
-    bfd_vma sp = bfd_h_get_32
-    (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+    bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
     if (sp < SPARC_USRSTACK_SPARC10)
       intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
     else
@@ -599,7 +599,7 @@ sunos4_core_file_p (abfd)
      bfd *abfd;
 {
   unsigned char longbuf[4];    /* Raw bytes of various header fields */
-  bfd_size_type core_size;
+  bfd_size_type core_size, amt;
   unsigned long core_mag;
   struct internal_sunos_core *core;
   char *extcore;
@@ -608,38 +608,41 @@ sunos4_core_file_p (abfd)
       struct sun_core_struct suncoredata;
       struct internal_sunos_core internal_sunos_core;
       char external_core[1];
-    }
-   *mergem;
+    } *mergem;
 
-  if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
-      sizeof (longbuf))
+  if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+      != sizeof (longbuf))
     return 0;
-  core_mag = bfd_h_get_32 (abfd, longbuf);
+  core_mag = H_GET_32 (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))
+  if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+      != sizeof (longbuf))
     return 0;
-  core_size = bfd_h_get_32 (abfd, longbuf);
+  core_size = H_GET_32 (abfd, longbuf);
   /* Sanity check */
   if (core_size > 20000)
     return 0;
 
-  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
     return 0;
 
-  mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
+  amt = core_size + sizeof (struct mergem);
+  mergem = (struct mergem *) bfd_zalloc (abfd, amt);
   if (mergem == NULL)
     return 0;
 
   extcore = mergem->external_core;
 
-  if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
+  if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
     {
+    loser:
       bfd_release (abfd, (char *) mergem);
+      abfd->tdata.any = NULL;
+      bfd_section_list_clear (abfd);
       return 0;
     }
 
@@ -660,47 +663,29 @@ sunos4_core_file_p (abfd)
       break;
     default:
       bfd_set_error (bfd_error_system_call);   /* FIXME */
-      bfd_release (abfd, (char *) mergem);
-      return 0;
+      goto loser;
     }
 
   abfd->tdata.sun_core_data = &mergem->suncoredata;
   abfd->tdata.sun_core_data->hdr = core;
 
-  /* create the sections.  This is raunchy, but bfd_close wants to reclaim
-     them */
-  core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  /* Create the sections.  */
+  core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
   if (core_stacksec (abfd) == NULL)
-    {
-    loser:
-      bfd_release (abfd, (char *) mergem);
-      return 0;
-    }
-  core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+    /* bfd_release frees everything allocated after it's arg.  */
+    goto loser;
+
+  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
   if (core_datasec (abfd) == NULL)
-    {
-    loser1:
-      bfd_release (abfd, core_stacksec (abfd));
-      goto loser;
-    }
-  core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+    goto loser;
+
+  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
   if (core_regsec (abfd) == NULL)
-    {
-    loser2:
-      bfd_release (abfd, core_datasec (abfd));
-      goto loser1;
-    }
-  core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
-  if (core_reg2sec (abfd) == NULL)
-    {
-      bfd_release (abfd, core_regsec (abfd));
-      goto loser2;
-    }
+    goto loser;
 
-  core_stacksec (abfd)->name = ".stack";
-  core_datasec (abfd)->name = ".data";
-  core_regsec (abfd)->name = ".reg";
-  core_reg2sec (abfd)->name = ".reg2";
+  core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
+  if (core_reg2sec (abfd) == NULL)
+    goto loser;
 
   core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
   core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
@@ -729,13 +714,6 @@ sunos4_core_file_p (abfd)
   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;
 }
 
@@ -764,7 +742,7 @@ sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
       return false;
     }
 
-  /* Solaris core files do not include an aouthdr. */
+  /* Solaris core files do not include an aouthdr.  */
   if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
     return true;
 
@@ -823,7 +801,7 @@ sunos4_set_sizes (abfd)
 #define MY_finish_dynamic_link 0
 #endif
 
-static CONST struct aout_backend_data sunos4_aout_backend =
+static const struct aout_backend_data sunos4_aout_backend =
 {
   0,                           /* zmagic files are not contiguous */
   1,                           /* text includes header */
This page took 0.029088 seconds and 4 git commands to generate.