Commit 83c1f87cc8f865f1f55a2e476cd827aa51089e8c

Authored by pbrook
1 parent 4be27dbb

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
elf_ops.h
@@ -177,7 +177,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab) @@ -177,7 +177,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab)
177 return -1; 177 return -1;
178 } 178 }
179 179
180 -static int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend, 180 +static int glue(load_elf, SZ)(int fd, int64_t address_offset,
181 int must_swab, uint64_t *pentry, 181 int must_swab, uint64_t *pentry,
182 uint64_t *lowaddr, uint64_t *highaddr) 182 uint64_t *lowaddr, uint64_t *highaddr)
183 { 183 {
@@ -229,7 +229,9 @@ static int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend, @@ -229,7 +229,9 @@ static int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
229 if (read(fd, data, ph->p_filesz) != ph->p_filesz) 229 if (read(fd, data, ph->p_filesz) != ph->p_filesz)
230 goto fail; 230 goto fail;
231 } 231 }
232 - addr = ph->p_vaddr + virt_to_phys_addend; 232 + /* address_offset is hack for kernel images that are
  233 + linked at the wrong physical address. */
  234 + addr = ph->p_paddr + address_offset;
233 235
234 cpu_physical_memory_write_rom(addr, data, mem_size); 236 cpu_physical_memory_write_rom(addr, data, mem_size);
235 237
loader.c
@@ -282,7 +282,7 @@ static void *load_at(int fd, int offset, int size) @@ -282,7 +282,7 @@ static void *load_at(int fd, int offset, int size)
282 #include "elf_ops.h" 282 #include "elf_ops.h"
283 283
284 /* return < 0 if error, otherwise the number of bytes loaded in memory */ 284 /* return < 0 if error, otherwise the number of bytes loaded in memory */
285 -int load_elf(const char *filename, int64_t virt_to_phys_addend, 285 +int load_elf(const char *filename, int64_t address_offset,
286 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr) 286 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr)
287 { 287 {
288 int fd, data_order, host_data_order, must_swab, ret; 288 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, @@ -317,10 +317,10 @@ int load_elf(const char *filename, int64_t virt_to_phys_addend,
317 317
318 lseek(fd, 0, SEEK_SET); 318 lseek(fd, 0, SEEK_SET);
319 if (e_ident[EI_CLASS] == ELFCLASS64) { 319 if (e_ident[EI_CLASS] == ELFCLASS64) {
320 - ret = load_elf64(fd, virt_to_phys_addend, must_swab, pentry, 320 + ret = load_elf64(fd, address_offset, must_swab, pentry,
321 lowaddr, highaddr); 321 lowaddr, highaddr);
322 } else { 322 } else {
323 - ret = load_elf32(fd, virt_to_phys_addend, must_swab, pentry, 323 + ret = load_elf32(fd, address_offset, must_swab, pentry,
324 lowaddr, highaddr); 324 lowaddr, highaddr);
325 } 325 }
326 326
sysemu.h
@@ -160,7 +160,7 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; @@ -160,7 +160,7 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
160 int get_image_size(const char *filename); 160 int get_image_size(const char *filename);
161 int load_image(const char *filename, uint8_t *addr); /* deprecated */ 161 int load_image(const char *filename, uint8_t *addr); /* deprecated */
162 int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz); 162 int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
163 -int load_elf(const char *filename, int64_t virt_to_phys_addend, 163 +int load_elf(const char *filename, int64_t address_offset,
164 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr); 164 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
165 int load_aout(const char *filename, target_phys_addr_t addr, int max_sz); 165 int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
166 int load_uboot(const char *filename, target_ulong *ep, int *is_linux); 166 int load_uboot(const char *filename, target_ulong *ep, int *is_linux);