RISC-V: Don't assume the priv attributes are in order when handling them.
[deliverable/binutils-gdb.git] / bfd / aix5ppc-core.c
index ef1447b946fe84546c1a86af28356a20fcedb82c..ba8a4e0524082994bde27078a91d94ef1f406045 100644 (file)
@@ -1,6 +1,5 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
    Written by Tom Rix
    Contributed by Red Hat Inc.
 
    Written by Tom Rix
    Contributed by Red Hat Inc.
 
@@ -8,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -24,7 +23,7 @@
 #include "sysdep.h"
 #include "bfd.h"
 
 #include "sysdep.h"
 #include "bfd.h"
 
-const bfd_target *xcoff64_core_p (bfd *);
+bfd_cleanup 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 *);
 bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
 char *xcoff64_core_file_failing_command (bfd *);
 int xcoff64_core_file_failing_signal (bfd *);
@@ -40,14 +39,20 @@ int xcoff64_core_file_failing_signal (bfd *);
 #include <sys/ldr.h>
 #include <core.h>
 
 #include <sys/ldr.h>
 #include <core.h>
 
+/* The default architecture and machine for matching core files.  */
+#define DEFAULT_ARCHITECTURE   bfd_arch_powerpc
+#define DEFAULT_MACHINE                bfd_mach_ppc_620
+
 #define        core_hdr(abfd)          ((struct core_dumpxx *) abfd->tdata.any)
 
 #define CHECK_FILE_OFFSET(s, v) \
   ((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
 
 #define        core_hdr(abfd)          ((struct core_dumpxx *) abfd->tdata.any)
 
 #define CHECK_FILE_OFFSET(s, v) \
   ((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
 
-const bfd_target *
+bfd_cleanup
 xcoff64_core_p (bfd *abfd)
 {
 xcoff64_core_p (bfd *abfd)
 {
+  enum bfd_architecture arch;
+  unsigned long mach;
   struct core_dumpxx core, *new_core_hdr;
   struct stat statbuf;
   asection *sec;
   struct core_dumpxx core, *new_core_hdr;
   struct stat statbuf;
   asection *sec;
@@ -55,7 +60,6 @@ xcoff64_core_p (bfd *abfd)
   bfd_vma ld_offset;
   bfd_size_type i;
   struct vm_infox vminfo;
   bfd_vma ld_offset;
   bfd_size_type i;
   struct vm_infox vminfo;
-  const bfd_target *return_value = NULL;
   flagword flags;
 
   /* Get the header.  */
   flagword flags;
 
   /* Get the header.  */
@@ -104,12 +108,12 @@ xcoff64_core_p (bfd *abfd)
     {
       bfd_set_error (bfd_error_file_truncated);
 
     {
       bfd_set_error (bfd_error_file_truncated);
 
-      return return_value;
+      return NULL;
     }
 
   new_core_hdr = 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;
+    return NULL;
 
   memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
   /* The core_hdr() macro is no longer used here because it would
 
   memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
   /* The core_hdr() macro is no longer used here because it would
@@ -121,7 +125,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
   if (NULL == sec)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_size;
   sec->vma = core.c_stackorg;
 
   sec->size = core.c_size;
   sec->vma = core.c_stackorg;
@@ -131,7 +135,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
   sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (NULL == sec)
   flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
   sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = sizeof (struct __context64);
   sec->vma = 0;
 
   sec->size = sizeof (struct __context64);
   sec->vma = 0;
@@ -145,7 +149,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
   if (NULL == sec)
   flags = SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_lsize;
   sec->vma = 0;
 
   sec->size = core.c_lsize;
   sec->vma = 0;
@@ -159,7 +163,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (NULL == sec)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
 
   sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
@@ -171,18 +175,18 @@ xcoff64_core_p (bfd *abfd)
   while (1)
     {
       if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0)
   while (1)
     {
       if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0)
-       return return_value;
+       return NULL;
 
       if (sizeof (struct __ld_info64) !=
          bfd_bread (&ldinfo, sizeof (struct __ld_info64), abfd))
 
       if (sizeof (struct __ld_info64) !=
          bfd_bread (&ldinfo, sizeof (struct __ld_info64), abfd))
-       return return_value;
+       return NULL;
 
       if (ldinfo.ldinfo_core)
        {
          flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
          if (NULL == sec)
 
       if (ldinfo.ldinfo_core)
        {
          flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
          if (NULL == sec)
-           return return_value;
+           return NULL;
 
          sec->size = ldinfo.ldinfo_datasize;
          sec->vma = ldinfo.ldinfo_dataorg;
 
          sec->size = ldinfo.ldinfo_datasize;
          sec->vma = ldinfo.ldinfo_dataorg;
@@ -198,19 +202,19 @@ xcoff64_core_p (bfd *abfd)
   if (core.c_vmregions)
     {
       if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0)
   if (core.c_vmregions)
     {
       if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0)
-       return return_value;
+       return NULL;
 
       for (i = 0; i < core.c_vmregions; i++)
        if (sizeof (struct vm_infox) !=
            bfd_bread (&vminfo, sizeof (struct vm_infox), abfd))
 
       for (i = 0; i < core.c_vmregions; i++)
        if (sizeof (struct vm_infox) !=
            bfd_bread (&vminfo, sizeof (struct vm_infox), abfd))
-         return return_value;
+         return NULL;
 
       if (vminfo.vminfo_offset)
        {
          flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
          if (NULL == sec)
 
       if (vminfo.vminfo_offset)
        {
          flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
          if (NULL == sec)
-           return return_value;
+           return NULL;
 
          sec->size = vminfo.vminfo_size;
          sec->vma = vminfo.vminfo_addr;
 
          sec->size = vminfo.vminfo_size;
          sec->vma = vminfo.vminfo_addr;
@@ -218,13 +222,18 @@ xcoff64_core_p (bfd *abfd)
        }
     }
 
        }
     }
 
-  return_value = (bfd_target *) abfd->xvec;    /* This is garbage for now.  */
+  /* Set the architecture and machine.  */
+  arch = DEFAULT_ARCHITECTURE;
+  mach = DEFAULT_MACHINE;
+  bfd_default_set_arch_mach (abfd, arch, mach);
+
+  return _bfd_no_cleanup;
 
  xcoff64_core_p_error:
   if (bfd_get_error () != bfd_error_system_call)
     bfd_set_error (bfd_error_wrong_format);
 
 
  xcoff64_core_p_error:
   if (bfd_get_error () != bfd_error_system_call)
     bfd_set_error (bfd_error_wrong_format);
 
-  return return_value;
+  return NULL;
 }
 
 /* Return `TRUE' if given core is from the given executable.  */
 }
 
 /* Return `TRUE' if given core is from the given executable.  */
@@ -279,11 +288,11 @@ xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
     }
 
   str1 = strrchr (path, '/');
     }
 
   str1 = strrchr (path, '/');
-  str2 = strrchr (exec_bfd->filename, '/');
+  str2 = strrchr (bfd_get_filename (exec_bfd), '/');
 
   /* Step over character '/'.  */
   str1 = str1 != NULL ? str1 + 1 : path;
 
   /* 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)
     return_value = TRUE;
 
   if (strcmp (str1, str2) == 0)
     return_value = TRUE;
@@ -319,7 +328,7 @@ xcoff64_core_file_failing_signal (bfd *abfd)
 
 #else /* AIX_5_CORE */
 
 
 #else /* AIX_5_CORE */
 
-const bfd_target *
+bfd_cleanup
 xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
 {
   bfd_set_error (bfd_error_wrong_format);
 xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
 {
   bfd_set_error (bfd_error_wrong_format);
This page took 0.128967 seconds and 4 git commands to generate.