From patchwork Wed May 10 15:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680528 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2922241wrs; Wed, 10 May 2023 08:54:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+OidLzWmBQTwlqdVA1wX6RrBeGoCXLZ5s4UxxhypyGraPEfVqN1daXGJ29Zs34lKJbKxA X-Received: by 2002:a05:6214:c82:b0:5f1:6aa8:cd2d with SMTP id r2-20020a0562140c8200b005f16aa8cd2dmr22333138qvr.22.1683734050137; Wed, 10 May 2023 08:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683734050; cv=none; d=google.com; s=arc-20160816; b=M77/pHKWBTNXK7YzVPvdqxGw9oGk4+cSCf0uz6j3lRfiMGiahAxnbG94W9JYtaL/K4 fwAtymNWvj8OLANBLXuSWcknTYsKTsD+u6WWNSMVfy8Jcn9HZnFvPfdx52jl1tCTrQWC RiZjV1MbvMbFClZoWE3+wEgvkcNdyp1WsRtfSwy1UH3xGHlOPrRSG8B/+PKxubqYctSA iDPxLmpqVYGBw833s3dBdsBJNTx87pxuTQ4F5ymfowj9rsfLwcu0XkSd6tRplZNHE5ar 86pMzXFqzf2rG14ygJERrPVRMwSh5L/q0Cp0V5CySRR8Z5wKSiRBUueZ+NJ0ekxU66eM tYOA== 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=miMv82l+3KyI8ORxRUoDuIkWzm8hA82CyQJBzInCVAFXyZR7LDbX/OvwrUNw67ecJ9 jdCS+lTkNrclLvC5jC5VBxQmcQjx+5JCygAO+yeNfLs0lXszEZirfeZ5p7qk3wzL3gYH zJFsMSssiq9m1kbd0MBLLTNJERC22zXuFDkuMsEH0YYvCy8Oqso5qMy4C1EeUv9qnR7I hVJkJA+Il7n1FZ9/11IhLW3kraLuzG/T6ZRKzcrz9OWx+ijuct5CS6VJdfRYIHd2lJhO 6rQb/i2ll/GiRTvHaVSlR3qOhmXpefZ5YScTsoROX1BFYSgOjskjG77zkBERGIB3OoOB Gu6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ke/51h/x"; 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 u12-20020a0562141c0c00b0061b5bff03a8si2259347qvc.476.2023.05.10.08.54.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 May 2023 08:54:10 -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="Ke/51h/x"; 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 1pwm7I-000310-3T; Wed, 10 May 2023 11:52:36 -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 1pwm7F-0002zT-Ub for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:33 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7B-0004UR-TC for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f41d087b24so33500865e9.1 for ; Wed, 10 May 2023 08:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733948; x=1686325948; 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=Ke/51h/x0piipQ0SAV1UjL8R4SoMXAg5WLXaBs37i04OM2RUBxN+2HAu7GMjO3h5YP EokTTAun+4CCg/UnhOuF3P2UK4IRMKr6tlgQ5uYm+tWbq9pUNJP3gb1BHVDBcSaGgP6X q71abwvGUN7rxNBH9PwNrXko0UiVH8rxf5/QujIfziwx6SAr0JObBFmeu5DqHEWBZAf/ tC0UC8iDqz+eA0xkwcFpe956JfExwuyzd/PPMG9FR3AUE5zoSi4kFAd6YBjXA0/xLwTC d20A/JCBZXqwIr6V2OKt8j8h/HWX9TDL9gE15rTcoDZdK8NZAl6+wA3cLRmqpCLyVVut +wBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733948; x=1686325948; 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=W5/hIj3FhOwZA5yIyaaQrVCTekvBnQiA/H/MR4sHgzGGadr7CBxyut1hi7WDZAG+4f DUItTSGL/W9pmEpb+buvjIVuMyRqcy3mFTE3EhnFiFzuQ9oulpx1IsitJeOEpFTfdys7 u+h8xAKOdquYMwX2Wign7cDaX8QDhAo9gSmgKaoJzoeI1OQ2OKKc9vHHnhqBcenaV4mx dC8Gl+K0pBAjkqzLhJufKVjq5bPB/chhkLHhbWWBZy6/ivS7hZSsVFyQC1TvlQYACw2C DmrvzeBKlDyVvIBsfApCBIw7xqktJ6xA/dP8YYO0Fds+ekfw934r1BKnOkn2TAK+0Dlw g0BA== X-Gm-Message-State: AC+VfDxuZUsW8v9IeUXEtgd/uVPAUUXqnXd9lJafBYW47TmnmHgH8iTe 9zK3mPWTnhQrfVg+a88gR9TJDZTYpzn9gt9QXx9JNQ== X-Received: by 2002:a05:6000:1c4:b0:2f5:ace2:8737 with SMTP id t4-20020a05600001c400b002f5ace28737mr11431643wrx.32.1683733948514; Wed, 10 May 2023 08:52:28 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 2/5] disas: Remove target_ulong from the interface Date: Wed, 10 May 2023 16:52:23 +0100 Message-Id: <20230510155226.647756-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Use uint64_t for the pc, and size_t for the size. Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-81-richard.henderson@linaro.org> --- include/disas/disas.h | 17 ++++++----------- bsd-user/elfload.c | 5 +++-- disas/disas.c | 19 +++++++++---------- linux-user/elfload.c | 5 +++-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/disas/disas.h b/include/disas/disas.h index d363e95ede..6c394e0b09 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,28 +7,23 @@ #include "cpu.h" /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *code, unsigned long size); -void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size); +void disas(FILE *out, const void *code, size_t size); +void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size); -void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical); +void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, + int nb_insn, bool is_physical); char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size); /* Look up symbol for debugging purpose. Returns "" if unknown. */ -const char *lookup_symbol(target_ulong orig_addr); +const char *lookup_symbol(uint64_t orig_addr); #endif struct syminfo; struct elf32_sym; struct elf64_sym; -#if defined(CONFIG_USER_ONLY) -typedef const char *(*lookup_symbol_t)(struct syminfo *s, target_ulong orig_addr); -#else -typedef const char *(*lookup_symbol_t)(struct syminfo *s, hwaddr orig_addr); -#endif +typedef const char *(*lookup_symbol_t)(struct syminfo *s, uint64_t orig_addr); struct syminfo { lookup_symbol_t lookup_symbol; diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index fbcdc94b96..2e76f0d3b5 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -352,9 +352,10 @@ static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex, static int symfind(const void *s0, const void *s1) { - target_ulong addr = *(target_ulong *)s0; + __typeof(sym->st_value) addr = *(uint64_t *)s0; struct elf_sym *sym = (struct elf_sym *)s1; int result = 0; + if (addr < sym->st_value) { result = -1; } else if (addr >= sym->st_value + sym->st_size) { @@ -363,7 +364,7 @@ static int symfind(const void *s0, const void *s1) return result; } -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS == ELFCLASS32 struct elf_sym *syms = s->disas_symtab.elf32; diff --git a/disas/disas.c b/disas/disas.c index b087c12c47..f5e95043cf 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -204,10 +204,9 @@ static void initialize_debug_host(CPUDebug *s) } /* Disassemble this for me please... (debugging). */ -void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size) +void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size) { - target_ulong pc; + uint64_t pc; int count; CPUDebug s; @@ -226,7 +225,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } for (pc = code; size > 0; pc += count, size -= count) { - fprintf(out, "0x" TARGET_FMT_lx ": ", pc); + fprintf(out, "0x%08" PRIx64 ": ", pc); count = s.info.print_insn(pc, &s.info); fprintf(out, "\n"); if (count < 0) @@ -292,7 +291,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) } /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *code, unsigned long size) +void disas(FILE *out, const void *code, size_t size) { uintptr_t pc; int count; @@ -324,7 +323,7 @@ void disas(FILE *out, const void *code, unsigned long size) } /* Look up symbol for debugging purpose. Returns "" if unknown. */ -const char *lookup_symbol(target_ulong orig_addr) +const char *lookup_symbol(uint64_t orig_addr) { const char *symbol = ""; struct syminfo *s; @@ -356,8 +355,8 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, } /* Disassembler for the monitor. */ -void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical) +void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, + int nb_insn, bool is_physical) { int count, i; CPUDebug s; @@ -378,13 +377,13 @@ void monitor_disas(Monitor *mon, CPUState *cpu, } if (!s.info.print_insn) { - monitor_printf(mon, "0x" TARGET_FMT_lx + monitor_printf(mon, "0x%08" PRIx64 ": Asm output not supported on this arch\n", pc); return; } for (i = 0; i < nb_insn; i++) { - g_string_append_printf(ds, "0x" TARGET_FMT_lx ": ", pc); + g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); count = s.info.print_insn(pc, &s.info); g_string_append_c(ds, '\n'); if (count < 0) { diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 703f7434a0..80085b8a30 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3327,9 +3327,10 @@ static void load_elf_interp(const char *filename, struct image_info *info, static int symfind(const void *s0, const void *s1) { - target_ulong addr = *(target_ulong *)s0; struct elf_sym *sym = (struct elf_sym *)s1; + __typeof(sym->st_value) addr = *(uint64_t *)s0; int result = 0; + if (addr < sym->st_value) { result = -1; } else if (addr >= sym->st_value + sym->st_size) { @@ -3338,7 +3339,7 @@ static int symfind(const void *s0, const void *s1) return result; } -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS == ELFCLASS32 struct elf_sym *syms = s->disas_symtab.elf32;