cmd: bootm: add ELF file support
PATCH 1/1 cmd: bootm: add ELF file support
Some operating systems (e.g. seL4) and embedded applications are ELF images. It is convenient to use FIT-images to implement trusted boot. Added "elf" image type for booting using bootm command.
--- boot/bootm_os.c | 21 +++++++++++++++++++++ boot/image-fit.c | 3 ++- boot/image.c | 3 +++ include/image.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-)
boot/bootm_os.c +21 -0
@@ -395,6 +395,24 @@ static int do_bootm_qnxelf(int flag, struct bootm_info *bmi) }#endif +#if defined(CONFIG_CMD_ELF ) +static int do_bootm_elf (int flag,struct bootm_info *bmi) +{ +struct bootm_headers *images = bmi->images; +char *local_args[2 ] = {NULL }; +char str[19 ] ="" ;/* "0x" + 16 digits + "\0" */ + +sprintf (str,"0x%lx" , images->ep);/* write entry-point into string */ + str[18 ] ='\0' ; + local_args[0 ] = bmi->argv[0 ]; + local_args[1 ] = str;/* and provide it via the arguments */ + +do_bootelf (NULL ,0 ,2 , local_args); + +return 1 ; +} +#endif +#ifdef CONFIG_INTEGRITY static int do_bootm_integrity (int flag,struct bootm_info *bmi) {
@@ -536,6 +554,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_EFI [IH_OS_EFI] = do_bootm_efi,#endif +#if defined(CONFIG_CMD_ELF ) + [IH_OS_ELF] = do_bootm_elf, +#endif };/* Allow for arch specific config before we boot */
boot/image-fit.c +2 -1
@@ -2180,7 +2180,8 @@ int fit_image_load(struct bootm_headers *images, ulong addr,fit_image_check_os (fit, noffset,IH_OS_TEE ) ||fit_image_check_os (fit, noffset,IH_OS_OPENRTOS ) ||fit_image_check_os (fit, noffset,IH_OS_EFI ) || -fit_image_check_os (fit, noffset,IH_OS_VXWORKS ); +fit_image_check_os (fit, noffset,IH_OS_VXWORKS ) || +fit_image_check_os (fit, noffset,IH_OS_ELF );/* * If either of the checks fail, we should report an error, but
boot/image.c +3 -0
@@ -134,6 +134,9 @@ static const table_entry_t uimage_os[] = {#endif { IH_OS_OPENSBI, "opensbi", "RISC-V OpenSBI", }, { IH_OS_EFI, "efi", "EFI Firmware" }, +#ifdef CONFIG_CMD_ELF + { IH_OS_ELF, "elf", "ELF Image" }, +#endif { -1, "", "", }, };
include/image.h +1 -0
@@ -100,6 +100,7 @@ enum {IH_OS_TEE ,/* Trusted Execution Environment */ IH_OS_OPENSBI ,/* RISC-V OpenSBI */ IH_OS_EFI ,/* EFI Firmware (e.g. GRUB2) */ +IH_OS_ELF ,/* ELF Image (e.g. seL4) */ IH_OS_COUNT, };
Signature · 1 line
2.39.2
Hi Maxim,
Quoted 5 lines · Maxim Moskalets
[You don't often get email from [email protected]. Learn why this is important at https://cas5-0-urlprotect.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2faka.ms%2fLearnAboutSenderIdentification&umid=d3728a4f-0e7b-4ded-94bc-5bd133b6deef&auth=d807158c60b7d2502abde8a2fc01f40662980862-7a67d937c0016d0d3292f79af55f0ce3d78f480b ]
Some operating systems (e.g. seL4) and embedded applications are ELF images. It is convenient to use FIT-images to implement trusted boot. Added "elf" image type for booting using bootm command.
Why not use objcopy to create a binary?
--Sean
Quoted 88 lines
Signed-off-by Maxim Moskalets <[email protected]>--- boot/bootm_os.c | 21 +++++++++++++++++++++ boot/image-fit.c | 3 ++- boot/image.c | 3 +++ include/image.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-)boot/bootm_os.c +21
-0@@ -395,6 +395,24 @@ static int do_bootm_qnxelf(int flag, struct bootm_info *bmi) }#endif +#if defined(CONFIG_CMD_ELF ) +static int do_bootm_elf (int flag,struct bootm_info *bmi) +{ +struct bootm_headers *images = bmi->images; +char *local_args[2 ] = {NULL }; +char str[19 ] ="" ;/* "0x" + 16 digits + "\0" */ + +sprintf (str,"0x%lx" , images->ep);/* write entry-point into string */ + str[18 ] ='\0' ; + local_args[0 ] = bmi->argv[0 ]; + local_args[1 ] = str;/* and provide it via the arguments */ + +do_bootelf (NULL ,0 ,2 , local_args); + +return 1 ; +} +#endif +#ifdef CONFIG_INTEGRITY static int do_bootm_integrity (int flag,struct bootm_info *bmi) {@@ -536,6 +554,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_EFI [IH_OS_EFI] = do_bootm_efi,#endif +#if defined(CONFIG_CMD_ELF ) + [IH_OS_ELF] = do_bootm_elf, +#endif };/* Allow for arch specific config before we boot */ boot/image-fit.c +2
-1@@ -2180,7 +2180,8 @@ int fit_image_load(struct bootm_headers *images, ulong addr,fit_image_check_os (fit, noffset,IH_OS_TEE ) ||fit_image_check_os (fit, noffset,IH_OS_OPENRTOS ) ||fit_image_check_os (fit, noffset,IH_OS_EFI ) || -fit_image_check_os (fit, noffset,IH_OS_VXWORKS ); +fit_image_check_os (fit, noffset,IH_OS_VXWORKS ) || +fit_image_check_os (fit, noffset,IH_OS_ELF );/* * If either of the checks fail, we should report an error, but boot/image.c +3
-0@@ -134,6 +134,9 @@ static const table_entry_t uimage_os[] = {#endif { IH_OS_OPENSBI, "opensbi", "RISC-V OpenSBI", }, { IH_OS_EFI, "efi", "EFI Firmware" }, +#ifdef CONFIG_CMD_ELF + { IH_OS_ELF, "elf", "ELF Image" }, +#endif { -1, "", "", }, };include/image.h +1
-1@@ -100,6 +100,7 @@ enum {IH_OS_TEE ,/* Trusted Execution Environment */ IH_OS_OPENSBI ,/* RISC-V OpenSBI */ IH_OS_EFI ,/* EFI Firmware (e.g. GRUB2) */ +IH_OS_ELF ,/* ELF Image (e.g. seL4) */ IH_OS_COUNT, }; --
Quoted 2 lines
2.39.2
[Embedded World 2024, SECO SpA]<https://www.messe-ticket.de/Nuernberg/embeddedworld2024/Register/ew24517689>
Hi Sean
Quoted 11 lines · Sean Anderson
Hi Maxim,
Quoted 5 lines · Maxim Moskalets
[You don't often get email from [email protected]. Learn why this is important at https://cas5-0-urlprotect.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2faka.ms%2fLearnAboutSenderIdentification&umid=d3728a4f-0e7b-4ded-94bc-5bd133b6deef&auth=d807158c60b7d2502abde8a2fc01f40662980862-7a67d937c0016d0d3292f79af55f0ce3d78f480b ]
Some operating systems (e.g. seL4) and embedded applications are ELF images. It is convenient to use FIT-images to implement trusted boot. Added "elf" image type for booting using bootm command.
Why not use objcopy to create a binary?
--Sean
When expanding ELF to binary, the size can grow significantly due to the layout of the file.
ELF is also more convenient for debugging due to its clear structure and ease of getting symbols and other debugging information.
--Maxim
Quoted 92 lines
Quoted 88 lines
Signed-off-by Maxim Moskalets <[email protected]>--- boot/bootm_os.c | 21 +++++++++++++++++++++ boot/image-fit.c | 3 ++- boot/image.c | 3 +++ include/image.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-)boot/bootm_os.c +21
-0@@ -395,6 +395,24 @@ static int do_bootm_qnxelf(int flag, struct bootm_info *bmi) }#endif +#if defined(CONFIG_CMD_ELF ) +static int do_bootm_elf (int flag,struct bootm_info *bmi) +{ +struct bootm_headers *images = bmi->images; +char *local_args[2 ] = {NULL }; +char str[19 ] ="" ;/* "0x" + 16 digits + "\0" */ + +sprintf (str,"0x%lx" , images->ep);/* write entry-point into string */ + str[18 ] ='\0' ; + local_args[0 ] = bmi->argv[0 ]; + local_args[1 ] = str;/* and provide it via the arguments */ + +do_bootelf (NULL ,0 ,2 , local_args); + +return 1 ; +} +#endif +#ifdef CONFIG_INTEGRITY static int do_bootm_integrity (int flag,struct bootm_info *bmi) {@@ -536,6 +554,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_EFI [IH_OS_EFI] = do_bootm_efi,#endif +#if defined(CONFIG_CMD_ELF ) + [IH_OS_ELF] = do_bootm_elf, +#endif };/* Allow for arch specific config before we boot */ boot/image-fit.c +2
-1@@ -2180,7 +2180,8 @@ int fit_image_load(struct bootm_headers *images, ulong addr,fit_image_check_os (fit, noffset,IH_OS_TEE ) ||fit_image_check_os (fit, noffset,IH_OS_OPENRTOS ) ||fit_image_check_os (fit, noffset,IH_OS_EFI ) || -fit_image_check_os (fit, noffset,IH_OS_VXWORKS ); +fit_image_check_os (fit, noffset,IH_OS_VXWORKS ) || +fit_image_check_os (fit, noffset,IH_OS_ELF );/* * If either of the checks fail, we should report an error, but boot/image.c +3
-0@@ -134,6 +134,9 @@ static const table_entry_t uimage_os[] = {#endif { IH_OS_OPENSBI, "opensbi", "RISC-V OpenSBI", }, { IH_OS_EFI, "efi", "EFI Firmware" }, +#ifdef CONFIG_CMD_ELF + { IH_OS_ELF, "elf", "ELF Image" }, +#endif { -1, "", "", }, };include/image.h +1
-1@@ -100,6 +100,7 @@ enum {IH_OS_TEE ,/* Trusted Execution Environment */ IH_OS_OPENSBI ,/* RISC-V OpenSBI */ IH_OS_EFI ,/* EFI Firmware (e.g. GRUB2) */ +IH_OS_ELF ,/* ELF Image (e.g. seL4) */ IH_OS_COUNT, }; --Quoted 2 lines
2.39.2
[Embedded World 2024, SECO SpA]<https://www.messe-ticket.de/Nuernberg/embeddedworld2024/Register/ew24517689>