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
This commit is contained in:
Ed Maste 2013-07-18 17:25:50 +00:00
parent c825d4dc50
commit c158e13f7d
2 changed files with 50 additions and 3 deletions

View File

@ -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:
@ -9129,6 +9127,39 @@ get_note_type (unsigned e_type)
return buff;
}
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)
{
@ -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);

View File

@ -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". */