PR 1147
[deliverable/binutils-gdb.git] / bfd / aix5ppc-core.c
index 12f4917b70296af2dc782c4646e3cb74d70591da..89b6d8afe58afef5646bbf8863b06bd056f5166a 100644 (file)
@@ -1,8 +1,8 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright 2001, 2002
+   Copyright 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Tom Rix
-   Contributed by Redhat.
+   Contributed by Red Hat Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -18,8 +18,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 #include "bfd.h"
 
 #include "sysdep.h"
 #include "libbfd.h"
 
-const bfd_target * xcoff64_core_p PARAMS ((bfd *));
-boolean            xcoff64_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
-char *             xcoff64_core_file_failing_command PARAMS ((bfd *));
-int                xcoff64_core_file_failing_signal PARAMS ((bfd *));
+const bfd_target *xcoff64_core_p (bfd *);
+bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
+char *xcoff64_core_file_failing_command (bfd *);
+int xcoff64_core_file_failing_signal (bfd *);
 
 /* Aix 5.1 system include file.  */
 
@@ -46,8 +46,7 @@ int                xcoff64_core_file_failing_signal PARAMS ((bfd *));
   ((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
 
 const bfd_target *
-xcoff64_core_p (abfd)
-     bfd *abfd;
+xcoff64_core_p (bfd *abfd)
 {
   struct core_dumpxx core, *new_core_hdr;
   struct stat statbuf;
@@ -62,11 +61,11 @@ xcoff64_core_p (abfd)
   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
     goto xcoff64_core_p_error;
 
-  if (sizeof (struct core_dumpxx) 
-      != bfd_read (&core, sizeof (struct core_dumpxx), 1, abfd))
+  if (sizeof (struct core_dumpxx)
+      != bfd_bread (&core, sizeof (struct core_dumpxx), abfd))
     goto xcoff64_core_p_error;
 
-  if (bfd_stat (abfd, &statbuf) < 0) 
+  if (bfd_stat (abfd, &statbuf) < 0)
     goto xcoff64_core_p_error;
 
   /* Sanity checks
@@ -82,24 +81,24 @@ xcoff64_core_p (abfd)
      See rs6000-core.c for comment on size of core
      If there isn't enough of a real core file, bail.  */
 
-  if ((CORE_VERSION_1 != (core.c_flag & CORE_VERSION_1)) 
-      || (0 != core.c_entries) 
-      || (! (IS_PROC64 (&core.c_u.U_proc))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_fdsinfox))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader + core.c_lsize))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_thr))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_segregion))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack + core.c_size))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_data))) 
-      || ((CHECK_FILE_OFFSET (statbuf, core.c_data + core.c_datasize))) 
-      || (! (core.c_flag & UBLOCK_VALID)) 
-      || (! (core.c_flag & LE_VALID))) 
+  if ((CORE_VERSION_1 != (core.c_flag & CORE_VERSION_1))
+      || (0 != core.c_entries)
+      || (! (IS_PROC64 (&core.c_u.U_proc)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_fdsinfox)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_loader + core.c_lsize)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_thr)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_segregion)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_stack + core.c_size)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_data)))
+      || ((CHECK_FILE_OFFSET (statbuf, core.c_data + core.c_datasize)))
+      || (! (core.c_flag & UBLOCK_VALID))
+      || (! (core.c_flag & LE_VALID)))
     goto xcoff64_core_p_error;
 
