Module Name: src
Committed By: martin
Date: Thu Jan 2 09:47:06 UTC 2020
Modified Files:
src/usr.bin/mkubootimage [netbsd-9]: mkubootimage.c
Log Message:
Pull up following revision(s) (requested by skrll in ticket #596):
usr.bin/mkubootimage/mkubootimage.c: revision 1.28
usr.bin/mkubootimage/mkubootimage.c: revision 1.29
Adjust image size appropriately when using update_image
OK jmcneill
Avoid mixing signed/unsigned arguments to the ? operator.
To generate a diff of this commit:
cvs rdiff -u -r1.24.6.1 -r1.24.6.2 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.24.6.1 src/usr.bin/mkubootimage/mkubootimage.c:1.24.6.2
--- src/usr.bin/mkubootimage/mkubootimage.c:1.24.6.1 Mon Dec 9 15:19:30 2019
+++ src/usr.bin/mkubootimage/mkubootimage.c Thu Jan 2 09:47:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mkubootimage.c,v 1.24.6.1 2019/12/09 15:19:30 martin Exp $ */
+/* $NetBSD: mkubootimage.c,v 1.24.6.2 2020/01/02 09:47:05 martin Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -30,7 +30,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkubootimage.c,v 1.24.6.1 2019/12/09 15:19:30 martin Exp $");
+__RCSID("$NetBSD: mkubootimage.c,v 1.24.6.2 2020/01/02 09:47:05 martin Exp $");
#include <sys/mman.h>
#include <sys/stat.h>
@@ -336,7 +336,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 ?
+ (uint32_t)st.st_size - sizeof(*hdr) : (uint32_t)st.st_size;
crc = crc32(p, st.st_size);
}
munmap(p, st.st_size);
@@ -389,10 +390,13 @@ generate_header_arm64(struct arm64_image
flags |= ARM64_FLAGS_PHYS_PLACEMENT_ANY;
#endif
+ const uint64_t dsize = update_image ?
+ (uint64_t)st.st_size - sizeof(*hdr) : (uint64_t)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);