FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Crash Utility

 
 
LinkBack Thread Tools
 
Old 02-01-2012, 05:12 AM
"Suzuki K. Poulose"
 
Default Generic routines for processing elf notes

Rearranges the x86_process_elf_notes() to make it more reusable,
by making it more generic. Splits the code for handling Elf32 and
Elf64 PT_NOTE headers to separate functions.

This may be reused by other architectures, e.g, ppc32.

Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
---

diskdump.c | 73 ++++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/diskdump.c b/diskdump.c
index 5519af7..9f4b228 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -85,6 +85,9 @@ static struct diskdump_data **dd_list = NULL;
static int num_dd = 0;
static int num_dumpfiles = 0;

+void process_elf32_notes(void *, ulong);
+void process_elf64_notes(void *, ulong);
+
int dumpfile_is_split(void)
{
return KDUMP_SPLIT();
@@ -232,44 +235,66 @@ open_dump_file(char *file)
return TRUE;
}

-void
-x86_process_elf_notes(void *note_ptr, unsigned long size_note)
+void
+process_elf32_notes(void *note_buf, unsigned long size_note)
{
- Elf32_Nhdr *note32 = NULL;
- Elf64_Nhdr *note64 = NULL;
- size_t tot, len = 0;
+ Elf32_Nhdr *nt;
+ size_t index, len = 0;
int num = 0;

- for (tot = 0; tot < size_note; tot += len) {
- if (machine_type("X86_64")) {
- note64 = note_ptr + tot;

- if (note64->n_type == NT_PRSTATUS) {
- dd->nt_prstatus_percpu[num] = note64;
- num++;
- }
+ for (index = 0; index < size_note; index += len) {
+ nt = note_buf + index;

- len = sizeof(Elf64_Nhdr);
- len = roundup(len + note64->n_namesz, 4);
- len = roundup(len + note64->n_descsz, 4);
- } else if (machine_type("X86")) {
- note32 = note_ptr + tot;
+ if(nt->n_type == NT_PRSTATUS) {
+ dd->nt_prstatus_percpu[num] = nt;
+ num++;
+ }
+ len = sizeof(Elf32_Nhdr);
+ len = roundup(len + nt->n_namesz, 4);
+ len = roundup(len + nt->n_descsz, 4);
+ }

- if (note32->n_type == NT_PRSTATUS) {
- dd->nt_prstatus_percpu[num] = note32;
- num++;
- }
+ if (num > 0) {
+ pc->flags2 |= ELF_NOTES;
+ dd->num_prstatus_notes = num;
+ }
+ return;
+}
+
+void
+process_elf64_notes(void *note_buf, unsigned long size_note)
+{
+ Elf64_Nhdr *nt;
+ size_t index, len = 0;
+ int num = 0;

- len = sizeof(Elf32_Nhdr);
- len = roundup(len + note32->n_namesz, 4);
- len = roundup(len + note32->n_descsz, 4);
+ for (index = 0; index < size_note; index += len) {
+ nt = note_buf + index;
+
+ if(nt->n_type == NT_PRSTATUS) {
+ dd->nt_prstatus_percpu[num] = nt;
+ num++;
}
+ len = sizeof(Elf64_Nhdr);
+ len = roundup(len + nt->n_namesz, 4);
+ len = roundup(len + nt->n_descsz, 4);
}

if (num > 0) {
pc->flags2 |= ELF_NOTES;
dd->num_prstatus_notes = num;
}
+ return;
+}
+
+void
+x86_process_elf_notes(void *note_ptr, unsigned long size_note)
+{
+ if (machine_type("X86_64"))
+ process_elf64_notes(note_ptr, size_note);
+ else if (machine_type("X86"))
+ process_elf32_notes(note_ptr, size_note);
}

static int

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 

Thread Tools




All times are GMT. The time now is 04:30 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org