Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / rs6000-core.c
index 0f0fcdcdf8287137246e4b770cf2b353599fef02..74bde846dec2b811bad8256dd578da78b7955f59 100644 (file)
@@ -1,5 +1,5 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright (C) 1990-2016 Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
    Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
    Archive support from Damon A. Permezel.
    Contributed by IBM Corporation and Cygnus Support.
@@ -109,7 +109,7 @@ typedef union
 #else
   struct core_dump new_dump;   /* For simpler coding.  */
 #endif
-#ifndef BFD64                   /* Use old only if gdb is 32-bit.  */
+#ifndef BFD64                  /* Use old only if gdb is 32-bit.  */
   struct core_dump old;                /* Old AIX 4.2- core dump, still used on
                                   4.3+ with appropriate SMIT config.  */
 #endif
@@ -135,9 +135,9 @@ typedef union
 
 #ifdef AIX_CORE_DUMPX_CORE
 # ifndef BFD64
-#  define CORE_NEW(c)        (!(c).old.c_entries)
+#  define CORE_NEW(c)  (!(c).old.c_entries)
 # else
-#  define CORE_NEW(c)   (!(c).new_dump.c_entries)
+#  define CORE_NEW(c)  1
 # endif
 #else
 # define CORE_NEW(c)   0
@@ -150,7 +150,7 @@ typedef union
    but that may not be the only such format version number.  */
 
 #ifdef AIX_5_CORE
-# define CORE_DUMPXX_VERSION   267312562
+# define CORE_DUMPXX_VERSION   267312562
 # define CNEW_IS_CORE_DUMPXX(c) ((c).new_dump.c_version == CORE_DUMPXX_VERSION)
 #else
 # define CNEW_IS_CORE_DUMPXX(c) 0
@@ -269,36 +269,35 @@ typedef union
    common.  */
 #ifdef AIX_CORE_DUMPX_CORE
 #define CORE_COMMONSZ  ((long) &((struct core_dumpx *) 0)->c_entries \
-                        + sizeof (((struct core_dumpx *) 0)->c_entries))
+                       + sizeof (((struct core_dumpx *) 0)->c_entries))
 #else
-#define CORE_COMMONSZ   ((int) &((struct core_dump *) 0)->c_entries \
-                       + sizeof (((struct core_dump *) 0)->c_entries)
+#define CORE_COMMONSZ  ((int) &((struct core_dump *) 0)->c_entries \
+                       + sizeof (((struct core_dump *) 0)->c_entries))
 #endif
 /* Define prototypes for certain functions, to avoid a compiler warning
    saying that they are missing.  */
 
-const bfd_target * rs6000coff_core_p (bfd *abfd);
-bfd_boolean rs6000coff_core_file_matches_executable_p (bfd *core_bfd,
-                                                       bfd *exec_bfd);
+bfd_cleanup rs6000coff_core_p (bfd *abfd);
+bool rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd);
 char * rs6000coff_core_file_failing_command (bfd *abfd);
 int rs6000coff_core_file_failing_signal (bfd *abfd);
 
 /* Try to read into CORE the header from the core file associated with ABFD.
    Return success.  */
 
