[PATCH] NetBSD ELF core note type pretty-printing for readelf
Jason R Thorpe
thorpej@wasabisystems.com
Wed Jan 9 12:50:00 GMT 2002
On Wed, Jan 09, 2002 at 11:44:11AM +0000, Nick Clifton wrote:
> 32 appears to be a magic constant for NetBSD core files. Please
> consider replacing it with a meaningfully named #define macro.
Ok, this patch adds and uses #define'd constants for the NetBSD core
file note types.
Committed as obvious.
[ for include/elf/ChangeLog ]
2002-01-09 Jason Thorpe <thorpej@wasabisystems.com>
* common.h: Update copyright years.
(NT_NETBSDCORE_PROCINFO): Define.
(NT_NETBSDCORE_FIRSTMACH): Define.
[ for bfd/ChangeLog ]
2002-01-09 Jason Thorpe <thorpej@wasabisystems.com>
* elf.c: Update copyright years.
(elfcore_grok_netbsd_note): Use NT_NETBSDCORE_PROCINFO
and NT_NETBSDCORE_FIRSTMACH. Improve a comment.
[ for binutils/ChangeLog ]
2002-01-09 Jason Thorpe <thorpej@wasabisystems.com>
* readelf.c (get_netbsd_elfcore_note_type): Use
NT_NETBSDCORE_PROCINFO and NT_NETBSDCORE_FIRSTMACH.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.117
diff -c -r1.117 elf.c
*** elf.c 2001/12/19 05:16:47 1.117
--- elf.c 2002/01/09 18:38:33
***************
*** 1,5 ****
/* ELF executable support for BFD.
! Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
--- 1,5 ----
/* ELF executable support for BFD.
! Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
***************
*** 6431,6437 ****
if (elfcore_netbsd_get_lwpid (note, &lwp))
elf_tdata (abfd)->core_lwpid = lwp;
! if (note->type == 1)
{
/* NetBSD-specific core "procinfo". Note that we expect to
find this note before any of the others, which is fine,
--- 6431,6437 ----
if (elfcore_netbsd_get_lwpid (note, &lwp))
elf_tdata (abfd)->core_lwpid = lwp;
! if (note->type == NT_NETBSDCORE_PROCINFO)
{
/* NetBSD-specific core "procinfo". Note that we expect to
find this note before any of the others, which is fine,
***************
*** 6441,6451 ****
return elfcore_grok_netbsd_procinfo (abfd, note);
}
! /* There are not currently any other machine-independent notes defined
! for NetBSD ELF core files. If the note type is less than the start
! of the machine-dependent note types, we don't understand it. */
! if (note->type < 32)
return true;
--- 6441,6452 ----
return elfcore_grok_netbsd_procinfo (abfd, note);
}
! /* As of Jan 2002 there are no other machine-independent notes
! defined for NetBSD core files. If the note type is less
! than the start of the machine-dependent note types, we don't
! understand it. */
! if (note->type < NT_NETBSDCORE_FIRSTMACH)
return true;
***************
*** 6458,6467 ****
case bfd_arch_sparc:
switch (note->type)
{
! case 32+0:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
! case 32+2:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
--- 6459,6468 ----
case bfd_arch_sparc:
switch (note->type)
{
! case NT_NETBSDCORE_FIRSTMACH+0:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
! case NT_NETBSDCORE_FIRSTMACH+2:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
***************
*** 6474,6483 ****
default:
switch (note->type)
{
! case 32+1:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
! case 32+3:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
--- 6475,6484 ----
default:
switch (note->type)
{
! case NT_NETBSDCORE_FIRSTMACH+1:
return elfcore_make_note_pseudosection (abfd, ".reg", note);
! case NT_NETBSDCORE_FIRSTMACH+3:
return elfcore_make_note_pseudosection (abfd, ".reg2", note);
default:
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.144
diff -c -r1.144 readelf.c
*** readelf.c 2002/01/09 18:05:49 1.144
--- readelf.c 2002/01/09 18:39:48
***************
*** 9087,9093 ****
{
static char buff[64];
! if (e_type == 1)
{
/* NetBSD core "procinfo" structure. */
return _("NetBSD procinfo structure");
--- 9087,9093 ----
{
static char buff[64];
! if (e_type == NT_NETBSDCORE_PROCINFO)
{
/* NetBSD core "procinfo" structure. */
return _("NetBSD procinfo structure");
***************
*** 9098,9104 ****
than the start of the machine-dependent note types, we don't
understand it. */
! if (e_type < 32)
{
sprintf (buff, _("Unknown note type: (0x%08x)"), e_type);
return buff;
--- 9098,9104 ----
than the start of the machine-dependent note types, we don't
understand it. */
! if (e_type < NT_NETBSDCORE_FIRSTMACH)
{
sprintf (buff, _("Unknown note type: (0x%08x)"), e_type);
return buff;
***************
*** 9116,9123 ****
case EM_SPARCV9:
switch (e_type)
{
! case 32+0: return _("PT_GETREGS (reg structure)");
! case 32+2: return _("PT_GETFPREGS (fpreg structure)");
default:
break;
}
--- 9116,9125 ----
case EM_SPARCV9:
switch (e_type)
{
! case NT_NETBSDCORE_FIRSTMACH+0:
! return _("PT_GETREGS (reg structure)");
! case NT_NETBSDCORE_FIRSTMACH+2:
! return _("PT_GETFPREGS (fpreg structure)");
default:
break;
}
***************
*** 9128,9141 ****
default:
switch (e_type)
{
! case 32+1: return _("PT_GETREGS (reg structure)");
! case 32+3: return _("PT_GETFPREGS (fpreg structure)");
default:
break;
}
}
! sprintf (buff, _("PT_FIRSTMACH+%d"), e_type - 32);
return buff;
}
--- 9130,9145 ----
default:
switch (e_type)
{
! case NT_NETBSDCORE_FIRSTMACH+1:
! return _("PT_GETREGS (reg structure)");
! case NT_NETBSDCORE_FIRSTMACH+3:
! return _("PT_GETFPREGS (fpreg structure)");
default:
break;
}
}
! sprintf (buff, _("PT_FIRSTMACH+%d"), e_type - NT_NETBSDCORE_FIRSTMACH);
return buff;
}
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.39
diff -c -r1.39 common.h
*** common.h 2001/12/17 00:52:34 1.39
--- common.h 2002/01/09 18:40:19
***************
*** 1,6 ****
/* ELF support for BFD.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
! 2001
Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
--- 1,6 ----
/* ELF support for BFD.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
! 2001, 2002
Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
***************
*** 341,346 ****
--- 341,354 ----
#define NT_LWPSTATUS 16 /* Has a struct lwpstatus_t */
#define NT_LWPSINFO 17 /* Has a struct lwpsinfo_t */
#define NT_WIN32PSTATUS 18 /* Has a struct win32_pstatus */
+
+
+ /* Note segments for core files on NetBSD systems. Note name
+ must start with "NetBSD-CORE". */
+
+ #define NT_NETBSDCORE_PROCINFO 1 /* Has a struct procinfo */
+ #define NT_NETBSDCORE_FIRSTMACH 32 /* start of machdep note types */
+
/* Values of note segment descriptor types for object files. */
More information about the Binutils
mailing list