Commit 83c1f87cc8f865f1f55a2e476cd827aa51089e8c
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
Showing
3 changed files
with
8 additions
and
6 deletions
elf_ops.h
... | ... | @@ -177,7 +177,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab) |
177 | 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 | 181 | int must_swab, uint64_t *pentry, |
182 | 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 | 229 | if (read(fd, data, ph->p_filesz) != ph->p_filesz) |
230 | 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 | 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 | 282 | #include "elf_ops.h" |
283 | 283 | |
284 | 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 | 286 | uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr) |
287 | 287 | { |
288 | 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 | 317 | |
318 | 318 | lseek(fd, 0, SEEK_SET); |
319 | 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 | 321 | lowaddr, highaddr); |
322 | 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 | 324 | lowaddr, highaddr); |
325 | 325 | } |
326 | 326 | ... | ... |
sysemu.h
... | ... | @@ -160,7 +160,7 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; |
160 | 160 | int get_image_size(const char *filename); |
161 | 161 | int load_image(const char *filename, uint8_t *addr); /* deprecated */ |
162 | 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 | 164 | uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr); |
165 | 165 | int load_aout(const char *filename, target_phys_addr_t addr, int max_sz); |
166 | 166 | int load_uboot(const char *filename, target_ulong *ep, int *is_linux); | ... | ... |