support loading executable tasks on nommu systems - useful for debugging tasks
with hardware debuggers that can't relocate debug info
---
boot/common/elf.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/boot/common/elf.c b/boot/common/elf.c
index 2c1fbc3..f963edb 100755
--- a/boot/common/elf.c
+++ b/boot/common/elf.c
@@ -58,11 +58,14 @@ static int load_executable(char *img, struct img_info *info)
u_int phys_base;
int i;
- phys_base = load_base;
ehdr = (Elf32_Ehdr *)img;
phdr = (Elf32_Phdr *)((u_long)ehdr + ehdr->e_phoff);
- info->phys = load_base;
+#ifdef CONFIG_MMU
phys_base = load_base;
+#else
+ phys_base = (u_long)virt_to_phys(phdr->p_vaddr);
+#endif
+ info->phys = phys_base;
elf_dbg("phys addr=%x\n", phys_base);
/* find ksyms */
@@ -101,25 +104,31 @@ static int load_executable(char *img, struct img_info
*info)
info->data_size = phdr->p_filesz;
info->bss_size = phdr->p_memsz - phdr->p_filesz;
info->bss = info->data + info->data_size;
- load_base = phys_base + (info->data - info->text);
+ phys_base += (info->data - info->text);
}
if (phdr->p_filesz > 0) {
- memcpy((char *)load_base, img + phdr->p_offset,
+ memcpy((char *)phys_base, img + phdr->p_offset,
phdr->p_filesz);
elf_dbg("load: offset=%x size=%x\n",
- load_base, (int)phdr->p_filesz);
+ phys_base, (int)phdr->p_filesz);
}
if (!(phdr->p_flags & PF_X)) {
if (info->bss_size > 0) {
/* Zero fill BSS */
- memset((char *)load_base + info->data_size,
+ memset((char *)phys_base + info->data_size,
0, info->bss_size);
}
- load_base += phdr->p_memsz;
+ phys_base += phdr->p_memsz;
}
}
- load_base = PAGE_ALIGN(load_base);
- info->size = load_base - info->phys;
+ phys_base = PAGE_ALIGN(phys_base);
+#ifndef CONFIG_MMU
+ if (nr_img == 0)
+#endif
+ {
+ load_base = phys_base;
+ }
+ info->size = phys_base - info->phys;
info->entry = ehdr->e_entry;
elf_dbg("info size=%x entry=%x\n", info->size, info->entry);
return 0;
--
1.5.0.3.GIT
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Prex-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/prex-devel