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.
---

Signed-off-by: Vivek Goyal <[EMAIL PROTECTED]>
---


diff -puN kexec/kexec-elf-exec.c~kexec-tools-shared-object 
kexec/kexec-elf-exec.c
--- kexec-tools-1.101/kexec/kexec-elf-exec.c~kexec-tools-shared-object  
2006-07-26 17:09:26.000000000 -0700
+++ kexec-tools-1.101-root/kexec/kexec-elf-exec.c       2006-07-26 
17:14:22.000000000 -0700
@@ -47,7 +47,7 @@ int build_elf_exec_info(const char *buf,
 }
 
 
-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 
                        }
                        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 
                        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;
diff -puN kexec/kexec-elf.h~kexec-tools-shared-object kexec/kexec-elf.h
--- kexec-tools-1.101/kexec/kexec-elf.h~kexec-tools-shared-object       
2006-07-26 17:09:26.000000000 -0700
+++ kexec-tools-1.101-root/kexec/kexec-elf.h    2006-07-26 17:09:26.000000000 
-0700
@@ -89,7 +89,7 @@ extern int build_elf_info(const char *bu
 extern int build_elf_exec_info(const char *buf, off_t len, struct mem_ehdr 
*ehdr);
 extern int build_elf_rel_info(const char *buf, off_t len, struct mem_ehdr 
*ehdr);
 
-extern int elf_exec_load(const struct mem_ehdr *ehdr, struct kexec_info *info);
+extern int elf_exec_load(struct mem_ehdr *ehdr, struct kexec_info *info);
 extern int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
        unsigned long min, unsigned long max, int end);
 
_
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to