diff mbox series

[RFC,u-boot-mvebu,45/59] tools: mkimage: Do not fill legacy_img_hdr for non-legacy XIP images

Message ID 20230221201925.9644-46-pali@kernel.org
State Accepted
Commit 27670acaac82f370b635f1af103594a335322bcf
Delegated to: Stefan Roese
Headers show
Series arm: mvebu: Various fixes | expand

Commit Message

Pali Rohár Feb. 21, 2023, 8:19 p.m. UTC
Skip filling legacy_img_hdr structure for XIP images which do not use
legacy_img_hdr structure header. Adding unwanted header to other image
formats, like kwbimage cause generation of broken image.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 tools/mkimage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 30c6df77081f..955a1f39a419 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -842,7 +842,9 @@  copy_file (int ifd, const char *datafile, int pad)
 		exit (EXIT_FAILURE);
 	}
 
-	if (params.xflag) {
+	if (params.xflag &&
+	    (((params.type > IH_TYPE_INVALID) && (params.type < IH_TYPE_FLATDT)) ||
+	     (params.type == IH_TYPE_KERNEL_NOLOAD) || (params.type == IH_TYPE_FIRMWARE_IVT))) {
 		unsigned char *p = NULL;
 		/*
 		 * XIP: do not append the struct legacy_img_hdr at the