Module Name: src Committed By: skrll Date: Wed Jan 1 10:35:10 UTC 2020
Modified Files: src/usr.bin/mkubootimage: mkubootimage.c Log Message: Adjust image size appropriately when using update_image OK jmcneill To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mkubootimage/mkubootimage.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/mkubootimage/mkubootimage.c diff -u src/usr.bin/mkubootimage/mkubootimage.c:1.27 src/usr.bin/mkubootimage/mkubootimage.c:1.28 --- src/usr.bin/mkubootimage/mkubootimage.c:1.27 Sat Dec 7 12:34:17 2019 +++ src/usr.bin/mkubootimage/mkubootimage.c Wed Jan 1 10:35:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mkubootimage.c,v 1.27 2019/12/07 12:34:17 wiz Exp $ */ +/* $NetBSD: mkubootimage.c,v 1.28 2020/01/01 10:35:10 skrll Exp $ */ /*- * Copyright (c) 2010 Jared D. McNeill <jmcne...@invisible.ca> @@ -30,7 +30,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: mkubootimage.c,v 1.27 2019/12/07 12:34:17 wiz Exp $"); +__RCSID("$NetBSD: mkubootimage.c,v 1.28 2020/01/01 10:35:10 skrll Exp $"); #include <sys/mman.h> #include <sys/stat.h> @@ -334,7 +334,8 @@ generate_header_uimg(struct uboot_image_ iov[2].iov_len = st.st_size; crc = crc32v(iov, 3); } else { - dsize = st.st_size; + dsize = update_image ? + st.st_size - sizeof(*hdr) : st.st_size; crc = crc32(p, st.st_size); } munmap(p, st.st_size); @@ -387,10 +388,13 @@ generate_header_arm64(struct arm64_image flags |= ARM64_FLAGS_PHYS_PLACEMENT_ANY; #endif + const uint64_t dsize = update_image ? + st.st_size - sizeof(*hdr) : st.st_size; + memset(hdr, 0, sizeof(*hdr)); hdr->code0 = htole32(ARM64_CODE0); hdr->text_offset = htole64(image_entrypoint); - hdr->image_size = htole64(st.st_size + sizeof(*hdr)); + hdr->image_size = htole64(dsize); hdr->flags = htole32(flags); hdr->magic = htole32(ARM64_MAGIC);