This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Set architecture for NetBSD core files


It would make my life a lot easier if a netbsd-core BFD would have its
architecture set.  The attached patch accomplishes this, at least for
NetBSD/amd64, NetBSD/i386, NetBSD/sparc and NetBSD/sparc64 (and the
corresponding OpenBSD variants).

OK to check this in?  Or should I move the M_SPARC64_NETBSD and
M_X86_64_NETBSD #defines to libaout.h?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* netbsd-core.c: Update copyright years.
	(M_SPARC64_NETBSD, M_X86_64_NETBSD): New defines.
	(netbsd_core_file_p): Set architecture from machine ID.

Index: netbsd-core.c
===================================================================
RCS file: /cvs/src/src/bfd/netbsd-core.c,v
retrieving revision 1.8
diff -u -p -r1.8 netbsd-core.c
--- netbsd-core.c 1 Dec 2003 06:33:01 -0000 1.8
+++ netbsd-core.c 8 Feb 2004 23:07:55 -0000
@@ -1,6 +1,6 @@
 /* BFD back end for NetBSD style core files
    Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000, 2001,
-   2002
+   2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Paul Kranenburg, EUR
 
@@ -30,6 +30,11 @@ Foundation, Inc., 59 Temple Place - Suit
 #include <signal.h>
 #include <sys/core.h>
 
+/* Oops!  The NetBSD folks re-used M_MIPS1 for NetBSD/sparc64, and
+   M_MIPS2 for NetBSD/amd64.  */
+#define M_SPARC64_NETBSD	M_MIPS1
+#define M_X86_64_NETBSD		M_MIPS2
+
 /*
  * FIXME: On NetBSD/sparc CORE_FPU_OFFSET should be (sizeof (struct trapframe))
  */
@@ -158,6 +163,26 @@ netbsd_core_file_p (abfd)
 	  break;
 	}
 #endif
+    }
+
+  /* Set architecture from machine ID.  */
+  switch (CORE_GETMID (core))
+    {
+    case M_X86_64_NETBSD:
+      bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x86_64);
+      break;
+
+    case M_386_NETBSD:
+      bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_i386_i386);
+      break;
+
+    case M_SPARC_NETBSD:
+      bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
+      break;
+
+    case M_SPARC64_NETBSD:
+      bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc_v9);
+      break;
     }
 
   /* OK, we believe you.  You're a core file (sure, sure).  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]