From 6dcc69c0eb91b643f77c042db31ba23b4a67f1d6 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Wed, 26 Jul 2006 17:21:53 -0700 Subject: kexec-tools: Fix for loading files of type ET_DYN through kexec o Fix the logic to load a the files of type ET_DYN. Helpful in loading the relocatable kernel to a different address than the address executable is compiled for. --- kexec/kexec-elf-exec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'kexec/kexec-elf-exec.c') diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c index 324516c..ec00a05 100644 --- a/kexec/kexec-elf-exec.c +++ b/kexec/kexec-elf-exec.c @@ -47,7 +47,7 @@ int build_elf_exec_info(const char *buf, off_t len, struct mem_ehdr *ehdr) } -int elf_exec_load(const struct mem_ehdr *ehdr, struct kexec_info *info) +int elf_exec_load(struct mem_ehdr *ehdr, struct kexec_info *info) { unsigned long base; int result; @@ -79,8 +79,8 @@ int elf_exec_load(const struct mem_ehdr *ehdr, struct kexec_info *info) } start = phdr->p_paddr; stop = start + phdr->p_memsz; - if (start > first) { - start = first; + if (first > start) { + first = start; } if (last < stop) { last = stop; @@ -126,6 +126,10 @@ int elf_exec_load(const struct mem_ehdr *ehdr, struct kexec_info *info) phdr->p_data, size, phdr->p_paddr + base, phdr->p_memsz); } + + /* Update entry point to reflect new load address*/ + ehdr->e_entry += base; + result = 0; out: return result; -- cgit