Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/usr.bin/mkubootimage Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/36d3c3855f4d
branches:  netbsd-9
changeset: 466786:36d3c3855f4d
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jan 02 09:47:05 2020 +0000

description:
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.

diffstat:

 usr.bin/mkubootimage/mkubootimage.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (43 lines):

diff -r d6168f4e19d3 -r 36d3c3855f4d usr.bin/mkubootimage/mkubootimage.c
--- a/usr.bin/mkubootimage/mkubootimage.c       Thu Jan 02 09:42:06 2020 +0000
+++ b/usr.bin/mkubootimage/mkubootimage.c       Thu Jan 02 09:47:05 2020 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
                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 @@
        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);
 



Home | Main Index | Thread Index | Old Index