OSDN Git Service

mips64*-*-toppers* support.
[pf3gnuchains/pf3gnuchains3x.git] / bfd / aix5ppc-core.c
index 6b588ba..7b0695a 100644 (file)
@@ -1,5 +1,5 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright 2001, 2002, 2003, 2004, 2005
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Written by Tom Rix
    Contributed by Red Hat Inc.
@@ -8,7 +8,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
-   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,
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
-
-#ifdef AIX_5_CORE
-
 #include "sysdep.h"
-#include "libbfd.h"
+#include "bfd.h"
 
 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 *);
 
+#ifdef AIX_5_CORE
+
+#include "libbfd.h"
+
 /* Aix 5.1 system include file.  */
 
 /* Need to define this macro so struct ld_info64 get included.  */
@@ -40,6 +40,10 @@ int xcoff64_core_file_failing_signal (bfd *);
 #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) \
@@ -48,6 +52,8 @@ int xcoff64_core_file_failing_signal (bfd *);
 const bfd_target *
 xcoff64_core_p (bfd *abfd)
 {
+  enum bfd_architecture arch;
+  unsigned long mach;
   struct core_dumpxx core, *new_core_hdr;
   struct stat statbuf;
   asection *sec;
@@ -56,6 +62,7 @@ xcoff64_core_p (bfd *abfd)
   bfd_size_type i;
   struct vm_infox vminfo;
   const bfd_target *return_value = NULL;
+  flagword flags;
 
   /* Get the header.  */
   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
@@ -117,21 +124,21 @@ xcoff64_core_p (bfd *abfd)
   abfd->tdata.any = new_core_hdr;
 
   /* .stack section.  */
-  sec = bfd_make_section_anyway (abfd, ".stack");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   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");
+  flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
   sec->size = sizeof (struct __context64);
   sec->vma = 0;
   sec->filepos = 0;
@@ -141,11 +148,11 @@ xcoff64_core_p (bfd *abfd)
      To actually find out how long this section is in this particular
      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");
+  flags = SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_HAS_CONTENTS;
   sec->size = core.c_lsize;
   sec->vma = 0;
   sec->filepos = core.c_loader;
@@ -155,11 +162,11 @@ xcoff64_core_p (bfd *abfd)
      regions.  */
 
   /* .data section from executable.  */
-  sec = bfd_make_section_anyway (abfd, ".data");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
   sec->filepos = core.c_data;
@@ -178,11 +185,11 @@ xcoff64_core_p (bfd *abfd)
 
       if (ldinfo.ldinfo_core)
        {
-         sec = bfd_make_section_anyway (abfd, ".data");
+         flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+         sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
          if (NULL == sec)
            return return_value;
 
-         sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec->size = ldinfo.ldinfo_datasize;
          sec->vma = ldinfo.ldinfo_dataorg;
          sec->filepos = ldinfo.ldinfo_core;
@@ -206,17 +213,22 @@ xcoff64_core_p (bfd *abfd)
 
       if (vminfo.vminfo_offset)
        {
-         sec = bfd_make_section_anyway (abfd, ".vmdata");
+         flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+         sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
          if (NULL == sec)
            return return_value;
 
-         sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec->size = vminfo.vminfo_size;
          sec->vma = vminfo.vminfo_addr;
          sec->filepos = vminfo.vminfo_offset;
        }
     }
 
+  /* Set the architecture and machine.  */
+  arch = DEFAULT_ARCHITECTURE;
+  mach = DEFAULT_MACHINE;
+  bfd_default_set_arch_mach (abfd, arch, mach);
+
   return_value = (bfd_target *) abfd->xvec;    /* This is garbage for now.  */
 
  xcoff64_core_p_error:
@@ -318,11 +330,6 @@ xcoff64_core_file_failing_signal (bfd *abfd)
 
 #else /* AIX_5_CORE */
 
-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 (bfd *abfd ATTRIBUTE_UNUSED)
 {
@@ -331,10 +338,9 @@ xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
 }
 
 bfd_boolean
-xcoff64_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
-                                       bfd *exec_bfd ATTRIBUTE_UNUSED)
+xcoff64_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
 {
-  return FALSE;
+  return generic_core_file_matches_executable_p (core_bfd, exec_bfd);
 }
 
 char *