From owner-svn-src-all@FreeBSD.ORG Thu Jul 18 17:25:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 15581306; Thu, 18 Jul 2013 17:25:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 070A5C7C; Thu, 18 Jul 2013 17:25:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IHPoec003915; Thu, 18 Jul 2013 17:25:50 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6IHPoJT003913; Thu, 18 Jul 2013 17:25:50 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201307181725.r6IHPoJT003913@svn.freebsd.org> From: Ed Maste Date: Thu, 18 Jul 2013 17:25:50 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 17:25:51 -0000 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". */