From nobody Thu Apr 3 11:26:39 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1741189370; cv=none; d=zohomail.com; s=zohoarc; b=LZ09xkJV/5IIn7/fozxgS4Kgomm7rqjzzYQ6Fp2G61fd7ApX0PzeFCkX3uwIBPWVnaTPBEdmAtp4Y3PuVK5CMFymc7xaEH0aOEhifb6TuyuoGdkps+BKpj4DeqwjsZECY4S1C2Bv50j31zEEjA4mod/Otu+e3e+wMAIzwd5SwVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741189370; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fYDAc70iCmEcsaAQpim9Lu0U9CfOBiddFcVryIIgw1c=; b=iUJXLtFidePU9Zo1VjAdwAcKhiYe2yiP+ffLf/SMWgzQupN6R/kIxxlCgk7aM0v0f8zNeMe0PBThI9SUqS2V3mxnsV9WwdkSkbEPGvW9vKfI98+ruNnT2t29i2Hm1z2luStg12BlSYjybZvrLIvSp+3eZ26wS+kf3HwBjj6JTOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741189370607894.8737767631276; Wed, 5 Mar 2025 07:42:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tpqrP-0000MX-9p; Wed, 05 Mar 2025 10:40:39 -0500 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 1tpqr9-0000B7-VA for qemu-devel@nongnu.org; Wed, 05 Mar 2025 10:40:25 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tpqr8-0002Yd-0r for qemu-devel@nongnu.org; Wed, 05 Mar 2025 10:40:23 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-388cae9eb9fso3709630f8f.3 for ; Wed, 05 Mar 2025 07:40:21 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e485dbe7sm21577111f8f.93.2025.03.05.07.40.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 05 Mar 2025 07:40:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741189220; x=1741794020; 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=fYDAc70iCmEcsaAQpim9Lu0U9CfOBiddFcVryIIgw1c=; b=YkMY0QYPt/LvwyelHu9FWgbr6h6iETjtGO5oUtRKzVuRdXJmU0MvggKrPQ5nos1x/r UDjkG3fCKv0GXa8tPhFJcDUXJ/DZQN7ppa6/8+8GUmRgpVA+ReWCWLu2bgGLzzNtgGGI XTYYcDLf6mmjzy1Di5Ir2qgO/4ih5bb25/0HtyYCDzUOqNDHUiou5DIf0y3utI4RVy4d 4yP0ArNp9ef4YAvAoMN43bd6X84Z4j1kfmJx9LFdiyidgxQ9axqLyv2ujgdtTjxWtJUL NgdzieO6bH2fKwXUFGt8CwdCyiSzg1PLQPJHQ/58sPhcdtaun1T+Vno55fTTc/nQN1Wu ZB4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741189220; x=1741794020; 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=fYDAc70iCmEcsaAQpim9Lu0U9CfOBiddFcVryIIgw1c=; b=QTZLQa2MnORvXC34Q59v14NuKZCuIkY1E/wtoyzS73Yci5Y5UjNAkEbGWnwrz9fBmj wwVlC4CMKbzEerpwr487HMW8pjc3BbcICLSNP2VJcNA4EW7sa/iSR/vTFeRjf1DKEN2x lpu1y3W45WtxDuT0k9IdjIdr0/9YmIMS9jUoHTBj/1v73eSjwja97RdJrKLapdXrbALl tmf40EAuwAy7TamKGTG8dw5l2ZngyLjY0OeTH8W+e6sYU6ry3OomIGnm6RJci6DGL3vf rfLo0uMjpioOdkwTPqQ4rW0lpRRh0Yxlo93WxxqM5fCVYlttCBfaDk8bSgpgu+iiIyeK PNww== X-Gm-Message-State: AOJu0Yw7degxVPtBDUT/WVO7/U8pHvL9aOKV3CLtAMO46srizBzXeA3c JQRP9oi/v/fq1YVLQDPXX6j0UqHrpffc7cq2v25jMndtrpf4myEm6FhelQ0GnIfDZ0ZN8a9iv/e Redo= X-Gm-Gg: ASbGnctSjetN0JxQCsUTkEQMMm3FZt/rjeIWjnbzoDc0Lqk7h6aks788h/f8ooRnaoT D1bmE48/au18JGf0iaFRJgmBNSRzibyn1uMryS364EE/r8mvKS+TXebQbPQdxeT32mLWv7Z+4oZ JE4E/0Jwy/ELtX/hXY6wloaaJF2MkpPs8rKHRBW1W5GxtnVAsk5S93N1WUdfBBV2PDi/XL44Duj 305RemwBjtQFBIFPu4UqM+ETOia1eMH66j9ChclosOaQcZ9SUtmq3e7nkg0YGBzOiHOg/VoRYgw qe4zE6Pb52TnXrAYqHeBBQjDvlXvGZ6JHweerz5PqiJCHinI16t87tYE8TxRZ0e/12maF2ToTGA EOVrwytjiveO8c1mlsuY= X-Google-Smtp-Source: AGHT+IHroEkV8P6Vz2KqqECLrWsyC5n3bWV3S4dxFGiwdRq/c7o7hZuQb8VuOSVRyA0UAd26buKBew== X-Received: by 2002:a05:6000:1869:b0:390:fbba:e64b with SMTP id ffacd0b85a97d-3911f789f82mr4109789f8f.31.1741189220035; Wed, 05 Mar 2025 07:40:20 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Richard Henderson , Pierrick Bouvier , Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper Date: Wed, 5 Mar 2025 16:39:20 +0100 Message-ID: <20250305153929.43687-11-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250305153929.43687-1-philmd@linaro.org> References: <20250305153929.43687-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1741189372595019000 Introduce legacy_binary_endianness() to return the endianness of a legacy binary, and legacy_binary_is_big_endian() being equivalent of compile time TARGET_BIG_ENDIAN definition. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/legacy_binary_info.h | 8 ++++++ legacy_binary_info.c | 43 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/qemu/legacy_binary_info.h b/include/qemu/legacy_binary= _info.h index 2d42e852b7a..18886a05402 100644 --- a/include/qemu/legacy_binary_info.h +++ b/include/qemu/legacy_binary_info.h @@ -9,9 +9,17 @@ #ifndef QEMU_LEGACY_BINARY_INFO_H #define QEMU_LEGACY_BINARY_INFO_H =20 +#include "qapi/qapi-types-common.h" + void legacy_binary_info_init(const char *argv0); =20 /* Return runtime equivalent of TARGET_LONG_BITS =3D=3D 64 check */ bool legacy_binary_is_64bit(void); =20 +/* Return runtime equivalent of TARGET_BIG_ENDIAN definition */ +bool legacy_binary_is_big_endian(void); + +/* Return endianness of legacy binary */ +EndianMode legacy_binary_endianness(void); + #endif diff --git a/legacy_binary_info.c b/legacy_binary_info.c index be50d3f50ea..c9a8e99699e 100644 --- a/legacy_binary_info.c +++ b/legacy_binary_info.c @@ -9,10 +9,12 @@ #include "qemu/osdep.h" #include "qemu/arch_info.h" #include "qemu/legacy_binary_info.h" +#include "qapi/qapi-types-common.h" =20 typedef struct LegacyBinaryInfo { const char *binary_name; QemuArchBit arch_bit; + EndianMode endianness; unsigned long_bits; } LegacyBinaryInfo; =20 @@ -21,146 +23,175 @@ static const LegacyBinaryInfo legacy_binary_infos[] = =3D { { .binary_name =3D "qemu-system-aarch64", .arch_bit =3D QEMU_ARCH_BIT_ARM, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-alpha", .arch_bit =3D QEMU_ARCH_BIT_ALPHA, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-arm", .arch_bit =3D QEMU_ARCH_BIT_ARM, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-avr", .arch_bit =3D QEMU_ARCH_BIT_AVR, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-hppa", .arch_bit =3D QEMU_ARCH_BIT_HPPA, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-i386", .arch_bit =3D QEMU_ARCH_BIT_I386, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-loongarch64", .arch_bit =3D QEMU_ARCH_BIT_LOONGARCH, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-m68k", .arch_bit =3D QEMU_ARCH_BIT_M68K, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-microblaze", .arch_bit =3D QEMU_ARCH_BIT_MICROBLAZE, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-microblazeel", .arch_bit =3D QEMU_ARCH_BIT_MICROBLAZE, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-mips", .arch_bit =3D QEMU_ARCH_BIT_MIPS, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-mips64", .arch_bit =3D QEMU_ARCH_BIT_MIPS, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-mips64el", .arch_bit =3D QEMU_ARCH_BIT_MIPS, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-mipsel", .arch_bit =3D QEMU_ARCH_BIT_MIPS, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-or1k", .arch_bit =3D QEMU_ARCH_BIT_OPENRISC, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-ppc", .arch_bit =3D QEMU_ARCH_BIT_PPC, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-ppc64", .arch_bit =3D QEMU_ARCH_BIT_PPC, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-riscv32", .arch_bit =3D QEMU_ARCH_BIT_RISCV, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-riscv64", .arch_bit =3D QEMU_ARCH_BIT_RISCV, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-rx", .arch_bit =3D QEMU_ARCH_BIT_RX, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-s390x", .arch_bit =3D QEMU_ARCH_BIT_S390X, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-sh4", .arch_bit =3D QEMU_ARCH_BIT_SH4, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-sh4eb", .arch_bit =3D QEMU_ARCH_BIT_SH4, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-sparc", .arch_bit =3D QEMU_ARCH_BIT_SPARC, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-sparc64", .arch_bit =3D QEMU_ARCH_BIT_SPARC, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-tricore", .arch_bit =3D QEMU_ARCH_BIT_TRICORE, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-x86_64", .arch_bit =3D QEMU_ARCH_BIT_I386, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 64, }, { .binary_name =3D "qemu-system-xtensa", .arch_bit =3D QEMU_ARCH_BIT_XTENSA, + .endianness =3D ENDIAN_MODE_LITTLE, .long_bits =3D 32, }, { .binary_name =3D "qemu-system-xtensaeb", .arch_bit =3D QEMU_ARCH_BIT_XTENSA, + .endianness =3D ENDIAN_MODE_BIG, .long_bits =3D 32, }, }; @@ -182,6 +213,7 @@ void legacy_binary_info_init(const char *argv0) for (size_t i =3D 0; i < ARRAY_SIZE(legacy_binary_infos); i++) { if (!strcmp(legacy_binary_infos[i].binary_name, binary_name)) { assert(legacy_binary_infos[i].long_bits); + assert(legacy_binary_infos[i].endianness !=3D ENDIAN_MODE_UNSP= ECIFIED); current_index =3D i; return; } @@ -195,3 +227,14 @@ bool legacy_binary_is_64bit(void) assert(current_index !=3D -1); return legacy_binary_infos[current_index].long_bits =3D=3D 64; } + +EndianMode legacy_binary_endianness(void) +{ + assert(current_index !=3D -1); + return legacy_binary_infos[current_index].endianness; +} + +bool legacy_binary_is_big_endian(void) +{ + return legacy_binary_endianness() =3D=3D ENDIAN_MODE_BIG; +} --=20 2.47.1