From 6bdbea77cb4cf3c856d89a677129a298377e35fd Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 22 Feb 2024 13:15:17 +0000 Subject: [PATCH] The ctt_size of integers and floating point numbers is in bytes not bits. OK mpi@ --- usr.bin/ctfconv/generate.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/usr.bin/ctfconv/generate.c b/usr.bin/ctfconv/generate.c index c2911f59c76..fdbaa0ea33f 100644 --- a/usr.bin/ctfconv/generate.c +++ b/usr.bin/ctfconv/generate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: generate.c,v 1.5 2022/08/14 14:54:13 millert Exp $ */ +/* $OpenBSD: generate.c,v 1.6 2024/02/22 13:15:17 claudio Exp $ */ /* * Copyright (c) 2017 Martin Pieuchot @@ -196,7 +196,20 @@ imcs_add_type(struct imcs *imcs, struct itype *it) ctt.ctt_type = it->it_refp->it_idx; ctsz = sizeof(struct ctf_stype); } else if (size <= CTF_MAX_SIZE) { - ctt.ctt_size = size; + if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT) { + assert(size <= 64); + if (size == 0) + ctt.ctt_size = 0; + else if (size <= 8) + ctt.ctt_size = 1; + else if (size <= 16) + ctt.ctt_size = 2; + else if (size <= 32) + ctt.ctt_size = 4; + else + ctt.ctt_size = 8; + } else + ctt.ctt_size = size; ctsz = sizeof(struct ctf_stype); } else { ctt.ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size); -- 2.20.1