aboutsummaryrefslogtreecommitdiffstats
path: root/hw/loader.c
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2010-03-14 21:20:59 +0100
committerAurelien Jarno <aurelien@aurel32.net>2010-03-16 08:38:05 +0100
commit409dbce54b57b85bd229174da86d77ca08508508 (patch)
tree61aaddb4700595752b34e01db383074463336329 /hw/loader.c
parentcb66ffcf9e298dc1bfc11682172ff9472bcd4495 (diff)
load_elf: replace the address addend by a translation function
A few machines need to translate the ELF header addresses into physical addresses. Currently the only possibility is to add a value to the addresses. This patch replaces the addend argument by and a translation function and an opaque passed to the function. A NULL function does not translate the address. The patch also convert all machines that have an addend, simplify the PowerPC kernel loading and fix the MIPS kernel loading using this new feature. Other machines may benefit from this feature. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'hw/loader.c')
-rw-r--r--hw/loader.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/hw/loader.c b/hw/loader.c
index 1448887e5..79a6f9518 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -276,9 +276,9 @@ 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 address_offset,
- uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr,
- int big_endian, int elf_machine, int clear_lsb)
+int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),
+ void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr,
+ uint64_t *highaddr, int big_endian, int elf_machine, int clear_lsb)
{
int fd, data_order, target_data_order, must_swab, ret;
uint8_t e_ident[EI_NIDENT];
@@ -312,11 +312,11 @@ int load_elf(const char *filename, int64_t address_offset,
lseek(fd, 0, SEEK_SET);
if (e_ident[EI_CLASS] == ELFCLASS64) {
- ret = load_elf64(filename, fd, address_offset, must_swab, pentry,
- lowaddr, highaddr, elf_machine, clear_lsb);
+ ret = load_elf64(filename, fd, translate_fn, translate_opaque, must_swab,
+ pentry, lowaddr, highaddr, elf_machine, clear_lsb);
} else {
- ret = load_elf32(filename, fd, address_offset, must_swab, pentry,
- lowaddr, highaddr, elf_machine, clear_lsb);
+ ret = load_elf32(filename, fd, translate_fn, translate_opaque, must_swab,
+ pentry, lowaddr, highaddr, elf_machine, clear_lsb);
}
close(fd);