summaryrefslogtreecommitdiff
path: root/kexec/kexec-elf-rel.c
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2012-03-08 14:39:38 +0800
committerSimon Horman <horms@verge.net.au>2012-03-15 15:09:41 +0900
commit28d4ab53280853d2aeefdfb7c369331e89ab9ac2 (patch)
treec4dcab7622680c57bfc499c36b9271335ffea45e /kexec/kexec-elf-rel.c
parentf1facd4b11aa141ffd9bbacb2631ad18dc33669c (diff)
downloadkexec-tools-28d4ab53280853d2aeefdfb7c369331e89ab9ac2.tar.gz
Add generic debug option
Currently the debugging code is under #ifdef DEBUG, which means when we want to debug, we have to re-compile the source code with -DDEBUG. This is not convenient, we want to have a generic --debug option so that we can enable debugging code without re-compiling. This patch moves the arch-specific --debug to generic place and moves code under #ifdef DEBUG to --debug on x86. BTW, the size of kexec binary increases very little after this patch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec-elf-rel.c')
-rw-r--r--kexec/kexec-elf-rel.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
index f102fb8..c04c972 100644
--- a/kexec/kexec-elf-rel.c
+++ b/kexec/kexec-elf-rel.c
@@ -363,8 +363,8 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
name = ehdr->e_shdr[ehdr->e_shstrndx].sh_data;
name += ehdr->e_shdr[sym.st_shndx].sh_name;
}
-#ifdef DEBUG
- fprintf(stderr, "sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n",
+
+ dbgprintf("sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n",
name,
sym.st_info,
sym.st_other,
@@ -372,7 +372,6 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
sym.st_value,
sym.st_size);
-#endif
if (sym.st_shndx == STN_UNDEF) {
/*
* NOTE: ppc64 elf .ro shows up a UNDEF section.
@@ -405,10 +404,10 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
value = sym.st_value;
value += sec_base;
value += rel.r_addend;
-#ifdef DEBUG
- fprintf(stderr, "sym: %s value: %lx addr: %lx\n",
+
+ dbgprintf("sym: %s value: %lx addr: %lx\n",
name, value, address);
-#endif
+
machine_apply_elf_rel(ehdr, rel.r_type,
(void *)location, address, value);
}