summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2010-01-04 21:59:07 -0800
committerRoland McGrath <[email protected]>2010-01-04 21:59:07 -0800
commit0ccbbcd1244336d38f51648620b32b193d591cbb (patch)
treebccb82dbe2a1c9a403b15f5f6e17c77c04068d33 /backends
parent2e79deb2cb049f3b0f3f45680dfe956cf99b25d8 (diff)
Make readelf -n check note name strings, handle "VMCOREINFO" flavor.
Diffstat (limited to 'backends')
-rw-r--r--backends/ChangeLog9
-rw-r--r--backends/i386_corenote.c5
-rw-r--r--backends/linux-core-note.c58
-rw-r--r--backends/x86_corenote.c5
4 files changed, 64 insertions, 13 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index c7f6d366..69351b32 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-04 Roland McGrath <[email protected]>
+
+ * linux-core-note.c (vmcoreinfo_items): New static const variable.
+ (EBLHOOK(core_note)): Update arguments for new protocol.
+ Validate the name as "CORE" or "LINUX" for known n_type cases.
+ Handle name "VMCOREINFO" n_type=0 with vmcoreinfo_items.
+ * i386_corenote.c (EXTRA_NOTES): Update parameter usage.
+ * x86_corenote.c (EXTRA_NOTES_IOPERM): Likewise.
+
2009-09-10 Mark Wielaard <[email protected]>
* sparc_retval.c: Fix license header.
diff --git a/backends/i386_corenote.c b/backends/i386_corenote.c
index 89890252..40b6a24e 100644
--- a/backends/i386_corenote.c
+++ b/backends/i386_corenote.c
@@ -1,5 +1,5 @@
/* i386 specific core note handling.
- Copyright (C) 2007-2009 Red Hat, Inc.
+ Copyright (C) 2007-2010 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -103,7 +103,8 @@ static const Ebl_Register_Location prxfpreg_regs[] =
#define EXTRA_NOTES \
EXTRA_REGSET (NT_PRXFPREG, 512, prxfpreg_regs) \
case NT_386_TLS: \
- return tls_info (descsz, regs_offset, nregloc, reglocs, nitems, items); \
+ return tls_info (nhdr->n_descsz, regs_offset, nregloc, reglocs, \
+ nitems, items); \
EXTRA_NOTES_IOPERM
static const Ebl_Core_Item tls_items[] =
diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c
index 7b1fc025..9d01219c 100644
--- a/backends/linux-core-note.c
+++ b/backends/linux-core-note.c
@@ -1,5 +1,5 @@
/* Common core note type descriptions for Linux.
- Copyright (C) 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2007-2010 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -23,6 +23,8 @@
Network licensing program, please visit www.openinventionnetwork.com
<http://www.openinventionnetwork.com>. */
+#include <string.h>
+
/* The including CPU_corenote.c file provides prstatus_regs and
defines macros ULONG, [PUG]ID_T, and ALIGN_*, TYPE_*.
@@ -163,23 +165,61 @@ static const Ebl_Core_Item prpsinfo_items[] =
FIELD (command, CHAR, psargs, 's', .count = PRARGSZ),
};
+static const Ebl_Core_Item vmcoreinfo_items[] =
+ {
+ {
+ .type = ELF_T_BYTE, .format = '\n'
+ }
+ };
+
#undef FIELD
int
-EBLHOOK(core_note) (n_type, descsz,
- regs_offset, nregloc, reglocs, nitems, items)
- GElf_Word n_type;
- GElf_Word descsz;
+EBLHOOK(core_note) (nhdr, name, regs_offset, nregloc, reglocs, nitems, items)
+ const GElf_Nhdr *nhdr;
+ const char *name;
GElf_Word *regs_offset;
size_t *nregloc;
const Ebl_Register_Location **reglocs;
size_t *nitems;
const Ebl_Core_Item **items;
{
- switch (n_type)
+ switch (nhdr->n_namesz)
+ {
+ case sizeof "CORE" - 1: /* Buggy old Linux kernels. */
+ if (memcmp (name, "CORE", nhdr->n_namesz) == 0)
+ break;
+ return 0;
+
+ case sizeof "CORE":
+ if (memcmp (name, "CORE", nhdr->n_namesz) == 0)
+ break;
+ /* Buggy old Linux kernels didn't terminate "LINUX".
+ Fall through. */
+
+ case sizeof "LINUX":
+ if (memcmp (name, "LINUX", nhdr->n_namesz) == 0)
+ break;
+ return 0;
+
+ case sizeof "VMCOREINFO":
+ if (nhdr->n_type != 0
+ || memcmp (name, "VMCOREINFO", sizeof "VMCOREINFO") != 0)
+ return 0;
+ *regs_offset = 0;
+ *nregloc = 0;
+ *nitems = 1;
+ *items = vmcoreinfo_items;
+ return 1;
+
+ default:
+ return 0;
+ }
+
+ switch (nhdr->n_type)
{
case NT_PRSTATUS:
- if (descsz != sizeof (struct EBLHOOK(prstatus)))
+ if (nhdr->n_descsz != sizeof (struct EBLHOOK(prstatus)))
return 0;
*regs_offset = offsetof (struct EBLHOOK(prstatus), pr_reg);
*nregloc = sizeof prstatus_regs / sizeof prstatus_regs[0];
@@ -189,7 +229,7 @@ EBLHOOK(core_note) (n_type, descsz,
return 1;
case NT_PRPSINFO:
- if (descsz != sizeof (struct EBLHOOK(prpsinfo)))
+ if (nhdr->n_descsz != sizeof (struct EBLHOOK(prpsinfo)))
return 0;
*regs_offset = 0;
*nregloc = 0;
@@ -200,7 +240,7 @@ EBLHOOK(core_note) (n_type, descsz,
#define EXTRA_REGSET(type, size, table) \
case type: \
- if (descsz != size) \
+ if (nhdr->n_descsz != size) \
return 0; \
*regs_offset = 0; \
*nregloc = sizeof table / sizeof table[0]; \
diff --git a/backends/x86_corenote.c b/backends/x86_corenote.c
index 7d550676..78849a66 100644
--- a/backends/x86_corenote.c
+++ b/backends/x86_corenote.c
@@ -1,5 +1,5 @@
/* x86-specific core note handling, pieces common to x86-64 and i386.
- Copyright (C) 2005, 2008 Red Hat, Inc.
+ Copyright (C) 2005-2010 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -25,7 +25,8 @@
#define EXTRA_NOTES_IOPERM \
case NT_386_IOPERM: \
- return ioperm_info (descsz, regs_offset, nregloc, reglocs, nitems, items);
+ return ioperm_info (nhdr->n_descsz, \
+ regs_offset, nregloc, reglocs, nitems, items);
static int
ioperm_info (GElf_Word descsz, GElf_Word *regs_offset,