bfd/
[binutils-gdb.git] / bfd / aoutf1.h
index ff02136562ca4ed3e3b4685b433291d30872bd47..4d66d87bc870c871e7c156b573e805a5743ea1ef 100644 (file)
@@ -1,6 +1,6 @@
 /* A.out "format 1" file handling code for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001
+   2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -75,15 +75,24 @@ The name put into the target vector.
 #define sunos_write_object_contents aout_32_sunos4_write_object_contents
 #endif
 
-static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-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 *));
-static char *sunos4_core_file_failing_command PARAMS ((bfd *));
-static int sunos4_core_file_failing_signal PARAMS ((bfd *));
-static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
-static boolean sunos4_set_sizes PARAMS ((bfd *));
+static bfd_boolean sunos_merge_private_bfd_data
+  PARAMS ((bfd *, bfd *));
+static void sunos_set_arch_mach
+  PARAMS ((bfd *, enum machine_type));
+static void choose_reloc_size
+  PARAMS ((bfd *));
+static bfd_boolean sunos_write_object_contents
+  PARAMS ((bfd *));
+static const bfd_target *sunos4_core_file_p
+  PARAMS ((bfd *));
+static char *sunos4_core_file_failing_command
+  PARAMS ((bfd *));
+static int sunos4_core_file_failing_signal
+  PARAMS ((bfd *));
+static bfd_boolean sunos4_core_file_matches_executable_p
+  PARAMS ((bfd *, bfd *));
+static bfd_boolean sunos4_set_sizes
+  PARAMS ((bfd *));
 
 /* Merge backend data into the output file.
    This is necessary on sparclet-aout where we want the resultant machine
@@ -91,13 +100,13 @@ static boolean sunos4_set_sizes PARAMS ((bfd *));
 
 #define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
 
-static boolean
+static bfd_boolean
 sunos_merge_private_bfd_data (ibfd, obfd)
      bfd *ibfd, *obfd;
 {
   if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
       || bfd_get_flavour (obfd) != bfd_target_aout_flavour)
-    return true;
+    return TRUE;
 
   if (bfd_get_arch (obfd) == bfd_arch_sparc)
     {
@@ -105,7 +114,7 @@ sunos_merge_private_bfd_data (ibfd, obfd)
        bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
     }
 
-  return true;
+  return TRUE;
 }
 
 /* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,
@@ -207,7 +216,7 @@ choose_reloc_size (abfd)
    aout_64_sunos4_write_object_contents or
    aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE.  */
 
-static boolean
+static bfd_boolean
 sunos_write_object_contents (abfd)
      bfd *abfd;
 {
@@ -264,7 +273,7 @@ sunos_write_object_contents (abfd)
 
   WRITE_HEADERS (abfd, execp);
 
-  return true;
+  return TRUE;
 }
 \f
 /* core files */
@@ -641,6 +650,8 @@ sunos4_core_file_p (abfd)
     {
     loser:
       bfd_release (abfd, (char *) mergem);
+      abfd->tdata.any = NULL;
+      bfd_section_list_clear (abfd);
       return 0;
     }
 
@@ -667,31 +678,24 @@ sunos4_core_file_p (abfd)
   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 */
-  amt = sizeof (asection);
-  core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, amt);
+  /* Create the sections.  */
+  core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
   if (core_stacksec (abfd) == NULL)
     /* bfd_release frees everything allocated after it's arg.  */
     goto loser;
 
-  core_datasec (abfd) = (asection *) bfd_zalloc (abfd, amt);
+  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
   if (core_datasec (abfd) == NULL)
     goto loser;
 
-  core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
+  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
   if (core_regsec (abfd) == NULL)
     goto loser;
 
-  core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, amt);
+  core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
   if (core_reg2sec (abfd) == NULL)
     goto loser;
 
-  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 + SEC_HAS_CONTENTS;
   core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
   core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
@@ -719,13 +723,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;
 }
 
@@ -743,7 +740,7 @@ sunos4_core_file_failing_signal (abfd)
   return core_hdr (abfd)->hdr->c_signo;
 }
 
-static boolean
+static bfd_boolean
 sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
      bfd *core_bfd;
      bfd *exec_bfd;
@@ -751,37 +748,37 @@ sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
   if (core_bfd->xvec != exec_bfd->xvec)
     {
       bfd_set_error (bfd_error_system_call);
-      return false;
+      return FALSE;
     }
 
   /* Solaris core files do not include an aouthdr.  */
   if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
-    return true;
+    return TRUE;
 
   return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
                  (char *) exec_hdr (exec_bfd),
-                 sizeof (struct internal_exec)) == 0) ? true : false;
+                 sizeof (struct internal_exec)) == 0);
 }
 
 #define MY_set_sizes sunos4_set_sizes
-static boolean
+static bfd_boolean
 sunos4_set_sizes (abfd)
      bfd *abfd;
 {
   switch (bfd_get_arch (abfd))
     {
     default:
-      return false;
+      return FALSE;
     case bfd_arch_sparc:
       adata (abfd).page_size = 0x2000;
       adata (abfd).segment_size = 0x2000;
       adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-      return true;
+      return TRUE;
     case bfd_arch_m68k:
       adata (abfd).page_size = 0x2000;
       adata (abfd).segment_size = 0x20000;
       adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-      return true;
+      return TRUE;
     }
 }