diff options
author | Clement Leger <cleger@kalray.eu> | 2020-06-12 09:10:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-15 16:14:33 +0200 |
commit | 588255910d570aa37328489cbb314cc39e6dc1b7 (patch) | |
tree | b2fca9573db4072304026dafca16dfff2bc00dc5 /common | |
parent | 6c1e7688df94a9d4dfebeb62266f7fc91c209d8a (diff) | |
download | barebox-588255910d570aa37328489cbb314cc39e6dc1b7.tar.gz barebox-588255910d570aa37328489cbb314cc39e6dc1b7.tar.xz |
common: elf: add computation of elf boundaries
In order to correctly load an initrd or a device tree after an elf file,
we need to know its boundaries. This commit adds support for that and
allow the bootm implementations to use it for memory loading.
Signed-off-by: Clement Leger <cleger@kalray.eu>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/elf.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/common/elf.c b/common/elf.c index 4733accb05..d64de401c4 100644 --- a/common/elf.c +++ b/common/elf.c @@ -59,6 +59,11 @@ static int load_elf_phdr_segment(struct elf_image *elf, void *src, if (!p_filesz) return 0; + if (dst < elf->low_addr) + elf->low_addr = dst; + if (dst + p_memsz > elf->high_addr) + elf->high_addr = dst + p_memsz; + pr_debug("Loading phdr to 0x%p (%llu bytes)\n", dst, p_filesz); ret = elf_request_region(elf, (resource_size_t)dst, p_filesz); @@ -124,6 +129,8 @@ struct elf_image *elf_load_image(void *buf) INIT_LIST_HEAD(&elf->list); elf->buf = buf; + elf->low_addr = (void *) (unsigned long) -1; + elf->high_addr = 0; ret = elf_check_image(elf); if (ret) |