summaryrefslogtreecommitdiff
path: root/kexec
diff options
context:
space:
mode:
authorHorms <horms@verge.net.au>2006-12-20 15:55:10 +0900
committerSimon Horman <horms@verge.net.au>2006-12-21 15:29:17 +0900
commitcdab051ce335c98e265a7824280755368799bd7a (patch)
treeabaebbb28b99d8aef41c4b903fd36092a77ac111 /kexec
parent1f0c1b411631a4ae320a7b450adee8475a8a0e92 (diff)
kexec-tool: Use the appropriate format in debug print statements
Use the appropriate format in debug print statements. This is kind of messy because the same code is compiled with different definitions of the PHDR type. The solution below is the best I can think of at this time. Cc: Magnus Damm <magnus.damm@gmail.com> Cc: Sachin P. Sant <sachinp@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r--kexec/crashdump-elf.c41
-rw-r--r--kexec/crashdump.c4
2 files changed, 29 insertions, 16 deletions
diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index 5ec5a07..e702a53 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -3,6 +3,26 @@
#error FUNC, EHDR and PHDR must be defined
#endif
+#if (ELF_WIDTH == 64)
+#define dfprintf_phdr(fh, prefix, phdr) \
+do { \
+ dfprintf((fh), \
+ "%s: p_type = %u, p_offset = 0x%lx p_paddr = 0x%lx " \
+ "p_vaddr = 0x%lx p_filesz = 0x%lx p_memsz = 0x%lx\n", \
+ (prefix), (phdr)->p_type, (phdr)->p_offset, (phdr)->p_paddr, \
+ (phdr)->p_vaddr, (phdr)->p_filesz, (phdr)->p_memsz); \
+} while(0)
+#else
+#define dfprintf_phdr(fh, prefix, phdr) \
+do { \
+ dfprintf((fh), \
+ "%s: p_type = %u, p_offset = 0x%x " "p_paddr = 0x%x " \
+ "p_vaddr = 0x%x p_filesz = 0x%x p_memsz = 0x%x\n", \
+ (prefix), (phdr)->p_type, (phdr)->p_offset, (phdr)->p_paddr, \
+ (phdr)->p_vaddr, (phdr)->p_filesz, (phdr)->p_memsz); \
+} while(0)
+#endif
+
/* Prepares the crash memory headers and stores in supplied buffer. */
int FUNC(struct kexec_info *info,
struct crash_elf_info *elf_info,
@@ -120,11 +140,7 @@ int FUNC(struct kexec_info *info,
/* Increment number of program headers. */
(elf->e_phnum)++;
- dfprintf(stdout, "Elf header: p_type = %d, p_offset = 0x%lx "
- "p_paddr = 0x%lx p_vaddr = 0x%lx "
- "p_filesz = 0x%lx p_memsz = 0x%lx\n",
- phdr->p_type, phdr->p_offset, phdr->p_paddr,
- phdr->p_vaddr, phdr->p_filesz, phdr->p_memsz);
+ dfprintf_phdr(stdout, "Elf header", phdr);
}
/* Setup an PT_LOAD type program header for the region where
@@ -141,12 +157,7 @@ int FUNC(struct kexec_info *info,
phdr->p_filesz = phdr->p_memsz = info->kern_size;
phdr->p_align = 0;
(elf->e_phnum)++;
- dfprintf(stdout, "Kernel text Elf header: "
- "p_type = %d, p_offset = 0x%lx "
- "p_paddr = 0x%lx p_vaddr = 0x%lx "
- "p_filesz = 0x%lx p_memsz = 0x%lx\n",
- phdr->p_type, phdr->p_offset, phdr->p_paddr,
- phdr->p_vaddr, phdr->p_filesz, phdr->p_memsz);
+ dfprintf_phdr(stdout, "Kernel text Elf header", phdr);
}
/* Setup PT_LOAD type program header for every system RAM chunk.
@@ -187,11 +198,9 @@ int FUNC(struct kexec_info *info,
/* Increment number of program headers. */
(elf->e_phnum)++;
- dfprintf(stdout, "Elf header: p_type = %d, p_offset = 0x%lx "
- "p_paddr = 0x%lx p_vaddr = 0x%lx "
- "p_filesz = 0x%lx p_memsz = 0x%lx\n",
- phdr->p_type, phdr->p_offset, phdr->p_paddr,
- phdr->p_vaddr, phdr->p_filesz, phdr->p_memsz);
+ dfprintf_phdr(stdout, "Elf header", phdr);
}
return 0;
}
+
+#undef dfprintf_phdr
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 1cb8123..f6fd911 100644
--- a/kexec/crashdump.c
+++ b/kexec/crashdump.c
@@ -31,18 +31,22 @@
/* include "crashdump-elf.c" twice to create two functions from one */
+#define ELF_WIDTH 64
#define FUNC crash_create_elf64_headers
#define EHDR Elf64_Ehdr
#define PHDR Elf64_Phdr
#include "crashdump-elf.c"
+#undef ELF_WIDTH
#undef PHDR
#undef EHDR
#undef FUNC
+#define ELF_WIDTH 32
#define FUNC crash_create_elf32_headers
#define EHDR Elf32_Ehdr
#define PHDR Elf32_Phdr
#include "crashdump-elf.c"
+#undef ELF_WIDTH
#undef PHDR
#undef EHDR
#undef FUNC