# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1173264814 0
# Node ID e68ee3665cba1d11017a1ad9a924078cbdb54ff2
# Parent 9be942ec0247a20f4d6b9dacc53fd85582688df5
dump-core: always use elfclass64 format to support x86_32pae.
Without this patch xen dump-core format can't handle over 4GB case.
Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
docs/misc/dump-core-format.txt | 14 ++++++++++----
tools/libxc/xc_core.c | 26 +++++++++++++-------------
tools/libxc/xc_core.h | 4 ++--
tools/libxc/xc_core_ia64.c | 4 ++--
tools/libxc/xc_core_ia64.h | 2 +-
tools/libxc/xc_core_x86.h | 2 +-
tools/libxc/xc_ptrace_core.c | 24 +++++++++++++-----------
7 files changed, 42 insertions(+), 34 deletions(-)
diff -r 9be942ec0247 -r e68ee3665cba docs/misc/dump-core-format.txt
--- a/docs/misc/dump-core-format.txt Wed Mar 07 10:49:20 2007 +0000
+++ b/docs/misc/dump-core-format.txt Wed Mar 07 10:53:34 2007 +0000
@@ -26,11 +26,12 @@ Elf header
Elf header
----------
The elf header members are set as follows
+ e_ident[EI_CLASS] = ELFCLASS64 = 2
e_ident[EI_OSABI] = ELFOSABI_SYSV = 0
e_type = ET_CORE = 4
-e_ident[EI_CLASS], e_ident[EI_DATA] and e_flags are set according
-to an architecture which a file is created. Other members are set as usual.
-
+ELFCLASS64 is always used independent of architecture.
+e_ident[EI_DATA] and e_flags are set according to the dumping system's
+architecture. Other members are set as usual.
Sections
--------
@@ -221,5 +222,10 @@ format_version descriptor
Format version history
----------------------
-The currently only (major, minor) = (0, 1) is used.
+Currently only (major, minor) = (0, 1) is used.
[When the format is changed, it would be described here.]
+
+(0, 1) update
+- EI_CLASS member of elf header was changed to ELFCLASS64 independent of
+ architecture. This is mainly for x86_32pae.
+ The format version isn't bumped because analysis tools can distinguish it.
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_core.c
--- a/tools/libxc/xc_core.c Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_core.c Wed Mar 07 10:53:34 2007 +0000
@@ -153,7 +153,7 @@ struct xc_core_section_headers {
uint16_t num;
uint16_t num_max;
- Elf_Shdr *shdrs;
+ Elf64_Shdr *shdrs;
};
#define SHDR_INIT 16
#define SHDR_INC 4
@@ -184,14 +184,14 @@ xc_core_shdr_free(struct xc_core_section
free(sheaders);
}
-Elf_Shdr*
+Elf64_Shdr*
xc_core_shdr_get(struct xc_core_section_headers *sheaders)
{
- Elf_Shdr *shdr;
+ Elf64_Shdr *shdr;
if ( sheaders->num == sheaders->num_max )
{
- Elf_Shdr *shdrs;
+ Elf64_Shdr *shdrs;
if ( sheaders->num_max + SHDR_INC < sheaders->num_max )
{
errno = E2BIG;
@@ -212,7 +212,7 @@ xc_core_shdr_get(struct xc_core_section_
}
int
-xc_core_shdr_set(Elf_Shdr *shdr,
+xc_core_shdr_set(Elf64_Shdr *shdr,
struct xc_core_strtab *strtab,
const char *name, uint32_t type,
uint64_t offset, uint64_t size,
@@ -317,15 +317,15 @@ xc_domain_dumpcore_via_callback(int xc_h
uint64_t *pfn_array = NULL;
- Elf_Ehdr ehdr;
- unsigned long filesz;
- unsigned long offset;
- unsigned long fixup;
+ Elf64_Ehdr ehdr;
+ uint64_t filesz;
+ uint64_t offset;
+ uint64_t fixup;
struct xc_core_strtab *strtab = NULL;
uint16_t strtab_idx;
struct xc_core_section_headers *sheaders = NULL;
- Elf_Shdr *shdr;
+ Elf64_Shdr *shdr;
/* elf notes */
struct elfnote elfnote;
@@ -460,7 +460,7 @@ xc_domain_dumpcore_via_callback(int xc_h
ehdr.e_ident[EI_MAG1] = ELFMAG1;
ehdr.e_ident[EI_MAG2] = ELFMAG2;
ehdr.e_ident[EI_MAG3] = ELFMAG3;
- ehdr.e_ident[EI_CLASS] = ELFCLASS;
+ ehdr.e_ident[EI_CLASS] = ELFCLASS64;
ehdr.e_ident[EI_DATA] = ELF_ARCH_DATA;
ehdr.e_ident[EI_VERSION] = EV_CURRENT;
ehdr.e_ident[EI_OSABI] = ELFOSABI_SYSV;
@@ -474,9 +474,9 @@ xc_domain_dumpcore_via_callback(int xc_h
ehdr.e_shoff = sizeof(ehdr);
ehdr.e_flags = ELF_CORE_EFLAGS;
ehdr.e_ehsize = sizeof(ehdr);
- ehdr.e_phentsize = sizeof(Elf_Phdr);
+ ehdr.e_phentsize = sizeof(Elf64_Phdr);
ehdr.e_phnum = 0;
- ehdr.e_shentsize = sizeof(Elf_Shdr);
+ ehdr.e_shentsize = sizeof(Elf64_Shdr);
/* ehdr.e_shnum and ehdr.e_shstrndx aren't known here yet. fill it later*/
/* create section header */
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_core.h
--- a/tools/libxc/xc_core.h Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_core.h Wed Mar 07 10:53:34 2007 +0000
@@ -116,10 +116,10 @@ struct xc_core_strtab;
struct xc_core_strtab;
struct xc_core_section_headers;
-Elf_Shdr*
+Elf64_Shdr*
xc_core_shdr_get(struct xc_core_section_headers *sheaders);
int
-xc_core_shdr_set(Elf_Shdr *shdr,
+xc_core_shdr_set(Elf64_Shdr *shdr,
struct xc_core_strtab *strtab,
const char *name, uint32_t type,
uint64_t offset, uint64_t size,
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_core_ia64.c
--- a/tools/libxc/xc_core_ia64.c Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_core_ia64.c Wed Mar 07 10:53:34 2007 +0000
@@ -266,10 +266,10 @@ xc_core_arch_context_get_shdr(struct xc_
xc_core_arch_context_get_shdr(struct xc_core_arch_context *arch_ctxt,
struct xc_core_section_headers *sheaders,
struct xc_core_strtab *strtab,
- unsigned long *filesz, unsigned long offset)
+ uint64_t *filesz, uint64_t offset)
{
int sts = -1;
- Elf_Shdr *shdr;
+ Elf64_Shdr *shdr;
/* mmapped priv regs */
shdr = xc_core_shdr_get(sheaders);
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_core_ia64.h
--- a/tools/libxc/xc_core_ia64.h Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_core_ia64.h Wed Mar 07 10:53:34 2007 +0000
@@ -42,7 +42,7 @@ xc_core_arch_context_get_shdr(struct xc_
xc_core_arch_context_get_shdr(struct xc_core_arch_context* arch_ctxt,
struct xc_core_section_headers *sheaders,
struct xc_core_strtab *strtab,
- unsigned long *filesz, unsigned long offset);
+ uint64_t *filesz, uint64_t offset);
int
xc_core_arch_context_dump(struct xc_core_arch_context* arch_ctxt,
void* args, dumpcore_rtn_t dump_rtn);
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_core_x86.h
--- a/tools/libxc/xc_core_x86.h Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_core_x86.h Wed Mar 07 10:53:34 2007 +0000
@@ -45,7 +45,7 @@ xc_core_arch_context_get_shdr(struct xc_
xc_core_arch_context_get_shdr(struct xc_core_arch_context *arch_ctxt,
struct xc_core_section_headers *sheaders,
struct xc_core_strtab *strtab,
- unsigned long *filesz, unsigned long offset)
+ uint64_t *filesz, uint64_t offset)
{
*filesz = 0;
return 0;
diff -r 9be942ec0247 -r e68ee3665cba tools/libxc/xc_ptrace_core.c
--- a/tools/libxc/xc_ptrace_core.c Wed Mar 07 10:49:20 2007 +0000
+++ b/tools/libxc/xc_ptrace_core.c Wed Mar 07 10:53:34 2007 +0000
@@ -192,7 +192,7 @@ struct elf_core
struct elf_core
{
int domfd;
- Elf_Ehdr ehdr;
+ Elf64_Ehdr ehdr;
char* shdr;
@@ -241,6 +241,8 @@ elf_core_init(struct elf_core* ecore, in
/* check elf header */
if (!IS_ELF(ecore->ehdr) || ecore->ehdr.e_type != ET_CORE)
+ goto out;
+ if (ecore->ehdr.e_ident[EI_CLASS] != ELFCLASS64)
goto out;
/* check elf header more: EI_DATA, EI_VERSION, e_machine... */
@@ -294,7 +296,7 @@ elf_core_search_note(struct elf_core* ec
}
static int
-elf_core_alloc_read_sec(struct elf_core* ecore, const Elf_Shdr* shdr,
+elf_core_alloc_read_sec(struct elf_core* ecore, const Elf64_Shdr* shdr,
char** buf)
{
int ret;
@@ -309,19 +311,19 @@ elf_core_alloc_read_sec(struct elf_core*
return ret;
}
-static Elf_Shdr*
+static Elf64_Shdr*
elf_core_shdr_by_index(struct elf_core* ecore, uint16_t index)
{
if (index >= ecore->ehdr.e_shnum)
return NULL;
- return (Elf_Shdr*)(ecore->shdr + ecore->ehdr.e_shentsize * index);
+ return (Elf64_Shdr*)(ecore->shdr + ecore->ehdr.e_shentsize * index);
}
static int
elf_core_alloc_read_sec_by_index(struct elf_core* ecore, uint16_t index,
char** buf, uint64_t* size)
{
- Elf_Shdr* shdr = elf_core_shdr_by_index(ecore, index);
+ Elf64_Shdr* shdr = elf_core_shdr_by_index(ecore, index);
if (shdr == NULL)
return -1;
if (size != NULL)
@@ -329,14 +331,14 @@ elf_core_alloc_read_sec_by_index(struct
return elf_core_alloc_read_sec(ecore, shdr, buf);
}
-static Elf_Shdr*
+static Elf64_Shdr*
elf_core_shdr_by_name(struct elf_core* ecore, const char* name)
{
const char* s;
for (s = ecore->shdr;
s < ecore->shdr + ecore->ehdr.e_shentsize * ecore->ehdr.e_shnum;
s += ecore->ehdr.e_shentsize) {
- Elf_Shdr* shdr = (Elf_Shdr*)s;
+ Elf64_Shdr* shdr = (Elf64_Shdr*)s;
if (strncmp(ecore->shstrtab + shdr->sh_name, name, strlen(name)) == 0)
return shdr;
@@ -348,7 +350,7 @@ static int
static int
elf_core_read_sec_by_name(struct elf_core* ecore, const char* name, char* buf)
{
- Elf_Shdr* shdr = elf_core_shdr_by_name(ecore, name);
+ Elf64_Shdr* shdr = elf_core_shdr_by_name(ecore, name);
return pread_exact(ecore->domfd, buf, shdr->sh_size, shdr->sh_offset);
}
@@ -357,7 +359,7 @@ elf_core_alloc_read_sec_by_name(struct e
elf_core_alloc_read_sec_by_name(struct elf_core* ecore, const char* name,
char** buf, uint64_t* size)
{
- Elf_Shdr* shdr = elf_core_shdr_by_name(ecore, name);
+ Elf64_Shdr* shdr = elf_core_shdr_by_name(ecore, name);
if (shdr == NULL)
return -1;
if (size != NULL)
@@ -508,8 +510,8 @@ xc_waitdomain_core_elf(
struct xen_dumpcore_elfnote_xen_version *xen_version;
struct xen_dumpcore_elfnote_format_version *format_version;
- Elf_Shdr* table_shdr;
- Elf_Shdr* pages_shdr;
+ Elf64_Shdr* table_shdr;
+ Elf64_Shdr* pages_shdr;
if (elf_core_init(&ecore, domfd) < 0)
goto out;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|