summaryrefslogtreecommitdiffstats
path: root/arch/mips/lib
diff options
context:
space:
mode:
authorClement Leger <cleger@kalray.eu>2020-06-12 09:10:33 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-06-15 16:15:05 +0200
commit7a7cc824c7d748eb6b6821c2fcdb04074cede97b (patch)
treea21fadd505976de6d6fa7e7ef9c3d076648dc311 /arch/mips/lib
parent860fbba93e53666ca46dd92dedfda43c9c426931 (diff)
downloadbarebox-7a7cc824c7d748eb6b6821c2fcdb04074cede97b.tar.gz
barebox-7a7cc824c7d748eb6b6821c2fcdb04074cede97b.tar.xz
common: elf: load elf directly from file
Currently, elf file must be loaded into a buffer and then passed to elf_load_image. This requires to copy the whole elf file before booting it. This commit allows to pass the filename directly and will allocate data only for the elf header (elf header + program headers). This will then be used to load the elf data from the file without copying it in an intermediate buffer. Elf segments are first parsed into a list and are then loaded from the file in a second time. 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 'arch/mips/lib')
-rw-r--r--arch/mips/lib/bootm.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 5bb09cc2de..b07884ae02 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -47,14 +47,10 @@ static int do_bootm_elf(struct image_data *data)
{
void (*entry)(int, void *);
struct elf_image *elf;
- void *fdt, *buf;
+ void *fdt;
int ret = 0;
- buf = read_file(data->os_file, NULL);
- if (!buf)
- return -EINVAL;
-
- elf = elf_load_image(buf);
+ elf = elf_load_image(data->os_file);
if (IS_ERR(elf))
return PTR_ERR(elf);
@@ -82,7 +78,6 @@ static int do_bootm_elf(struct image_data *data)
bootm_elf_done:
elf_release_image(elf);
free(fdt);
- free(buf);
return ret;
}