Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/mkubootimage Adjust image size appropriately when us...



details:   https://anonhg.NetBSD.org/src/rev/8f9ff946d54e
branches:  trunk
changeset: 968041:8f9ff946d54e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Jan 01 10:35:10 2020 +0000

description:
Adjust image size appropriately when using update_image

OK jmcneill

diffstat:

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

diffs (43 lines):

diff -r 06b99a1841df -r 8f9ff946d54e usr.bin/mkubootimage/mkubootimage.c
--- a/usr.bin/mkubootimage/mkubootimage.c       Wed Jan 01 10:18:39 2020 +0000
+++ b/usr.bin/mkubootimage/mkubootimage.c       Wed Jan 01 10:35:10 2020 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
                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 @@
        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);
 



Home | Main Index | Thread Index | Old Index