summaryrefslogtreecommitdiffstats
path: root/common/elf.c
Commit message (Collapse)AuthorAgeFilesLines
* common: elf: add elf_open, elf_close and elf_loadClement Leger2020-06-151-13/+7
| | | | | | | | | In order to integrate elf loading into bootm command, split elf opening from elf 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>
* common: elf: load elf directly from fileClement Leger2020-06-151-35/+185
| | | | | | | | | | | | | | 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>
* common: elf: check number of elf program headersClement Leger2020-06-151-0/+5
| | | | | | | | | An elf file without program headers should not be loaded. Add a check for such cases. 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>
* common: elf: use calloc instead of xzallocClement Leger2020-06-151-1/+4
| | | | | | | | This failure can be handled grecefully, use standard calloc. 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>
* common: elf: fix warning on 32 bits architecturesClement Leger2020-06-151-1/+1
| | | | | | | | | | | When pointers are 32 bits wide and we cast a potentially 64 bits value in it, the compiler will yield an error. Cast that value first into a phys_addr_t to match the architecture pointer size and then in a void *. 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>
* common: elf: add computation of elf boundariesClement Leger2020-06-151-0/+7
| | | | | | | | | | 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>
* elf: add 64 bits elf loading supportClement Leger2019-09-061-22/+23
| | | | | | | | | | | | | | | | This patch add elf64 loading support to the elf loader. Since elf32 and elf64 uses completely different types, to avoid copying all the code and simply replace elf32 with elf64, use a macro which will return the appropriate field for each type of header. This macro generates getter for elf structures according to the class of the loaded elf. All direct elf struct dereference are then replaced by call to generated functions. This allows to keep a common loader code even if types are different. Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* add basic ELF parserOleksij Rempel2018-06-181-0/+145
This parser is needed for kernel boot support on MIPS and can potentially reused on other platforms. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>