OSDN Git Service

mips64*-*-toppers* support.
[pf3gnuchains/pf3gnuchains3x.git] / bfd / netbsd-core.c
index f021928..397f1d0 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back end for NetBSD style core files
    Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005
+   2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    Written by Paul Kranenburg, EUR
 
@@ -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,
 
    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 "bfd.h"
 #include "libbfd.h"
 #include "libaout.h"           /* BFD a.out internal data structures.  */
 
 
 /* Offset of StackGhost cookie within `struct md_coredump' on
    OpenBSD/sparc.  */
-#define CORE_WCOOKIE_OFFSET    344
+#define SPARC_WCOOKIE_OFFSET   344
+
+/* Offset of StackGhost cookie within `struct md_coredump' on
+   OpenBSD/sparc64.  */
+#define SPARC64_WCOOKIE_OFFSET 832
+
+#define netbsd_core_file_matches_executable_p generic_core_file_matches_executable_p
 
 struct netbsd_core_struct
 {
@@ -120,33 +127,49 @@ netbsd_core_file_p (bfd *abfd)
          flags = SEC_ALLOC + SEC_HAS_CONTENTS;
          break;
        }
-      asect = bfd_make_section_anyway (abfd, sname);
+      asect = bfd_make_section_anyway_with_flags (abfd, sname, flags);
       if (asect == NULL)
        goto punt;
 
-      asect->flags = flags;
       asect->size = coreseg.c_size;
       asect->vma = coreseg.c_addr;
       asect->filepos = offset;
       asect->alignment_power = 2;
 
-      if (CORE_GETMID (core) == M_SPARC_NETBSD
-         && CORE_GETFLAG (coreseg) == CORE_CPU
-         && coreseg.c_size > CORE_WCOOKIE_OFFSET)
+      if (CORE_GETFLAG (coreseg) == CORE_CPU)
        {
-         /* Truncate the .reg section.  */
-         asect->size = CORE_WCOOKIE_OFFSET;
-
-         /* And create the .wcookie section.  */
-         asect = bfd_make_section_anyway (abfd, ".wcookie");
-         if (asect == NULL)
-           goto punt;
-
-         asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
-         asect->size = 4;
-         asect->vma = 0;
-         asect->filepos = offset + CORE_WCOOKIE_OFFSET;
-         asect->alignment_power = 2;
+         bfd_size_type wcookie_offset;
+
+         switch (CORE_GETMID (core))
+           {
+           case M_SPARC_NETBSD:
+             wcookie_offset = SPARC_WCOOKIE_OFFSET;
+             break;
+           case M_SPARC64_OPENBSD:
+             wcookie_offset = SPARC64_WCOOKIE_OFFSET;
+             break;
+           default:
+             wcookie_offset = 0;
+             break;
+           }
+
+         if (wcookie_offset > 0 && coreseg.c_size > wcookie_offset)
+           {
+             /* Truncate the .reg section.  */
+             asect->size = wcookie_offset;
+
+             /* And create the .wcookie section.  */
+             flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+             asect = bfd_make_section_anyway_with_flags (abfd, ".wcookie",
+                                                         flags);
+             if (asect == NULL)
+               goto punt;
+
+             asect->size = coreseg.c_size - wcookie_offset;
+             asect->vma = 0;
+             asect->filepos = offset + wcookie_offset;
+             asect->alignment_power = 2;
+           }
        }
 
       offset += coreseg.c_size;
@@ -226,14 +249,6 @@ netbsd_core_file_failing_signal (bfd *abfd)
   /*return core_signal (abfd);*/
   return abfd->tdata.netbsd_core_data->core.c_signo;
 }
-
-static bfd_boolean
-netbsd_core_file_matches_executable_p  (bfd *core_bfd ATTRIBUTE_UNUSED,
-                                       bfd *exec_bfd ATTRIBUTE_UNUSED)
-{
-  /* FIXME, We have no way of telling at this point.  */
-  return TRUE;
-}
 \f
 /* If somebody calls any byte-swapping routines, shoot them.  */