-static bfd_boolean
+static bool
 read_hdr (bfd *abfd, CoreHdr *core)
 {
   bfd_size_type size;
 
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
-    return FALSE;
+    return false;
 
   /* Read the leading portion that old and new core dump structures have in
      common.  */
   size = CORE_COMMONSZ;
   if (bfd_bread (core, size, abfd) != size)
-    return FALSE;
+    return false;
 
   /* Read the trailing portion of the structure.  */
   if (CORE_NEW (*core))
@@ -332,7 +331,7 @@ make_bfd_asection (bfd *abfd, const char *name, flagword flags,
 /* Decide if a given bfd represents a `core' file or not. There really is no
    magic number or anything like, in rs6000coff.  */
 
-const bfd_target *
+bfd_cleanup
 rs6000coff_core_p (bfd *abfd)
 {
   CoreHdr core;
@@ -468,8 +467,7 @@ rs6000coff_core_p (bfd *abfd)
 
   /* Issue warning if the core file was truncated during writing.  */
   if (c_flag & CORE_TRUNC)
-    (*_bfd_error_handler) (_("%s: warning core file truncated"),
-                          bfd_get_filename (abfd));
+    _bfd_error_handler (_("%pB: warning core file truncated"), abfd);
 
   /* Allocate core file header.  */
 #ifndef BFD64
@@ -586,10 +584,10 @@ rs6000coff_core_p (bfd *abfd)
        /* If Large Memory Model is used, then the .data segment should start from
           BDATAORG which has been defined in the system header files. */
 
-        if (c_flag & CORE_BIGDATA)
-          core_dataorg = BDATAORG;
-        else
-          core_dataorg = CDATA_ADDR (c_datasize);
+       if (c_flag & CORE_BIGDATA)
+         core_dataorg = BDATAORG;
+       else
+         core_dataorg = CDATA_ADDR (c_datasize);
 
        if (!make_bfd_asection (abfd, ".data",
                                SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS,
@@ -656,7 +654,7 @@ rs6000coff_core_p (bfd *abfd)
 #ifndef BFD64
            size = CORE_NEW (core) ? sizeof (vminfo.new_dump) : sizeof (vminfo.old);
 #else
-            size = sizeof (vminfo.new_dump);
+           size = sizeof (vminfo.new_dump);
 #endif
            if (bfd_bread (&vminfo, size, abfd) != size)
              goto fail;
@@ -687,7 +685,7 @@ rs6000coff_core_p (bfd *abfd)
   }
 #endif
 
-  return abfd->xvec;           /* This is garbage for now.  */
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, abfd->tdata.any);
@@ -698,7 +696,7 @@ rs6000coff_core_p (bfd *abfd)
 
 /* Return `TRUE' if given core is from the given executable.  */
 
-bfd_boolean
+bool
 rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
 {
   CoreHdr core;
@@ -706,11 +704,11 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
   char *path, *s;
   size_t alloc;
   const char *str1, *str2;
-  bfd_boolean ret;
+  bool ret;
   file_ptr c_loader;
 
   if (!read_hdr (core_bfd, &core))
-    return FALSE;
+    return false;
 
   if (CORE_NEW (core))
     c_loader = CNEW_LOADER (core.new_dump);
@@ -725,12 +723,12 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
     size = (int) ((LdInfo *) 0)->l32.ldinfo_filename;
 
   if (bfd_seek (core_bfd, c_loader + size, SEEK_SET) != 0)
-    return FALSE;
+    return false;
 
   alloc = 100;
   path = bfd_malloc ((bfd_size_type) alloc);
   if (path == NULL)
-    return FALSE;
+    return false;
   s = path;
 
   while (1)
@@ -738,7 +736,7 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
       if (bfd_bread (s, (bfd_size_type) 1, core_bfd) != 1)
        {
          free (path);
-         return FALSE;
+         return false;
        }
       if (*s == '\0')
        break;
@@ -752,7 +750,7 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
          if (n == NULL)
            {
              free (path);
-             return FALSE;
+             return false;
            }
          s = n + (path - s);
          path = n;
@@ -760,16 +758,16 @@ rs6000coff_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
     }
 
   str1 = strrchr (path, '/');
-  str2 = strrchr (exec_bfd->filename, '/');
+  str2 = strrchr (bfd_get_filename (exec_bfd), '/');
 
   /* step over character '/' */
   str1 = str1 != NULL ? str1 + 1 : path;
-  str2 = str2 != NULL ? str2 + 1 : exec_bfd->filename;
+  str2 = str2 != NULL ? str2 + 1 : bfd_get_filename (exec_bfd);
 
   if (strcmp (str1, str2) == 0)
-    ret = TRUE;
+    ret = true;
   else
-    ret = FALSE;
+    ret = false;
 
   free (path);
 
This page took 0.046389 seconds and 4 git commands to generate.