diff -ruNp makedumpfile.old/makedumpfile.c makedumpfile/makedumpfile.c
--- makedumpfile.old/makedumpfile.c	2006-10-01 09:42:54.000000000 +0900
+++ makedumpfile/makedumpfile.c	2006-10-01 09:43:09.000000000 +0900
@@ -22,6 +22,7 @@
 
 #include "makedumpfile.h"
 
+struct dwarf_info dwarf_info;
 extern struct symbol_table	symbol_table;
 extern struct size_table	size_table;
 extern struct offset_table	offset_table;
@@ -450,26 +451,7 @@ open_files_for_creating_dumpfile(struct 
 }
 
 int
-dump_Elf32_pt_load(struct DumpInfo *info, Elf32_Phdr *prog, int num_load)
-{
-	struct pt_load_segment *pls;
-
-	if (prog->p_type != PT_LOAD) {
-		ERRMSG("%s isn't the dump memory.\n", info->name_memory);
-		return FALSE;
-	}
-
-	pls = &info->pt_load_segments[num_load];
-	pls->phys_start  = prog->p_paddr;
-	pls->phys_end    = pls->phys_start + prog->p_filesz;
-	pls->virt_start  = prog->p_vaddr;
-	pls->virt_end    = pls->virt_start + prog->p_filesz;
-	pls->file_offset = prog->p_offset;
-	return TRUE;
-}
-
-int
-dump_Elf64_pt_load(struct DumpInfo *info, Elf64_Phdr *prog, int num_load)
+dump_Elf_pt_load(struct DumpInfo *info, Elf64_Phdr *prog, int num_load)
 {
 	struct pt_load_segment *pls;
 
@@ -490,112 +472,75 @@ dump_Elf64_pt_load(struct DumpInfo *info
 int
 get_elf_info(struct DumpInfo *info)
 {
-	int i;
+	Elf *elfd = NULL;
+	GElf_Ehdr ehdr;
+	GElf_Phdr load;
+	int i, j;
 	unsigned long tmp;
-	const off_t failed = (off_t)-1;
+	int rc = FALSE;
 
-	Elf32_Ehdr *elf32;
-	Elf64_Ehdr *elf64;
-	Elf32_Phdr *load32;
-	Elf64_Phdr *load64;
-	char header[MIN_ELF_HEADER_SIZE];
-	char *tmp_elf_header = NULL;
+	elfd = elf_begin(info->fd_memory, ELF_C_READ, NULL);
 
-	/*
-	 * Get minimam ELF header info.
-	 */
-	if (read(info->fd_memory, header, MIN_ELF_HEADER_SIZE)
-	    != MIN_ELF_HEADER_SIZE) {
-		ERRMSG("Can't read the dump memory(%s). %s\n",
-		    info->name_memory, strerror(errno));
+	if (!elfd) {
+		ERRMSG("Could not obtain first elf header\n");
 		goto out;
 	}
 
-	elf32 = (Elf32_Ehdr *)&header[0];
-	elf64 = (Elf64_Ehdr *)&header[0];
-
-	if (STRNEQ(elf32->e_ident, ELFMAG)
-	    && (elf32->e_ident[EI_CLASS] == ELFCLASS32)) {
-		info->flag_elf = ELF32;
-		load32 = (Elf32_Phdr *)
-		       &header[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
-		info->num_load_memory    = elf32->e_phnum - 1;
-		info->offset_load_memory = (Elf32_Off)load32->p_offset;
-	} else if (STRNEQ(elf64->e_ident, ELFMAG)
-	    && (elf64->e_ident[EI_CLASS] == ELFCLASS64)) {
-		info->flag_elf = ELF64;
-		load64 = (Elf64_Phdr *)
-		       &header[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
-		info->num_load_memory    = elf64->e_phnum - 1;
-		info->offset_load_memory = (Elf64_Off)load64->p_offset;
-	} else {
-		ERRMSG("%s isn't the dump memory.\n", info->name_memory);
+	if (gelf_getehdr(elfd, &ehdr) == NULL) {
+		ERRMSG("Could not find file header\n");
 		goto out;
 	}
 
-	/*
-	 * FIXME
-	 *   If the page_size of 1st-kernel is different from the one of
-	 *   capture(2nd)-kernel, the problem will happen.
-	 */
-	if (!info->page_size) {
-		info->page_size = sysconf(_SC_PAGE_SIZE);
+	/* get the ident string */
+	if (ehdr.e_ident[EI_CLASS] == ELFCLASSNONE) {
+		ERRMSG("Elf File has no class\n");
+		goto out;
 	}
+
+	info->flag_elf = (ehdr.e_ident[EI_CLASS] == ELFCLASS32) ? ELF32 : ELF64;
+	info->num_load_memory = ehdr.e_phnum - 1;
 	if (!info->num_load_memory) {
 		ERRMSG("Can't get the number of PT_LOAD.\n");
 		goto out;
 	}
-	if (!info->offset_load_memory) {
-		ERRMSG("Can't get the offset of page data.\n");
-		goto out;
-	}
 
-	/*
-	 * Get full ELF header info.
-	 */
-	if ((tmp_elf_header = (char *)malloc(info->offset_load_memory))
-	    == NULL) {
-		ERRMSG("Can't allocate memory for the ELF header. %s\n",
+	if ((info->pt_load_segments = (struct pt_load_segment *)
+	    calloc(1, sizeof(struct pt_load_segment) *
+	    info->num_load_memory)) == NULL) {
+		ERRMSG("Can't allocate memory for the PT_LOAD. %s\n",
 		    strerror(errno));
 		goto out;
 	}
-	if (lseek(info->fd_memory, 0, SEEK_SET) == failed) {
-		ERRMSG("Can't seek the dump memory(%s). %s\n",
-		    info->name_memory, strerror(errno));
-		goto out;
-	}
-	if (read(info->fd_memory, tmp_elf_header, info->offset_load_memory)
-	    != info->offset_load_memory) {
-		ERRMSG("Can't read the dump memory(%s). %s\n",
-		    info->name_memory, strerror(errno));
-		goto out;
-	}
-	if (info->flag_elf & ELF32) {
-		load32 = (Elf32_Phdr *)
-		       &tmp_elf_header[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
-		if ((info->pt_load_segments = (struct pt_load_segment *)
-		    calloc(1, sizeof(struct pt_load_segment) *
-		    info->num_load_memory)) == NULL) {
-			ERRMSG("Can't allocate memory for the PT_LOAD. %s\n",
-			    strerror(errno));
+
+	for (i = 0, j = 0; i < ehdr.e_phnum; i++) {
+		if (gelf_getphdr(elfd, i, &load) == NULL) {
+			ERRMSG("Could not find Phdr %d\n", i);
 			goto out;
 		}
-		for (i = 0; i < info->num_load_memory; i++)
-			if(!dump_Elf32_pt_load(info, load32 + i, i))
+
+		if (load.p_type == PT_LOAD) {
+			if (j == 0) {
+				info->offset_load_memory = load.p_offset;
+				if (!info->offset_load_memory) {
+					ERRMSG("Can't get the offset of page data.\n");
+					goto out;
+				}
+			}
+			if (j >= info->num_load_memory)
 				goto out;
-	} else { /* ELF64 */
-		load64 = (Elf64_Phdr *)
-		       &tmp_elf_header[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
-		if ((info->pt_load_segments = (struct pt_load_segment *)
-		    calloc(1, sizeof(struct pt_load_segment) *
-		    info->num_load_memory)) == NULL) {
-			ERRMSG("Can't allocate memory for the PT_LOAD. %s\n",
-			    strerror(errno));
-			goto out;
-		}
-		for (i = 0; i < info->num_load_memory; i++)
-			if(!dump_Elf64_pt_load(info, load64 + i, i))
+			if(!dump_Elf_pt_load(info, &load, j))
 				goto out;
+			j++;
+		}
+	}
+
+	/*
+	 * FIXME
+	 *   If the page_size of 1st-kernel is different from the one of
+	 *   capture(2nd)-kernel, the problem will happen.
+	 */
+	if (!info->page_size) {
+		info->page_size = sysconf(_SC_PAGE_SIZE);
 	}
 	info->max_mapnr = get_max_mapnr(info);
 	tmp = 2*divideup(info->max_mapnr, BITPERBYTE);
@@ -604,12 +549,11 @@ get_elf_info(struct DumpInfo *info)
 	if (info->flag_exclude_free)
 		info->len_3rd_bitmap = info->len_bitmap >> 1;
 
-	free(tmp_elf_header);
-	return TRUE;
+	if (elf_end(elfd) == 0)
+		rc = TRUE;
 out:
-	if (tmp_elf_header != NULL)
-		free(tmp_elf_header);
-	return FALSE;
+	
+	return rc;
 }
 
 unsigned long
@@ -625,13 +569,6 @@ get_symbol_addr(struct DumpInfo *info, c
 	char *sym_name = NULL;
 
 	lseek(info->fd_memory,0,SEEK_SET);
-	if (elf_version(EV_CURRENT) == EV_NONE ) {
-		/*
-		 * library out of date
-		 */
-		ERRMSG("Elf library out of date!n");
-		goto out;
-	}
 	if (!(elfd = elf_begin(dwarf_info.vmlinux_fd, ELF_C_READ, NULL))) {
 		ERRMSG(" Could not start elf file\n");
 		return FALSE;
@@ -715,6 +652,188 @@ is_kvaddr(unsigned long addr)
 	return (addr >= (unsigned long)(KVBASE));
 }
 
+static int process_attribute(Dwarf_Attribute *attr, void *cb_data)
+{
+	struct dwarf_values *args = cb_data;
+
+	switch (attr->code) {
+		case DW_AT_data_member_location: {
+			Dwarf_Op *expr;
+			size_t expcnt;
+
+			dwarf_getlocation (attr, &expr, &expcnt);
+			dwarf_info.member_offset = expr[0].number;
+			*args->found_map |= DWARF_INFO_FOUND_LOCATION;
+			break;
+		}
+		default:
+			break;
+	}
+
+	return 0;
+}
+
+static int process_children(Dwarf_Die *die, uint32_t *found_map)
+{
+	Dwarf_Die child;
+	Dwarf_Die *walker;
+	int rc;
+	const char *name;
+	struct dwarf_values args;
+
+	rc = dwarf_child(die, &child);
+	walker = &child;
+	
+	while (rc == 0) {
+		name = dwarf_diename(walker);
+		if (dwarf_info.cmd == DWARF_INFO_GET_MEMBER_OFFSET &&
+			(dwarf_tag(walker) == DW_TAG_member) &&
+			(name) && (!strcmp(name, dwarf_info.member_name))) {
+			/*
+			 * get the attirbutes of this die to record the
+			 *location of the symbol
+			 */
+			*found_map |= DWARF_INFO_FOUND_MEMBER;
+		}
+		if (dwarf_info.cmd == DWARF_INFO_GET_NOT_NAMED_UNION_OFFSET &&
+			(dwarf_tag(walker) == DW_TAG_union_type) &&
+			(!name)) {
+			*found_map |= DWARF_INFO_FOUND_MEMBER;
+		}
+		if (*found_map & DWARF_INFO_FOUND_MEMBER) {
+			args.die = walker;
+			args.found_map = found_map;
+			dwarf_getattrs(walker, process_attribute, &args, 0);
+			if ((*found_map & DWARF_INFO_FOUND_ALL) ==
+				DWARF_INFO_FOUND_ALL)
+				return TRUE;
+		}
+
+		rc = dwarf_siblingof(walker, walker); 
+	}
+
+	/*
+	 * Return TRUE even if not found. Return FALSE if I/O error
+	 * in the future.
+	 */
+	return TRUE;
+}
+
+static void search_die_tree(Dwarf *dwarfd, Dwarf_Die *die, uint32_t *found_map)
+{
+	Dwarf_Die child; 
+	int tag;
+	const char *name;
+	/*
+	 * We are searching the die tree for the mappings member
+	 * of the page struct defined in mm.h
+	 */
+
+	/* 
+	 * start by looking at the children
+	 */
+	if (dwarf_child(die, &child) == 0)
+		search_die_tree(dwarfd, &child, found_map);
+
+	/*
+	 * If we get to here then we don't have any more
+	 * children, check to see if this is a relevant tag
+	 */
+next_tag:
+	tag = dwarf_tag(die);
+	name = dwarf_diename(die);
+	if ((tag == DW_TAG_structure_type) &&
+	   (name) && (!strcmp(name, dwarf_info.struct_name))) {
+		/*
+		 * this is our structure
+		 * process the children
+		 */
+		*found_map |= DWARF_INFO_FOUND_STRUCT;
+		dwarf_info.struct_size = dwarf_bytesize(die);
+		if (dwarf_info.cmd == DWARF_INFO_GET_STRUCT_SIZE)
+			return;
+		if (process_children(die, found_map) == TRUE)
+			return;
+	}
+
+	if (dwarf_siblingof(die,die) == 0)
+		goto next_tag;
+
+}
+
+
+int
+get_debug_info(void)
+{
+	Dwarf *dwarfd = NULL;
+	Elf *elfd = NULL;
+	Dwarf_Off off = 0;
+	Dwarf_Off next_off = 0;
+	Elf_Scn *scn = NULL;
+	GElf_Shdr scnhdr_mem;
+	GElf_Shdr *scnhdr = NULL;
+	size_t header_size;
+	Dwarf_Off abbrev_offset = 0;
+	Dwarf_Die cu_die;
+	uint8_t address_size;
+	uint8_t offset_size;
+	int rc;
+	uint32_t found_map = 0;
+	char *name = NULL;
+	size_t shstrndx;
+
+	rc = FALSE;
+
+	lseek(dwarf_info.vmlinux_fd, 0, SEEK_SET);
+
+	elfd = elf_begin(dwarf_info.vmlinux_fd, ELF_C_READ_MMAP, NULL);
+
+	if (!elfd)
+		goto out_close_elf;
+
+	dwarfd = dwarf_begin_elf(elfd, DWARF_C_READ, NULL);
+
+	if (!dwarfd)
+		goto out_close_dwarf;
+
+	if (elf_getshstrndx (elfd, &shstrndx) < 0)
+		goto out_close_dwarf;
+
+	while ((scn = elf_nextscn (elfd, scn)) != NULL) {
+
+		scnhdr = gelf_getshdr(scn, &scnhdr_mem);
+
+		name = elf_strptr(elfd, shstrndx, scnhdr->sh_name);
+
+		if (strcmp(name,".debug_info"))
+			continue;
+
+		while (dwarf_nextcu(dwarfd, off, &next_off, &header_size,
+				   &abbrev_offset, &address_size, &offset_size) == 0) {
+			off += header_size;
+			if (dwarf_offdie(dwarfd, off, &cu_die) == NULL)
+				goto out_close_dwarf;
+			search_die_tree(dwarfd, &cu_die, &found_map);
+			if (found_map & DWARF_INFO_FOUND_STRUCT)
+				goto out_found;
+			off = next_off;
+		}
+	}
+
+	if (scn == NULL)
+		goto out_close_dwarf;
+
+out_found:
+	rc = TRUE;
+
+out_close_dwarf:
+	dwarf_end(dwarfd);
+out_close_elf:
+	elf_end(elfd);
+	dwarf_info.status = found_map;
+	return rc;
+
+}
 /*
  * Get the size of structure.
  */
@@ -3014,7 +3133,13 @@ main(int argc, char *argv[])
 		info->name_dumpfile = argv[optind+1];
 	}
 
-
+	if (elf_version(EV_CURRENT) == EV_NONE ) {
+		/*
+		 * library out of date
+		 */
+		ERRMSG("Elf library out of date!n");
+		goto out;
+	}
 	if (info->flag_generate_config) {
 		if (!open_files_for_generating_configfile(info))
 			goto out;
diff -ruNp makedumpfile.old/makedumpfile.h makedumpfile/makedumpfile.h
--- makedumpfile.old/makedumpfile.h	2006-10-01 09:42:54.000000000 +0900
+++ makedumpfile/makedumpfile.h	2006-10-01 09:43:09.000000000 +0900
@@ -25,6 +25,9 @@
 #include <time.h>
 #include <sys/utsname.h>
 #include <zlib.h>
+#include <elfutils/libdw.h>
+#include <libelf.h>
+#include <dwarf.h>
 #include "diskdump_mod.h"
 
 /*
@@ -536,6 +539,8 @@ struct offset_table	offset_table;
 #define DWARF_INFO_GET_NOT_NAMED_UNION_OFFSET	3
 #define DWARF_INFO_FOUND_STRUCT			1
 #define DWARF_INFO_FOUND_MEMBER			2
+#define DWARF_INFO_FOUND_LOCATION		4
+#define DWARF_INFO_FOUND_ALL	(DWARF_INFO_FOUND_STRUCT|DWARF_INFO_FOUND_MEMBER|DWARF_INFO_FOUND_LOCATION)
 
 struct dwarf_info {
 	uint32_t	status;		/* TEMP */
@@ -549,3 +554,8 @@ struct dwarf_info {
 };
 
 extern struct dwarf_info dwarf_info;
+
+struct dwarf_values {
+	Dwarf_Die *die;
+	uint32_t *found_map;
+};
