This is the mail archive of the binutils-cvs@sourceware.org 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]

[binutils-gdb] Add support to readelf for reading NetBSD ELF core notes.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c6056a744af028824797e769ddb71927740be88a

commit c6056a744af028824797e769ddb71927740be88a
Author: Stephen Fisher <sfisher@panix.com>
Date:   Tue Oct 27 11:32:38 2015 +0000

    Add support to readelf for reading NetBSD ELF core notes.
    
    binutils * binutils.c (process_netbsd_elf_note): New function.
    	(process_note): Call the new function for NetBSD core notes.
    
    include	* common.h (NT_NETBSD_MARCH): Define.

Diff:
---
 binutils/ChangeLog    |  5 +++++
 binutils/readelf.c    | 38 ++++++++++++++++++++++++++++++++++++++
 include/elf/ChangeLog |  4 ++++
 include/elf/common.h  |  1 +
 4 files changed, 48 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 5cf05cc..f5627fc 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-27  Stephen Fisher  <sfisher@panix.com>
+
+	* binutils.c (process_netbsd_elf_note): New function.
+	(process_note): Call the new function for NetBSD core notes.
+
 2015-10-22  Hans-Peter Nilsson  <hp@bitrange.com>
 
 	* objcopy.c (setup_section): Don't omit bfd_copy_private_bfd_data
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 22cec2c..70a84e5 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -15365,6 +15365,40 @@ print_v850_note (Elf_Internal_Note * pnote)
   return 0;
 }
 
+static int 
+process_netbsd_elf_note (Elf_Internal_Note * pnote)
+{
+  unsigned int version;
+
+  switch (pnote->type)
+    {
+    case NT_NETBSD_IDENT:
+      version = byte_get ((unsigned char *) pnote->descdata, sizeof (version));
+      if ((version / 10000) % 100)
+        printf ("  NetBSD\t\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote->descsz,
+		version, version / 100000000, (version / 1000000) % 100,
+		(version / 10000) % 100 > 26 ? "Z" : "",
+		'A' + (version / 10000) % 26); 
+      else
+	printf ("  NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz,
+	        version, version / 100000000, (version / 1000000) % 100,
+		(version / 100) % 100); 
+      return 1;
+
+    case NT_NETBSD_MARCH:
+      printf ("  NetBSD\t0x%08lx\tMARCH <%s>\n", pnote->descsz,
+	      pnote->descdata);
+      return 1;
+
+    default:
+      break;
+    }
+
+  printf ("  NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n", pnote->descsz,
+	  pnote->type);
+  return 1;
+}
+
 static const char *
 get_netbsd_elfcore_note_type (unsigned e_type)
 {
@@ -15618,6 +15652,10 @@ process_note (Elf_Internal_Note * pnote)
     /* NetBSD-specific core file notes.  */
     nt = get_netbsd_elfcore_note_type (pnote->type);
 
+  else if (const_strneq (pnote->namedata, "NetBSD"))
+    /* NetBSD-specific core file notes.  */
+    return process_netbsd_elf_note (pnote);
+
   else if (strneq (pnote->namedata, "SPU/", 4))
     {
       /* SPU-specific core file notes.  */
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index 08b6701..8b354e1 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-27  Stephen Fisher  <sfisher@panix.com>
+
+	* common.h (NT_NETBSD_MARCH): Define.
+
 2015-10-22  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* x86-64.h (R_X86_64_GOTPCRELX): New.
diff --git a/include/elf/common.h b/include/elf/common.h
index bb15b7d..5c20c5e 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -642,6 +642,7 @@
 /* Values for NetBSD .note.netbsd.ident notes.  Note name is "NetBSD".  */
 
 #define NT_NETBSD_IDENT		1
+#define NT_NETBSD_MARCH		5
 
 /* Values for OpenBSD .note.openbsd.ident notes.  Note name is "OpenBSD".  */


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