Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 2013 17:25:50 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r253451 - in head/contrib/binutils: binutils include/elf
Message-ID:  <201307181725.r6IHPoJT003913@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu Jul 18 17:25:50 2013
New Revision: 253451
URL: http://svnweb.freebsd.org/changeset/base/253451

Log:
  Handle FreeBSD-specific ELF notes
  
  Add a function to return the specific type, when the note's Name field is
  'FreeBSD'.
  
  r249558 added FreeBSD-specific ELF note types that reuse type numbers of
  existing generic / Linux types.  This caused 'readelf -n' to produce
  incorrect output on FreeBSD core files.
  
  Sponsored by:	DARPA, AFRL
  MFC after:	3 days

Modified:
  head/contrib/binutils/binutils/readelf.c
  head/contrib/binutils/include/elf/common.h

Modified: head/contrib/binutils/binutils/readelf.c
==============================================================================
--- head/contrib/binutils/binutils/readelf.c	Thu Jul 18 15:17:11 2013	(r253450)
+++ head/contrib/binutils/binutils/readelf.c	Thu Jul 18 17:25:50 2013	(r253451)
@@ -9103,8 +9103,6 @@ get_note_type (unsigned e_type)
 	return _("NT_FPREGS (floating point registers)");
       case NT_PSINFO:
 	return _("NT_PSINFO (psinfo structure)");
-      case NT_THRMISC:
-	return _("NT_THRMISC (thrmisc structure)");
       case NT_LWPSTATUS:
 	return _("NT_LWPSTATUS (lwpstatus_t structure)");
       case NT_LWPSINFO:
@@ -9130,6 +9128,39 @@ get_note_type (unsigned e_type)
 }
 
 static const char *
+get_freebsd_elfcore_note_type (unsigned e_type)
+{
+  if (elf_header.e_type == ET_CORE)
+    switch (e_type)
+      {
+      case NT_THRMISC:
+	return _("NT_THRMISC (thrmisc structure)");
+      case NT_PROCSTAT_PROC:
+	return _("NT_PROCSTAT_PROC (proc data)");
+      case NT_PROCSTAT_FILES:
+	return _("NT_PROCSTAT_FILES (files data)");
+      case NT_PROCSTAT_VMMAP:
+	return _("NT_PROCSTAT_VMMAP: (vmmap data)");
+      case NT_PROCSTAT_GROUPS:
+	return _("NT_PROCSTAT_GROUPS: (groups data)");
+      case NT_PROCSTAT_UMASK:
+	return _("NT_PROCSTAT_UMASK: (umask data)");
+      case NT_PROCSTAT_RLIMIT:
+	return _("NT_PROCSTAT_RLIMIT: (rlimit data)");
+      case NT_PROCSTAT_OSREL:
+	return _("NT_PROCSTAT_OSREL: (osreldate data)");
+      case NT_PROCSTAT_PSSTRINGS:
+	return _("NT_PROCSTAT_PSSTRINGS: (ps_strings data)");
+      case NT_PROCSTAT_AUXV:
+	return _("NT_PROCSTAT_AUXV: (auxv data)");
+      default:
+	break;
+      }
+
+  return get_note_type(e_type);
+}
+
+static const char *
 get_netbsd_elfcore_note_type (unsigned e_type)
 {
   static char buff[64];
@@ -9206,6 +9237,10 @@ process_note (Elf_Internal_Note *pnote)
        note type strings.  */
     nt = get_note_type (pnote->type);
 
+  else if (const_strneq (pnote->namedata, "FreeBSD"))
+    /* FreeBSD-specific core file notes.  */
+    nt = get_freebsd_elfcore_note_type (pnote->type);
+
   else if (const_strneq (pnote->namedata, "NetBSD-CORE"))
     /* NetBSD-specific core file notes.  */
     nt = get_netbsd_elfcore_note_type (pnote->type);

Modified: head/contrib/binutils/include/elf/common.h
==============================================================================
--- head/contrib/binutils/include/elf/common.h	Thu Jul 18 15:17:11 2013	(r253450)
+++ head/contrib/binutils/include/elf/common.h	Thu Jul 18 17:25:50 2013	(r253451)
@@ -388,7 +388,6 @@
 #define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
 #define NT_TASKSTRUCT	4		/* Contains copy of task struct */
 #define NT_AUXV		6		/* Contains copy of Elfxx_auxv_t */
-#define NT_THRMISC	7		/* Contains copy of thrmisc struct */
 #define NT_PRXFPREG	0x46e62b7f	/* Contains a user_xfpregs_struct; */
 					/*   note name must be "LINUX".  */
 
@@ -401,6 +400,19 @@
 #define NT_LWPSINFO	17		/* Has a struct lwpsinfo_t */
 #define NT_WIN32PSTATUS	18		/* Has a struct win32_pstatus */
 
+/* Note segments for core files on FreeBSD systems.  Note name
+   must start with "FreeBSD".  */
+#define NT_THRMISC		7	/* Contains copy of thrmisc struct */
+#define NT_PROCSTAT_PROC	8
+#define NT_PROCSTAT_FILES	9
+#define NT_PROCSTAT_VMMAP	10
+#define NT_PROCSTAT_GROUPS	11
+#define NT_PROCSTAT_UMASK	12
+#define NT_PROCSTAT_RLIMIT	13
+#define NT_PROCSTAT_OSREL	14
+#define NT_PROCSTAT_PSSTRINGS	15
+#define NT_PROCSTAT_AUXV	16
+
 
 /* Note segments for core files on NetBSD systems.  Note name
    must start with "NetBSD-CORE".  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307181725.r6IHPoJT003913>