From 3f7047db7aafd0846ccddf102aad32ea13588cfb Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Thu, 2 Jul 2020 22:33:56 +0200 Subject: kernel: mtdsplit: support ELF loader splitting To parse the ELF kernel loader, a small ELF parser is used that can handle both ELF32 or ELF64 class loaders. The splitter assumes that the kernel is always located before the rootfs, whether it is embedded in the loader or not. If the kernel is located after the rootfs on the firmware partition, then the rootfs splitter will include it in the dynamically created rootfs_data partition and the kernel will be corrupted. The kernel image is preferably embedded inside the ELF loader, so the end of the loader equals the end of the kernel partition. This is due to the way mtd_find_rootfs_from searches for the the rootfs: - if the kernel image is embedded in the loader, the appended rootfs may follow the loader immediately, within the same erase block. - if the kernel image is not embedded in the loader, but placed at some offset behind the loader (OKLI-style loader), the rootfs must be aligned to an erase-block after the loader and kernel image. In case section header table is empty, determine the elf loader size by finding the end of the last segment, as defined by the program header table. Signed-off-by: Sander Vanheule --- target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig') diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig index 0447df585c..3b7e23af33 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig @@ -79,3 +79,8 @@ config MTD_SPLIT_JIMAGE_FW bool "JBOOT Image based firmware partition parser" depends on MTD_SPLIT_SUPPORT select MTD_SPLIT + +config MTD_SPLIT_ELF_FW + bool "ELF loader firmware partition parser" + depends on MTD_SPLIT_SUPPORT + select MTD_SPLIT -- cgit v1.2.3