aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-22 18:20:20 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-22 18:20:20 +0000
commit83c1f87cc8f865f1f55a2e476cd827aa51089e8c (patch)
treed0e3668ef58d9947a49a2ea8a6946fdf14482d19
parent4be27dbbde2aed1da305b83043caa6f0f0ca4309 (diff)
Use load address when loading ELF images.
Signed-off-by: Paul Brook <paul@codesourcery.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5513 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--elf_ops.h6
-rw-r--r--loader.c6
-rw-r--r--sysemu.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/elf_ops.h b/elf_ops.h
index 72fed1caaa..feea12f261 100644
--- a/elf_ops.h
+++ b/elf_ops.h
@@ -177,7 +177,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab)
return -1;
}
-static int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
+static int glue(load_elf, SZ)(int fd, int64_t address_offset,
int must_swab, uint64_t *pentry,
uint64_t *lowaddr, uint64_t *highaddr)
{
@@ -229,7 +229,9 @@ static int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
if (read(fd, data, ph->p_filesz) != ph->p_filesz)
goto fail;
}
- addr = ph->p_vaddr + virt_to_phys_addend;
+ /* address_offset is hack for kernel images that are
+ linked at the wrong physical address. */
+ addr = ph->p_paddr + address_offset;
cpu_physical_memory_write_rom(addr, data, mem_size);
diff --git a/loader.c b/loader.c
index 289ba0f028..872290957c 100644
--- a/loader.c
+++ b/loader.c
@@ -282,7 +282,7 @@ static void *load_at(int fd, int offset, int size)
#include "elf_ops.h"
/* return < 0 if error, otherwise the number of bytes loaded in memory */
-int load_elf(const char *filename, int64_t virt_to_phys_addend,
+int load_elf(const char *filename, int64_t address_offset,
uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr)
{
int fd, data_order, host_data_order, must_swab, ret;
@@ -317,10 +317,10 @@ int load_elf(const char *filename, int64_t virt_to_phys_addend,
lseek(fd, 0, SEEK_SET);
if (e_ident[EI_CLASS] == ELFCLASS64) {
- ret = load_elf64(fd, virt_to_phys_addend, must_swab, pentry,
+ ret = load_elf64(fd, address_offset, must_swab, pentry,
lowaddr, highaddr);
} else {
- ret = load_elf32(fd, virt_to_phys_addend, must_swab, pentry,
+ ret = load_elf32(fd, address_offset, must_swab, pentry,
lowaddr, highaddr);
}
diff --git a/sysemu.h b/sysemu.h
index 57ba19e65d..976fecc8d7 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -160,7 +160,7 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
int get_image_size(const char *filename);
int load_image(const char *filename, uint8_t *addr); /* deprecated */
int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
-int load_elf(const char *filename, int64_t virt_to_phys_addend,
+int load_elf(const char *filename, int64_t address_offset,
uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
int load_uboot(const char *filename, target_ulong *ep, int *is_linux);