diff options
| author | Paul Brook <paul@codesourcery.com> | 2009-06-05 15:16:41 +0100 |
|---|---|---|
| committer | Paul Brook <paul@codesourcery.com> | 2009-06-05 15:16:41 +0100 |
| commit | fd93a79999c728dd1f30bb2e726ce12bdf704e6d (patch) | |
| tree | 9b998d52093eaee9b0a55cb394e3abc34f327ded | |
| parent | bdb11366b9370e97fb436444c697c01fe839dc11 (diff) | |
| download | focaccia-qemu-fd93a79999c728dd1f30bb2e726ce12bdf704e6d.tar.gz focaccia-qemu-fd93a79999c728dd1f30bb2e726ce12bdf704e6d.zip | |
Fix elf loader range checking
The ELF loader tracks the range of addresses used by a binary. However this incorrectly assumes zero is not a valid address. Signed-off-by: Paul Brook <paul@codesourcery.com>
| -rw-r--r-- | elf_ops.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/elf_ops.h b/elf_ops.h index 485442a935..72cd83eb74 100644 --- a/elf_ops.h +++ b/elf_ops.h @@ -185,7 +185,7 @@ static int glue(load_elf, SZ)(int fd, int64_t address_offset, struct elf_phdr *phdr = NULL, *ph; int size, i, total_size; elf_word mem_size; - uint64_t addr, low = 0, high = 0; + uint64_t addr, low = (uint64_t)-1, high = 0; uint8_t *data = NULL; if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) @@ -249,9 +249,9 @@ static int glue(load_elf, SZ)(int fd, int64_t address_offset, cpu_physical_memory_write_rom(addr, data, mem_size); total_size += mem_size; - if (!low || addr < low) + if (addr < low) low = addr; - if (!high || (addr + mem_size) > high) + if ((addr + mem_size) > high) high = addr + mem_size; qemu_free(data); |