From patchwork Wed Oct 18 21:50:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 735109 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1226378wro; Wed, 18 Oct 2023 15:00:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEg/kNil1L5dMM+Qh5h/sbONWndYJ9JZEogClPr/LsyMIbhIMxtK771o57p6C9hbc4crG6l X-Received: by 2002:a05:6808:10cf:b0:3ac:4ee2:337b with SMTP id s15-20020a05680810cf00b003ac4ee2337bmr461123ois.51.1697666402173; Wed, 18 Oct 2023 15:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697666402; cv=none; d=google.com; s=arc-20160816; b=KVKvHChmp/F1g8Sl4/Gy/gYfNkfSW2DjyiKuPsygLfWXvud4QC/DTTw0GJ80Nt/jNd A/6Obod5U7xdF9KCfVPiPxnsYlFWIgJY1vF7mUTs0fqcOX9tveNTsxaD0UVesseBVEcS mKCaij6MtWug4t3qJAhe5iW54/gWu86Y3NlnXWDrTG4I0174gft5PIijaDSvYEb+tYHO NKiVoJGYjcFkHWpA1ev3GdW52s4NIfaonjqJwBoFCFVqnusNC1GuF8OubU1W7Ya2PZ/R Nl1jKvQNUCtiQ3cUMjqt6l1xhrYf/KnnISmyw5paGgue0Xd29brHgtgzgaAgsGuKzLFK sMEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hkIbB3zmI08zQqo8JvI15EoPXprMPyQ2OgXzm/sTzaE=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=GOE4CUsFJnj1XRZ3AxbG5+vTWwEV/HTTngqjz2d7HOVi8EemrMpdtbKgWmUta3HUzE UJUguCL5mN2EVm3L9lAvZzfoB/ljf4mEvNibUElEkNpCesihZhwU06JZ0xgXvArdHvoW 233bQtSpyIYCyX/NqCLRIyEydidO6MvLAxGil9m5n/X7h+u9QrD6ntigRkrAf5MPRTbh IX8RuOjIHxIIg5jCpZW14zuzDhK8h2/pbQWxTxvmhgDdnxBtAHQuRRpcsOkZtF+5LuJZ pTSGdWoZvbjpPZJrVrhjOQWOfaUTHhbHEAqhagVFMo9Z4fyg84urJg+wGuny7puSKEut 01Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C0pxWsAM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l12-20020a0ce84c000000b0066d854ccbe4si637205qvo.449.2023.10.18.15.00.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Oct 2023 15:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C0pxWsAM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtESA-0000rL-9e; Wed, 18 Oct 2023 17:51:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtES5-0000it-Tb for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:42 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtES3-0004Mi-Lq for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:41 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-57b5f0d658dso4275582eaf.0 for ; Wed, 18 Oct 2023 14:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697665897; x=1698270697; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hkIbB3zmI08zQqo8JvI15EoPXprMPyQ2OgXzm/sTzaE=; b=C0pxWsAMx0xMZpriRBPtpt6F2xoLOTokrT6GVDvIDnBJcoURHZ7yAUnTBBX79trORM Bk1g/ipdxpGsHABeH7Dof5Mmh9kBKngf+kTNrm9rQoMVL8yHOuUpyNpGsxdO2qaNHrdv 96l1bE8MFoRfoh888c+I5xp36hQ/heASfihyWapdsaW/z6oBkqoaMfdcFLGjHgbqOrlA D3PHGszWTYnBtaBO/axCBpD5xjhr8lAZJKQO3kNXoFo9PtNwlq5Zqgelj6Y9uyIMGbzM r8WAVC3+aYtQj3SnoXr4FqOc5w0BkSQLg/wdoo289cnZJ/uTXQ6C2Sj5zWG49xqOo/0B A4EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697665897; x=1698270697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkIbB3zmI08zQqo8JvI15EoPXprMPyQ2OgXzm/sTzaE=; b=FPsJE6SDDObhVToiaCRA6erm4A0zl13Rf+yhtACRt4lvMW+FVcg8+MezFHDxxGPhiU ggdGc1zsay1eD2o0PA6cBkZf5dZ4oxbqq0SqVJ16kypqzwMtICyKZVVc2e2tzzazZhSn lIr8e18LBMjOx1Ycsgf23jVc/vJP7noPzEBLOx2kRbpGU16h8PavrjhfvOh09O8EZTuK x49Hdd0I5UeIPYqVFYgm8xnfR9sUi8kx4hFX22u+97I8U+FWNPAyIEoF4UaxjEeW9t+Z JBrB9EQw5WQF9kBZvqJ3W6CCoeKHTaA6Oz6C0gLO2kuxaJxBFUkKK4OVi4TsiSJ9fLYk 6Bhg== X-Gm-Message-State: AOJu0YwVLQFn1BPvPjKsxTfOMKkbAOIsGvuHHgf3knfnEWUcyLMuY5JI 8kF9fuCJQcBMOMZScRvR+zxZMEc5fIb+itSOiio= X-Received: by 2002:a05:6359:d14:b0:14a:ddb8:9a12 with SMTP id gp20-20020a0563590d1400b0014addb89a12mr276183rwb.6.1697665897576; Wed, 18 Oct 2023 14:51:37 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id w17-20020a63f511000000b005b61a024ec7sm2176380pgh.74.2023.10.18.14.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:51:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH 01/61] include/hw/elf: Remove truncating signed casts Date: Wed, 18 Oct 2023 14:50:35 -0700 Message-Id: <20231018215135.1561375-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018215135.1561375-1-richard.henderson@linaro.org> References: <20231018215135.1561375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There's nothing about elf that specifically requires signed vs unsigned. This is very much a target-specific preference. In the meantime, casting low and high from uint64_t back to Elf_SWord to uint64_t discards high bits that might have been set by translate_fn. Signed-off-by: Richard Henderson --- include/hw/elf_ops.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index dffb0e73d2..0a5c258fe6 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -385,10 +385,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd, } if (pflags) { - *pflags = (elf_word)ehdr.e_flags; + *pflags = ehdr.e_flags; + } + if (pentry) { + *pentry = ehdr.e_entry; } - if (pentry) - *pentry = (uint64_t)(elf_sword)ehdr.e_entry; glue(load_symbols, SZ)(&ehdr, fd, must_swab, clear_lsb, sym_cb); @@ -610,10 +611,12 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd, } } - if (lowaddr) - *lowaddr = (uint64_t)(elf_sword)low; - if (highaddr) - *highaddr = (uint64_t)(elf_sword)high; + if (lowaddr) { + *lowaddr = low; + } + if (highaddr) { + *highaddr = high; + } ret = total_size; fail: if (mapped_file) {