-  /* Check for trucated stack or general truncating.  */
-  if ((! (core.c_flag & USTACK_VALID)) 
+  /* Check for truncated stack or general truncating.  */
+  if ((! (core.c_flag & USTACK_VALID))
       || (core.c_flag & CORE_TRUNC))
     {
       bfd_set_error (bfd_error_file_truncated);
@@ -107,9 +106,8 @@ xcoff64_core_p (abfd)
       return return_value;
     }
 
-  new_core_hdr = (struct core_dumpxx *)
-    bfd_zalloc (abfd, sizeof (struct core_dumpxx));
-  if (NULL == new_core_hdr) 
+  new_core_hdr = bfd_zalloc (abfd, sizeof (struct core_dumpxx));
+  if (NULL == new_core_hdr)
     return return_value;
 
   memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
@@ -117,72 +115,72 @@ xcoff64_core_p (abfd)
 
   /* .stack section.  */
   sec = bfd_make_section_anyway (abfd, ".stack");
-  if (NULL == sec) 
+  if (NULL == sec)
     return return_value;
 
   sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
-  sec->_raw_size = core.c_size;
+  sec->size = core.c_size;
   sec->vma = core.c_stackorg;
   sec->filepos = core.c_stack;
 
   /* .reg section for all registers.  */
   sec = bfd_make_section_anyway (abfd, ".reg");
-  if (NULL == sec) 
+  if (NULL == sec)
     return return_value;
 
   sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-  sec->_raw_size = sizeof (struct __context64);
+  sec->size = sizeof (struct __context64);
   sec->vma = 0;
   sec->filepos = 0;
   sec->contents = (bfd_byte *)&new_core_hdr->c_flt.r64;
 
   /* .ldinfo section.
      To actually find out how long this section is in this particular
-     core dump would require going down the whole list of struct 
+     core dump would require going down the whole list of struct
      ld_info's.   See if we can just fake it.  */
   sec = bfd_make_section_anyway (abfd, ".ldinfo");
   if (NULL == sec)
     return return_value;
 
   sec->flags = SEC_HAS_CONTENTS;
-  sec->_raw_size = core.c_lsize;
+  sec->size = core.c_lsize;
   sec->vma = 0;
   sec->filepos = core.c_loader;
 
   /* AIX 4 adds data sections from loaded objects to the core file,
      which can be found by examining ldinfo, and anonymously mmapped
      regions.  */
-  
+
   /* .data section from executable.  */
   sec = bfd_make_section_anyway (abfd, ".data");
-  if (NULL == sec) 
+  if (NULL == sec)
     return return_value;
 
   sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
-  sec->_raw_size = core.c_datasize;
+  sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
   sec->filepos = core.c_data;
 
   /* .data sections from loaded objects.  */
   ld_offset = core.c_loader;
-       
-  while (1) 
+
+  while (1)
     {
-      if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0) 
+      if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0)
        return return_value;
 
       if (sizeof (struct __ld_info64) !=
-         bfd_read (&ldinfo, sizeof (struct __ld_info64), 1, abfd)) 
+         bfd_bread (&ldinfo, sizeof (struct __ld_info64), abfd))
        return return_value;
 
-      if (ldinfo.ldinfo_core) 
+      if (ldinfo.ldinfo_core)
        {
          sec = bfd_make_section_anyway (abfd, ".data");
-         if (NULL == sec) 
+         if (NULL == sec)
            return return_value;
 
          sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
-         sec->_raw_size = ldinfo.ldinfo_datasize;
+         sec->size = ldinfo.ldinfo_datasize;
          sec->vma = ldinfo.ldinfo_dataorg;
          sec->filepos = ldinfo.ldinfo_core;
        }
@@ -193,84 +191,82 @@ xcoff64_core_p (abfd)
     }
 
   /* .vmdata sections from anonymously mmapped regions.  */
-  if (core.c_vmregions) 
+  if (core.c_vmregions)
     {
-      if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0) 
+      if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0)
        return return_value;
 
-      for (i = 0; i < core.c_vmregions; i++) 
+      for (i = 0; i < core.c_vmregions; i++)
        if (sizeof (struct vm_infox) !=
-           bfd_read (&vminfo, sizeof (struct vm_infox), 1, abfd)) 
+           bfd_bread (&vminfo, sizeof (struct vm_infox), abfd))
          return return_value;
 
-      if (vminfo.vminfo_offset) 
+      if (vminfo.vminfo_offset)
        {
          sec = bfd_make_section_anyway (abfd, ".vmdata");
-         if (NULL == sec) 
+         if (NULL == sec)
            return return_value;
 
          sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
-         sec->_raw_size = vminfo.vminfo_size;
+         sec->size = vminfo.vminfo_size;
          sec->vma = vminfo.vminfo_addr;
          sec->filepos = vminfo.vminfo_offset;
        }
     }
 
-  return_value = abfd->xvec;   /* This is garbage for now.  */
-       
+  return_value = (bfd_target *) abfd->xvec;    /* This is garbage for now.  */
+
  xcoff64_core_p_error:
-  if (bfd_get_error () != bfd_error_system_call) 
+  if (bfd_get_error () != bfd_error_system_call)
     bfd_set_error (bfd_error_wrong_format);
-  
+
   return return_value;
 }
 
-/* Return `true' if given core is from the given executable.  */
+/* Return `TRUE' if given core is from the given executable.  */
 
