aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elf_ops.h6
-rw-r--r--loader.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/elf_ops.h b/elf_ops.h
index 173d12f05a..646a569b28 100644
--- a/elf_ops.h
+++ b/elf_ops.h
@@ -159,7 +159,7 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
goto fail;
if (pentry)
- *pentry = (uint64_t)ehdr.e_entry;
+ *pentry = (uint64_t)(elf_sword)ehdr.e_entry;
glue(load_symbols, SZ)(&ehdr, fd, must_swab);
@@ -206,9 +206,9 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
}
qemu_free(phdr);
if (lowaddr)
- *lowaddr = (uint64_t)low;
+ *lowaddr = (uint64_t)(elf_sword)low;
if (highaddr)
- *highaddr = (uint64_t)high;
+ *highaddr = (uint64_t)(elf_sword)high;
return total_size;
fail:
qemu_free(data);
diff --git a/loader.c b/loader.c
index 40bcaf6204..c39cb55352 100644
--- a/loader.c
+++ b/loader.c
@@ -173,6 +173,7 @@ static void *load_at(int fd, int offset, int size)
#define SZ 32
#define elf_word uint32_t
+#define elf_sword int32_t
#define bswapSZs bswap32s
#include "elf_ops.h"
@@ -182,6 +183,7 @@ static void *load_at(int fd, int offset, int size)
#undef elf_sym
#undef elf_note
#undef elf_word
+#undef elf_sword
#undef bswapSZs
#undef SZ
#define elfhdr elf64_hdr
@@ -190,6 +192,7 @@ static void *load_at(int fd, int offset, int size)
#define elf_shdr elf64_shdr
#define elf_sym elf64_sym
#define elf_word uint64_t
+#define elf_sword int64_t
#define bswapSZs bswap64s
#define SZ 64
#include "elf_ops.h"