-boolean
-xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
-     bfd *core_bfd;
-     bfd *exec_bfd;
+bfd_boolean
+xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
 {
   struct core_dumpxx core;
   char *path, *s;
   size_t alloc;
   const char *str1, *str2;
-  boolean return_value = false;
+  bfd_boolean return_value = FALSE;
 
   /* Get the header.  */
-  if (bfd_seek (core_bfd, 0, SEEK_SET) != 0) 
+  if (bfd_seek (core_bfd, 0, SEEK_SET) != 0)
     return return_value;
-       
+
   if (sizeof (struct core_dumpxx) !=
-      bfd_read (&core, sizeof (struct core_dumpxx), 1, core_bfd)) 
+      bfd_bread (&core, sizeof (struct core_dumpxx), core_bfd))
     return return_value;
 
-  if (bfd_seek (core_bfd, core.c_loader, SEEK_SET) != 0) 
+  if (bfd_seek (core_bfd, core.c_loader, SEEK_SET) != 0)
     return return_value;
 
   alloc = 100;
   path = bfd_malloc (alloc);
-  if (path == NULL) 
+  if (path == NULL)
     return return_value;
 
   s = path;
 
   while (1)
     {
-      if (bfd_read (s, 1, 1, core_bfd) != 1)
+      if (bfd_bread (s, 1, core_bfd) != 1)
        goto xcoff64_core_file_matches_executable_p_end_1;
 
       if (*s == '\0')
        break;
       ++s;
-      if (s == path + alloc) 
+      if (s == path + alloc)
        {
          char *n;
 
          alloc *= 2;
          n = bfd_realloc (path, alloc);
-         if (n == NULL) 
+         if (n == NULL)
            goto xcoff64_core_file_matches_executable_p_end_1;
 
          s = n + (path - s);
@@ -285,8 +281,8 @@ xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
   str1 = str1 != NULL ? str1 + 1 : path;
   str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
 
-  if (strcmp (str1, str2) == 0) 
-    return_value = true;
+  if (strcmp (str1, str2) == 0)
+    return_value = TRUE;
 
  xcoff64_core_file_matches_executable_p_end_1:
   free (path);
@@ -294,26 +290,24 @@ xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
 }
 
 char *
-xcoff64_core_file_failing_command (abfd)
-     bfd *abfd;
+xcoff64_core_file_failing_command (bfd *abfd)
 {
   struct core_dumpxx *c = core_hdr (abfd);
   char *return_value = 0;
 
-  if (NULL != c) 
+  if (NULL != c)
     return_value = c->c_u.U_proc.pi_comm;
 
   return return_value;
 }
 
 int
-xcoff64_core_file_failing_signal (abfd)
-     bfd *abfd;
+xcoff64_core_file_failing_signal (bfd *abfd)
 {
   struct core_dumpxx *c = core_hdr (abfd);
   int return_value = 0;
 
-  if (NULL != c) 
+  if (NULL != c)
     return_value = c->c_signo;
 
   return return_value;
@@ -321,37 +315,33 @@ xcoff64_core_file_failing_signal (abfd)
 
 #else /* AIX_5_CORE */
 
-const bfd_target * xcoff64_core_p PARAMS ((bfd *));
-boolean            xcoff64_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
-char *             xcoff64_core_file_failing_command PARAMS ((bfd *));
-int                xcoff64_core_file_failing_signal PARAMS ((bfd *));
+const bfd_target *xcoff64_core_p  (bfd *);
+bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
+char *xcoff64_core_file_failing_command (bfd *);
+int xcoff64_core_file_failing_signal (bfd *);
 
 const bfd_target *
-xcoff64_core_p (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
 {
   bfd_set_error (bfd_error_wrong_format);
   return 0;
 }
 
-boolean
-xcoff64_core_file_matches_executable_p (core_bfd, exec_bfd)
-     bfd *core_bfd ATTRIBUTE_UNUSED;
-     bfd *exec_bfd ATTRIBUTE_UNUSED;
+bfd_boolean
+xcoff64_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
+                                       bfd *exec_bfd ATTRIBUTE_UNUSED)
 {
-  return false;
+  return FALSE;
 }
 
 char *
-xcoff64_core_file_failing_command (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+xcoff64_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return 0;
 }
 
 int
-xcoff64_core_file_failing_signal (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+xcoff64_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return 0;
 }
This page took 0.029147 seconds and 4 git commands to generate.