From patchwork Mon Jan 27 11:38:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860243 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1970670wrq; Mon, 27 Jan 2025 03:39:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWKeZSWSZdk8Wqk8ayeoLExglFuOelM7qBUX8n0hR3CV8xKfCgBecaML/sy1DEouZqkkfO1GQ==@linaro.org X-Google-Smtp-Source: AGHT+IF1cCkbSlBLCg745z4eGZOl/9Bo+jV3muLvnBkt848WMeE7clAg1H+5eqmxotFCUQTqwrjG X-Received: by 2002:a05:620a:3786:b0:7be:72e2:90a5 with SMTP id af79cd13be357-7bfe7b827f2mr634413985a.26.1737977982401; Mon, 27 Jan 2025 03:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737977982; cv=none; d=google.com; s=arc-20240605; b=CF3v9Cd3nqCG5AKibyMqVs+fqTo0t1MzGYB3SVqrGGj0A1cU467rm/H5D8gjBrzlfl pyJgAYN5m0xPbyr9MJyJteN5CWKmJh05eNEOStgZxbFOK6oM0xS0A1PhHJ5nGklSl7BV Gp6+/mB3AIOtGTyW+raF4wWgh9mtORIHfO45bBxDeEMrEjRKPg6jyWttEjo/plXO3c7e Iz3pzTWN/0XagkTW5LoYni0LYRCfj5eLI0BUJ4lnmF3wNAHJZ/I1XtgdL5clGzgs9t6Y TJ8QapcVrk3+ApeVSd5iDQb2/KwRyct6KrX/el3ItbpdwMR9LGQM++fM+9IW8T2yNeKG p8MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=+P4muHO2/Kjut6DQxBAs5VxofoUUFgPuTxOuR706kfs=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=UV6TpYS+GvILYcD1w7LGOK6XjMhdp9ykES9lWKSFzQ7YEBOR28+OZr5PdSFUqtUWHc ofLAzjeJVT89imGchi/DX+bZ5B8WCAhiW+oDMtph4P52H9YdAy0XSNkGeTooNBFzC+dQ eT01hTZpdVLdi2mYJJs+nnv4oxOdy2C9YM6PRfAn2L/2LbhB0I84xRY9k6jLta7DY2Lq B+jP0BwaRyceWr3A6dMnUoNlrso+ax/ncF0aEJS667/VIssc9PzuHcXQmbj0yHSg+aUU HY9hEgMXR0St/PVSvRoM/3GBsaFne9OfHtsdp65u2kfe2jZlxYY2GudOwyTzqWCGleu5 CQUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HE4ChrrW; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7be9ae94688si921367585a.159.2025.01.27.03.39.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:39:42 -0800 (PST) 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=HE4ChrrW; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNRy-0005tf-G1; Mon, 27 Jan 2025 06:38:42 -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 1tcNRs-0005q9-32 for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:36 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNRp-0005Ax-9W for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:35 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4361f65ca01so45972885e9.1 for ; Mon, 27 Jan 2025 03:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977911; x=1738582711; 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=+P4muHO2/Kjut6DQxBAs5VxofoUUFgPuTxOuR706kfs=; b=HE4ChrrW92g4g4APx2TtzUmoai3+KElocaEWRvUhgHSv34AU2p3jmImS1AZ8Bi9UzL Y/EyINX2xzf5x5p538Y+wNABNlHQfrvAxCpv+Z0fHUMnfLKeUaZafY2t3sLUzHdRmWLy ltQbvINmXs5M/3bXumTMV9kqp5WJlLkeDg4xWuTA+IaBe4XVE0Ia5SDwVQBatLFa8CkK tYHYnvF9MsAKVWE1hFiRvKS6eSFIrVED3Hvk5CteHN/Jck3/r+j2ad5J7PBLCm23UCD6 Y3V2ftp9DUwcLFkGTVwIG0x+0Juy9/TpUDTtyd0hlkC+0cltmK3QJ0XE+ReSq/gDxWcX BKbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977911; x=1738582711; 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=+P4muHO2/Kjut6DQxBAs5VxofoUUFgPuTxOuR706kfs=; b=o89s4KPxT5BclqXIvTDVfmLtPCQxfI5RZVDmDYyJZuFh1RTOBT1aH3DtBoM9B66WLM 0rciANVA8RjisVAhYjvVgwOMJQ1EsLnHCsme/Bu9Ages6Z8UTQBu15pang17xteTrNF1 DHGbhRx/+6b+2VNQPBvnZVUkL2pNtMEMe5yxmJLwg//l4sIz4VMzE1b/CRiz/AOlfQ/V n1MAJoFEJe8cAh3JPn5v4chlDbM6vcSojhmjNYmom4kim7lvc52BalPJKHaLQMqIht5S LvhJIHNf+yH6X3ixz8qNxj/C7m7ZuxIrIzTzr0BN59Tz+EAgZGAOVxAdlnNDjX4NnYrW AlSw== X-Gm-Message-State: AOJu0Yyi/kuUxQB9gF9YHNI3COeBL3TKDuWwZ3cYLzn7sN8ratEdH5Jh uskAnn4SOuPdP8udeAuGJy7h5bjNmiWF329Dxid12zBK9Oas3WhA8cbNqzbNK5AgDw93Uys8iqs DwYQ= X-Gm-Gg: ASbGncs9Zdb/OQWEpeVMWtgdHuCQCGjYocWh6b50Z1dAEPxQPcheVVCfnP+6PMMkgd2 lCb8sprqvFpnDOCZF2oFj0lHeg7cjYqGlJL+FEBk5462Y7hwTwgeqHnIoVuhNq2oiaaOtehTRqb 5+9iMIjU4Yzo9o03J6wa0RetraMYwTTMgXmKz4V0OPthW4F1Ix9VvQNbri2pgz5aoNQj6OMEGs/ tz9wTMAGA39HqDUanh/qtGnABqOPKE/GwjQsv3+RbbsrvDbRV5hzqro35O4Xf1XjkrNX/S8YpoR SSizveRegXe6flmsdocCU6J96/R9BEef9CagJLOE8qWo3MM9ymkr2EU= X-Received: by 2002:a05:6000:4022:b0:38b:dbeb:63a2 with SMTP id ffacd0b85a97d-38bf57d2dc0mr34279427f8f.55.1737977911246; Mon, 27 Jan 2025 03:38:31 -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-38c2a1bb040sm10899923f8f.67.2025.01.27.03.38.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/6] hw/avr/boot: Replace load_elf_ram_sym() -> load_elf_as() Date: Mon, 27 Jan 2025 12:38:19 +0100 Message-ID: <20250127113824.50177-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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=unavailable 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 load_elf_ram_sym() with load_rom=true, sym_cb=NULL is equivalent to load_elf_as(). Replace by the latter to simplify. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/avr/boot.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/avr/boot.c b/hw/avr/boot.c index 617f3a144c8..6a91dcd12d0 100644 --- a/hw/avr/boot.c +++ b/hw/avr/boot.c @@ -71,11 +71,9 @@ bool avr_load_firmware(AVRCPU *cpu, MachineState *ms, return false; } - bytes_loaded = load_elf_ram_sym(filename, - NULL, NULL, NULL, - &entry, NULL, NULL, - &e_flags, 0, EM_AVR, 0, 0, - NULL, true, NULL); + bytes_loaded = load_elf_as(filename, NULL, NULL, NULL, + &entry, NULL, NULL, + &e_flags, 0, EM_AVR, 0, 0, NULL); if (bytes_loaded >= 0) { /* If ELF file is provided, determine CPU type reading ELF e_flags. */ const char *elf_cpu = avr_elf_e_flags_to_cpu_type(e_flags); From patchwork Mon Jan 27 11:38:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860245 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1970710wrq; Mon, 27 Jan 2025 03:39:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXLi0U9+nLv2jOFTY1rPa2yr1rOfw4s2kP+5baT/WCZRemLBIBxKMzVLuFoJYEDKFQ9LygGVg==@linaro.org X-Google-Smtp-Source: AGHT+IGWwkJ//et6zerVTNlm8D3AM2NE1ZcU/OxBXFNB0xX3/Gsiua45wyOMmCm7+1Zr3zC5IGRQ X-Received: by 2002:ad4:576f:0:b0:6d4:dae:6250 with SMTP id 6a1803df08f44-6e1b220a4c0mr639861286d6.34.1737977987842; Mon, 27 Jan 2025 03:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737977987; cv=none; d=google.com; s=arc-20240605; b=IE6oKlz5f0pSQ6hktG0jaab/xdLbDSUkHXMZDDsQ9kT8+tQoEZElgnZp476HcanCdm sU1P8RK7l8dN2bCsqSrm6BP07lmZL9/jEAcLHSVS2R5WGwv2gbRzENpVccmCyLuHaUW/ s4JjiwpJ8HnFLWJZjj1teOPSVKkAlYk0Ll53bY+qq61jXcF3z7uYxnTrZkKEza7lBbBs qlqrRryUt0bFt/wOc4+1Ezhjl0jtOByFlp478Pt4DyljL9vXhXyGD5bCMf/FeQH6LUhK KF3F4/41xUmOQl59lNFoz+HEuFOsdszWW9xdgOQHrUozLGVUqgQgkxqWXm8hl8UZ1QTK ARvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=7f2QljdpVMPmTAUUD5p1a6uYolSKMxu405BuJzc8Pcs=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=WNCDuAwOEIq+dv4aOREP7eibAGYFp+QcjZAMFIj4Q90m4utbgXDCeQPrD4k24k2all HTAKQdOZykW/LiwtLhwThjqenvp1oiUBb83CdLv3+XDgFfApQi4wrOOGx02bQGE1nOhy smcNy22qRa5E43qQp93Vjm9AeBuNxVu8ozqxD56sS4ue5ptLab0qh/gmTpjXUzQXarvx zGqpItvs8NoStbQAyqNolbHOH20eiNGLXesc2RtrNWvOdfaFo1wCFjiA4nx256DHkrYl hqKiqvTbIumzCTYr2Eru5CF7uz6Kz3bHmOUhL2b+L2ykt+zvxhBRkgVFwvcklg1lFUyn WPRA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oKJs2Y4B; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46e6686d207si92652761cf.98.2025.01.27.03.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:39:47 -0800 (PST) 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=oKJs2Y4B; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNRz-0005v1-Fs; Mon, 27 Jan 2025 06:38:43 -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 1tcNRx-0005si-Gc for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:41 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNRu-0005C0-4o for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:40 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4362bae4d7dso30103415e9.1 for ; Mon, 27 Jan 2025 03:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977916; x=1738582716; 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=7f2QljdpVMPmTAUUD5p1a6uYolSKMxu405BuJzc8Pcs=; b=oKJs2Y4BRLVBXO7RO9q3kikLt4emzO+aEZbg3kPOrJt4ZzFAOmCfBiq8lnaQH/Sj8l GMqbm2uDvra9aYRyzAo+u96orxevYpbvySEI4+4TQCmDBUmyrHWNNT99bN5KUc+5K9L9 DBf0uodnqfaEKH4u9QaZCCYUHDE8vJC33d44/28ZpcNI04iVDPiVJw9RmLecXSqIlH7W Mptx49x9BCZI3Lv7ccF5pO7iKOtz5bWb2O+owSvmbzoU1VygGZ2Qi/vsjD54fmB/l70o 6WvL/OaPWKXEdtNGr+7AOc+P39XwGoqlT59XPGCjni6cgVuvAZVzGYLEpmi2DXBaGsNe sZaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977916; x=1738582716; 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=7f2QljdpVMPmTAUUD5p1a6uYolSKMxu405BuJzc8Pcs=; b=gZsa8mCWl++kdYBmvdndeJURIrCBCP3GZlMbFqzCrKJiu06kJIREWx6B9+hbK2F9ez q/1okb6U+zkRbTp8w1ZFNVB9VcsjHX+8nBLaeouKZLk+8cpM+Y6+u23diddWUBMaeC2d 5oarOCEPy+lC8HVadHiIYBReVcbBWZTgZmeOXCk9cRouG5oSPf3AiUH5PLqQmeoejB+4 GkNKmFUWBhz20zd32gMSOHDDnk+LBZXm9J7RtGws/WIbUavWhWbTpcCjkuiBXqIgETXB /90iZsUAbdJKO9Er9n2K0WgZaW0lvr+dBbvIyPlEwpwjQ7EtkMGBPWCVlPxoDI3ZhqqT YCMg== X-Gm-Message-State: AOJu0YwWxSMApSB+U+7ATofLxiaAADW2K3RPj87fu8votIjQkzzLNY0J bNPaiuyunyscmNHmzwODbp690wur+WHfcrYRyRHykeg+Asxdrxv/Omye3nJE0ns8O3bNIyGrruc XfcA= X-Gm-Gg: ASbGncuFx6Cniw69EXJnmOGDJc+5uh3z2fRRoXbVOkMQ6HXlUgBEJG1T7uxnkGZZra5 gOVFgSlFWer9TEBE+WEjz+XVoc3GFFaKY7sRCqfutZmqZ5z7iD84DNMwnYvQSfKz+7vEgDtvzQY MAR0NE5Om3hrCAokxf4JATYUB1A/n5tHMyE0QrFut7j6mOkOlTsuZKEqLvX8ImQjfcV7XUyHNRL RaJbU0KUus8YzZiM7UP7FF+gFYXq7q/XVR01v7GiehqJfvc5pX/0UXgbDZLn4QkjM8uBhYpubot 9ux5P8wFMJ3fMfCSRNj3/u4Ub2JyDYjgfp2DxNk/+MvVpHErBPvVQzo= X-Received: by 2002:a05:600c:1f86:b0:436:aaf:7eb9 with SMTP id 5b1f17b1804b1-43891439d5fmr325139905e9.20.1737977915930; Mon, 27 Jan 2025 03:38:35 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd573245sm129066725e9.33.2025.01.27.03.38.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/6] hw/loader: Remove unused load_elf_ram() Date: Mon, 27 Jan 2025 12:38:20 +0100 Message-ID: <20250127113824.50177-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=unavailable 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 Last use of load_elf_ram() was removed in commit 188e255bf8e ("hw/s390x: Remove the possibility to load the s390-netboot.img binary"), remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- include/hw/loader.h | 14 +------------- hw/core/loader.c | 16 +--------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/include/hw/loader.h b/include/hw/loader.h index 8985046be40..9bb34e6f062 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -155,20 +155,8 @@ ssize_t load_elf_ram_sym(const char *filename, int clear_lsb, int data_swab, AddressSpace *as, bool load_rom, symbol_fn_t sym_cb); -/** load_elf_ram: - * Same as load_elf_ram_sym(), but doesn't allow the caller to specify a - * symbol callback function - */ -ssize_t load_elf_ram(const char *filename, - uint64_t (*elf_note_fn)(void *, void *, bool), - uint64_t (*translate_fn)(void *, uint64_t), - void *translate_opaque, uint64_t *pentry, - uint64_t *lowaddr, uint64_t *highaddr, uint32_t *pflags, - int big_endian, int elf_machine, int clear_lsb, - int data_swab, AddressSpace *as, bool load_rom); - /** load_elf_as: - * Same as load_elf_ram(), but always loads the elf as ROM + * Same as load_elf_ram_sym(), but always loads the elf as ROM */ ssize_t load_elf_as(const char *filename, uint64_t (*elf_note_fn)(void *, void *, bool), diff --git a/hw/core/loader.c b/hw/core/loader.c index 4dfdb027eee..ead10fb6cb5 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -425,26 +425,12 @@ ssize_t load_elf_as(const char *filename, uint64_t *highaddr, uint32_t *pflags, int big_endian, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as) -{ - return load_elf_ram(filename, elf_note_fn, translate_fn, translate_opaque, - pentry, lowaddr, highaddr, pflags, big_endian, - elf_machine, clear_lsb, data_swab, as, true); -} - -/* return < 0 if error, otherwise the number of bytes loaded in memory */ -ssize_t load_elf_ram(const char *filename, - uint64_t (*elf_note_fn)(void *, void *, bool), - uint64_t (*translate_fn)(void *, uint64_t), - void *translate_opaque, uint64_t *pentry, - uint64_t *lowaddr, uint64_t *highaddr, uint32_t *pflags, - int big_endian, int elf_machine, int clear_lsb, - int data_swab, AddressSpace *as, bool load_rom) { return load_elf_ram_sym(filename, elf_note_fn, translate_fn, translate_opaque, pentry, lowaddr, highaddr, pflags, big_endian, elf_machine, clear_lsb, data_swab, as, - load_rom, NULL); + true, NULL); } /* return < 0 if error, otherwise the number of bytes loaded in memory */ From patchwork Mon Jan 27 11:38:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860246 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1970866wrq; Mon, 27 Jan 2025 03:40:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW31J6B8F1nTZKMg2qwfDvv/FpeernNAoHs4K4Y1KLCxdoAQFhyDSos4kSMM1VgB9fvmzKIsQ==@linaro.org X-Google-Smtp-Source: AGHT+IFiQKL0fBdGJBeB5YFMmlJBXA/n8S7s6JjJZki36NQEtSJooq20MBm4b66mRtYmUFCE6Tlc X-Received: by 2002:a05:620a:44c2:b0:7b6:d350:9bfc with SMTP id af79cd13be357-7be632384e0mr6297898785a.27.1737978018858; Mon, 27 Jan 2025 03:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737978018; cv=none; d=google.com; s=arc-20240605; b=dKBl74qyNc+Cd5yhM1z++KUooMSu+0QYWTtGTdLK53g+3aJcvsqA+xSrFId5t/Hejv f/38wTtX1rgagG12ZBMMLEbxGNQqXN+MHiZ7u29zJXcuvTaKWr2aiAjoguRAhKdNBFcX e6jjP9YcVq/S9czGvczrgKnq8W1VJBeQ9haRwe9zOdUIlJ6BAcvk9d274izIhy7IF1n4 +7G2AVZiUSzSRQNvI8yidVQzaEa07PaVM/cJCE9k7lqFj5GibVbbhxIOpFrDaai10SMD V3hvjL5OMZJxHbW3r5wzjPWSwPIKjhsvX5VJxJyTwKnziq0aDNo1r/x6UJ8nBP4MoZKu xuAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=onDlwj0ZIbN511qY5udeZ06adF9GhwMX2qPBrWPiGaQ=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=Sqc5Gg7wK5Fl7HY31PZ6bwxZSpYL9kvPWD2brshoi+rr0J5IDiIwCkdOSnvc8NDVWP p6HfL5pLdhoNp+yc9UMHd7VWPiaJH2wAnFd4V5Ll9YtMqVsqnuDGIgN3OZ5Ek6vdcAaF DR/A64crBSxsZ0l9e6E+Yr2LFIHqGofqUTmKtxoXvEc1wQDBHQF8LKDWH8qdufM8/60j sRvq5LMzSCVj36VEv5bGUgSrVWsLy8yAALNq/sIGz/mheSqvl25aYD93zz5Bhyeql+lo kbMvpHNuk6oZ+FR5FeqiIlcsL87XJnwkGOm/kbnQgw0jWfydYBR8E8lkad1II8afbb0i nBIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p6b9siCs; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7be9af2b867si1064028685a.609.2025.01.27.03.40.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:40:18 -0800 (PST) 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=p6b9siCs; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNS3-0005ym-D0; Mon, 27 Jan 2025 06:38:47 -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 1tcNS0-0005wZ-RT for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:44 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNRy-0005D1-Hy for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:44 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-38632b8ae71so3475377f8f.0 for ; Mon, 27 Jan 2025 03:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977921; x=1738582721; 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=onDlwj0ZIbN511qY5udeZ06adF9GhwMX2qPBrWPiGaQ=; b=p6b9siCsSdJOD0MwZLjwtjfuvcA0MKgin2SR84iYUEUAKrEzHpCBcRfEEKR2nW/gDB MHxXjBTvPIN3ukrggddqtYPHAhZrK82xtxGfzft4+uihXBLbbzNw2mF+YlVpq/vTIZrm 8KK3bPdNm4MH30Vxnat9IHxwHRRd10jdBiAraVSnFffo/9nixLreHN5TvaPDu2IWE+Vh wDZZ8B94xvS1Fj/104troNFIhpjmsRSwoCefMR2dsbJ7ur/rW4KD+C1w3K4c8uBAUlco s6IJBJ6O6WX/TNwMzaHMI1FzIsVWUemdnUSgqJcjHuLYi2pQ8Pez3L8twEXqN9tSPYbo uJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977921; x=1738582721; 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=onDlwj0ZIbN511qY5udeZ06adF9GhwMX2qPBrWPiGaQ=; b=I3ZYLmSnLUfD7genK/VSCPTEp80cNW/pxmvOHOo307cAEs4zjdTerWHCKLfcoix3Xj +nfibaapNc/2SP6qiEQ6rLRKAs57w+E5eq4+K4TBCzM0L8nm0OElG+TwMtOYqJudnH/8 hWRkp+X80zl0vH9Fz2FiuSZ1iwy5Zt0mONty7B/WXoYS8hfIzum7t4RZsmj2HkN34qzr qVT9ZESAfKGyzJCs4J2By8qLiA/utHnmbeQV2VDHbZB4NWLXBHtGaWijJiwKjJFLIFhr zz0uRqWog9a0yOfLk6XSH7q1H6dj29wQsRiprro4C2FvPiMJ4bUhWmad7/60x0xqM8zY W/8A== X-Gm-Message-State: AOJu0YxUYxUOlduO83TeIrOtIqCgATMiIq5hFgDyrLBdzfFXEcSzfF8w S0dOiMFYnqZaRmlITF+6mQa7XjMX6bRBagm5WXYeW1BorGyVgUpQFahCx32uqq56qaN+enO/lsx efd8= X-Gm-Gg: ASbGncvaEdYzwVG1uuiuHPofmHN/FNEAU2mYopqQ8GmnsnRRPjE5T2ZCn95CSFjNqZh SKFfFjCTlqwXtebkfyj/PzRyonRT6vqdfCJNWbsxUjS7aaazWptb8dSP5mAC884ezTyjtUf0Dx0 yVUk7CCizyFVqakWf7wpLdouU4MF4cC/Oa4oDUr6wDVITo6ZcJbmajcwtU7c7kizLGEYcZlWLUg 9D6+f8yOCrm3QK0FVomKXUN0+jW3wyCWxNkLUNFzpvrlgHBCiw8PTh9kZhjAWb6fbHScCncC1E+ 2CPAvCrsReO3R0tUQUWe0XUibvOJ8CCy63MHGiPQYneV17tiK8nNOug= X-Received: by 2002:a5d:440e:0:b0:385:faaa:9d1d with SMTP id ffacd0b85a97d-38bf58e8751mr31668234f8f.35.1737977920723; Mon, 27 Jan 2025 03:38:40 -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-38c2a1baf65sm11004842f8f.64.2025.01.27.03.38.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:40 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/6] hw/loader: Clarify local variable name in load_elf_ram_sym() Date: Mon, 27 Jan 2025 12:38:21 +0100 Message-ID: <20250127113824.50177-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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=unavailable 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 load_elf_ram_sym() compares target_data_order versus host data_order. Rename 'data_order' -> 'host_data_order' to ease code review. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: BALATON Zoltan Reviewed-by: Richard Henderson --- hw/core/loader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index ead10fb6cb5..fc2e8f91267 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -443,7 +443,7 @@ ssize_t load_elf_ram_sym(const char *filename, int clear_lsb, int data_swab, AddressSpace *as, bool load_rom, symbol_fn_t sym_cb) { - int fd, data_order, target_data_order, must_swab; + int fd, host_data_order, target_data_order, must_swab; ssize_t ret = ELF_LOAD_FAILED; uint8_t e_ident[EI_NIDENT]; @@ -462,11 +462,11 @@ ssize_t load_elf_ram_sym(const char *filename, goto fail; } #if HOST_BIG_ENDIAN - data_order = ELFDATA2MSB; + host_data_order = ELFDATA2MSB; #else - data_order = ELFDATA2LSB; + host_data_order = ELFDATA2LSB; #endif - must_swab = data_order != e_ident[EI_DATA]; + must_swab = host_data_order != e_ident[EI_DATA]; if (big_endian) { target_data_order = ELFDATA2MSB; } else { From patchwork Mon Jan 27 11:38:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860242 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1970650wrq; Mon, 27 Jan 2025 03:39:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWqK+J61tu5c1wxgLrwbyEu23yHcVaaJ3Goauda4l18PRGjlxZqF3aTKMk+HIDU7+3YwL+4/g==@linaro.org X-Google-Smtp-Source: AGHT+IEoSNw768JEBa20WfyUIE0y3aVwY3J3nXJyxmsa31TdVEDByrRBTCaLngv0GUKy2m0TgNjh X-Received: by 2002:a05:6214:d67:b0:6d8:a5f7:f116 with SMTP id 6a1803df08f44-6e1b22353a4mr572501706d6.42.1737977977546; Mon, 27 Jan 2025 03:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737977977; cv=none; d=google.com; s=arc-20240605; b=YHprdxOUw/OPfLfWTivoHOLTl26dAbkUg7mT3iStIPVaGIivts51fjKoepH3utZX1t 7GFJhlqYDY5zRPUphUT+Z3G3NmFgW63XmXDrs9EU85vyQyyDxVkdfVZr8tbb+poKUOao 71/MPpzgvSPXzkiK76kVC4EqKMgQI8yHxcm0j5Vc0TOdqmgrNFArNzIQEltcgh4fIouP RXjDjSvFY8EIFoplbYIlNOkmpOsxiwR4JCvx6yBaXr03Fxykr/614ikl+29XrEdhsXwX kgeYe4FusKB8jtHFujewk0R6eYozbxkIaOMAeiU4tGhABqW8SYtbxdXH7VLzGPCVocHZ 6/ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=duOqb1GCMJx47PEXJD6iEC2jwq3vPcsjz9INrZ4jd4c=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=PkpCjrzRO2zhfdUBq+NCM6xqq60+tVlH7LTTm3yOu4ivSnMC8YzhXw/3EKWEQI1JV4 0zt2Ob9r+Yt4RJ5BHxNEjHY6DIg8Bo2bobiJwtcUQNaS4Y5rgULKQvOOUWbgIxuFNfp6 kG20cbXjiQPrSa0gq8AiIHTqiLTaBgZFPRyAMU8ude0sDfRCnhsEr175ZWCC+cAY0zlX ZI5d0/6iIzbF1O+G2U/FAJN/Uc+DWpBXlLV0ZM9MVArOuLl+I1lj6igp6Z5oy1vEK6eq vZeg+/98GxP1npd3uCGkErxErtyHJDLJW2Ciz55aJBuXXpt7J8IM5jPQJASnKUcH2htR xmVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a1Gvi2c8; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6e205df7785si94315576d6.179.2025.01.27.03.39.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:39:37 -0800 (PST) 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=a1Gvi2c8; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNST-00062g-B3; Mon, 27 Jan 2025 06:39:16 -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 1tcNS5-0005zX-R7 for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:50 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNS3-0005Dz-3O for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:49 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-385e06af753so2299560f8f.2 for ; Mon, 27 Jan 2025 03:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977925; x=1738582725; 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=duOqb1GCMJx47PEXJD6iEC2jwq3vPcsjz9INrZ4jd4c=; b=a1Gvi2c8CdABavKz3SYRmeVC1qz4mcgQyD7/kxnuGXAZS2raUuqMMsCZDNhlG8whOa FNZPG5sw2UwFRofV5CTiIN/jKGFiY0EyIPDI8EcOvzgCnynKqcrxWtCVhu7g9r/8b+Qs 260qRmKM5KFOvxv+3q6pdZxT17Pym2Yk9F0mdzmebRQIQUIA5ZDYfb/Zje32tBSGo7Jk 1h5G0x/Gv61tyS2cBPMrwDcN0R5eGWJJ8Zp0NP2Z1HjhX4mXBPnTerJoK5fLNN481Drn UaAu4QULdr0vMCmLhfmO6QuhLPfXSoaPgG/MasC4aavHu43u41D69IfthxDNujWNwE05 1O0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977925; x=1738582725; 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=duOqb1GCMJx47PEXJD6iEC2jwq3vPcsjz9INrZ4jd4c=; b=g17+eJQiSB1th4WsWJMoEJjAqP8xrU/nHhgct9xDC1c167GeelB1g0ss6Yu8UQu0W+ ZNt9N3fDMfgrYkNQb/asGRH5/31gvlj+Nh3DzOxZn5Wg+nVn/b3pw9N8wvLgLydtwOv+ WtT4eExQQ1yxoKnIXyo7iO1yTCUoLNqP9GnFvcty+zi4GxUWyR3PcLMGwL+wdg3F4iF1 1ewDpqwfdbZSYqcdNYT927GrxBtVGFyes/eMc0JgbqYqdXJQiC02YGiWrnBXJpVr8HKi h3f12W8S95vW+t1ILdHr6HLdTenIpLU6zaZWAyhriPo6E7TL4t05XOu7fbUR1I6j/YxD v+LA== X-Gm-Message-State: AOJu0YzmxRyTbcfmZFFU62XV0IlwEPkR9z//nVp/G4ObnaJYOU5uezk9 0mexiUazIFiCUS7Fd0SIzsmA80KvE3z16/DlsWQ/umvkemiosPb6vnW3QoFasQHgHyHFxXGo8Ez otPI= X-Gm-Gg: ASbGncu3c0QADNlkKz8905C47k4YePwjbNZNriFMaVMy1XfyYNodE32YYfJ5qyXa8GM t7tn0N8tTYRaiyA1+TLXkRm74naPqz5GzwJ4F0pO2Qr7fuD9a8kyl0a+sff/azxvJgLYWtWcewd jIxWtF3vv/dEE9mRaU411zPlwp4yy5VW0BAx/kmfoIkCfSrwcfJVJQqcp3DQ+m8kyhKSMPTomxO br3ID7XXW9HSYLlyHYcz/omtNRfVOx0cdZgjTu8pazaDpPEmeOtxU4+3xN6aZsJo6UCkz59q7nH EweOwZYokMlICSTjawSRs2WGiQEDJ1ZHHeHYApY4R2R73TfC9IBv0djHh+wPdGV+3A== X-Received: by 2002:adf:eb10:0:b0:385:fc00:f5d4 with SMTP id ffacd0b85a97d-38bf566ce7dmr28102438f8f.29.1737977925293; Mon, 27 Jan 2025 03:38:45 -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-38c2a1c3994sm10608811f8f.81.2025.01.27.03.38.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:44 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/6] hw/loader: Pass ELFDATA endian order argument to load_elf_ram_sym() Date: Mon, 27 Jan 2025 12:38:22 +0100 Message-ID: <20250127113824.50177-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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=unavailable 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 Rather than passing a boolean 'is_big_endian' argument, directly pass the ELFDATA, which can be unspecified using the ELFDATANONE value. Update the call sites: 0 -> ELFDATA2LSB Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/loader.h | 4 ++-- hw/core/loader.c | 23 ++++++++++------------- hw/riscv/boot.c | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/hw/loader.h b/include/hw/loader.h index 9bb34e6f062..8202c376043 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -120,7 +120,7 @@ const char *load_elf_strerror(ssize_t error); * @lowaddr: Populated with lowest loaded address. Ignored if NULL. * @highaddr: Populated with highest loaded address. Ignored if NULL. * @pflags: Populated with ELF processor-specific flags. Ignore if NULL. - * @bigendian: Expected ELF endianness. 0 for LE otherwise BE + * @elf_data_order: Expected ELF endianness (ELFDATA2LSB or ELFDATA2MSB). * @elf_machine: Expected ELF machine type * @clear_lsb: Set to mask off LSB of addresses (Some architectures use * this for non-address data) @@ -151,7 +151,7 @@ ssize_t load_elf_ram_sym(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, - uint32_t *pflags, int big_endian, int elf_machine, + uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as, bool load_rom, symbol_fn_t sym_cb); diff --git a/hw/core/loader.c b/hw/core/loader.c index fc2e8f91267..0cd34425e9c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -428,7 +428,8 @@ ssize_t load_elf_as(const char *filename, { return load_elf_ram_sym(filename, elf_note_fn, translate_fn, translate_opaque, - pentry, lowaddr, highaddr, pflags, big_endian, + pentry, lowaddr, highaddr, pflags, + big_endian ? ELFDATA2MSB : ELFDATA2LSB, elf_machine, clear_lsb, data_swab, as, true, NULL); } @@ -439,11 +440,11 @@ ssize_t load_elf_ram_sym(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, - uint32_t *pflags, int big_endian, int elf_machine, + uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as, bool load_rom, symbol_fn_t sym_cb) { - int fd, host_data_order, target_data_order, must_swab; + int fd, host_data_order, must_swab; ssize_t ret = ELF_LOAD_FAILED; uint8_t e_ident[EI_NIDENT]; @@ -461,22 +462,18 @@ ssize_t load_elf_ram_sym(const char *filename, ret = ELF_LOAD_NOT_ELF; goto fail; } + + if (elf_data_order != ELFDATANONE && elf_data_order != e_ident[EI_DATA]) { + ret = ELF_LOAD_WRONG_ENDIAN; + goto fail; + } + #if HOST_BIG_ENDIAN host_data_order = ELFDATA2MSB; #else host_data_order = ELFDATA2LSB; #endif must_swab = host_data_order != e_ident[EI_DATA]; - if (big_endian) { - target_data_order = ELFDATA2MSB; - } else { - target_data_order = ELFDATA2LSB; - } - - if (target_data_order != e_ident[EI_DATA]) { - ret = ELF_LOAD_WRONG_ENDIAN; - goto fail; - } lseek(fd, 0, SEEK_SET); if (e_ident[EI_CLASS] == ELFCLASS64) { diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 90e75c69a04..c309441b7d8 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -246,7 +246,8 @@ void riscv_load_kernel(MachineState *machine, */ kernel_size = load_elf_ram_sym(kernel_filename, NULL, NULL, NULL, NULL, &info->image_low_addr, &info->image_high_addr, - NULL, 0, EM_RISCV, 1, 0, NULL, true, sym_cb); + NULL, ELFDATA2LSB, EM_RISCV, + 1, 0, NULL, true, sym_cb); if (kernel_size > 0) { info->kernel_size = kernel_size; goto out; From patchwork Mon Jan 27 11:38:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860247 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1971198wrq; Mon, 27 Jan 2025 03:41:17 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU2bnIvxew9fa8YvO7YREOQ/fvq5qrHFy9BSOFXNsWWVbEaZ/t+8oGwc5pXSOcpDjPie9d4OA==@linaro.org X-Google-Smtp-Source: AGHT+IGldU+fmflm1z8z3/FlzjiIYQwEnnSSoe5naXWAB5RZTOtvfFZ3LBJtKxLyAFZNWF23CU2t X-Received: by 2002:a05:620a:2985:b0:7b6:91a4:845b with SMTP id af79cd13be357-7be6321bf2emr5148538085a.15.1737978077203; Mon, 27 Jan 2025 03:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737978077; cv=none; d=google.com; s=arc-20240605; b=DCEo2mpuvs7T5kv4sMGzfhbuVrqIyBsFf2SL1QxFAKZkMj2lxZKiH1veSToxRKa7Va 4oO1Dd5LuG0JAAW/lqVGsvE/94ZIXcs9b8cj0GLk9WNEaQviw2/+BOaUdxZg9c9zU60Z v/XtaRGbn+7zJpyqiMwCMT8TC03pYqP3GiUvXxPBzRMM/rewb1hGFyLBAg23+rhXW9hD urJV1oUzqxO87pJoH/w66JrH0nP10lVZZIKq3zQ4Xdgjr42sv3WIsGCuirBmqbg2Zm53 YPpmNj5piN5JHT3p83HBz3odvluMi5XGnvdd+3DOe9JIPWun3MBLPbgXCCMJLYFLDo/R vcOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=uL+nnGyGOIubwvzcr2z3yGpj5dC7Jx5PGuyfw3ZHtPA=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=NQeFogLjPVGwRjqb6h3wFlRHkc54c82C0E/cFUwt6k1ZMxarfYcKSyYePmsPaqtWtt 1Kfw+lVybScINbPgiU8zKKp2ZslDHkqzTnfdeWA8SA59J8x7unFmCX6ecqj89bs4MJPk L7otu9HsI4cycUMN2dJkY3UcSOfG22dAJmJzV3Ve9Ut5qr9r8ykK3IG7sYgECZmwEc2B XVRlyeUf9mMzlOAlgrUqAXvb9KdkHatTxdicLI0OZsGWf0BqjbKVShzRSqHLrKEkZnLa 4hJWpokWYOk/mqn4sYNQV3wl7tWtkFq/fvOI7hzfSNGLB+Hu5liOb8FUULZHGXhbdNK4 ZZhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFHi0fXo; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7be9aeeec12si933376285a.357.2025.01.27.03.41.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:41:17 -0800 (PST) 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=vFHi0fXo; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNSX-00066L-4N; Mon, 27 Jan 2025 06:39:18 -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 1tcNSB-000614-Do for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:56 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNS8-0005Er-BK for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:38:55 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-438a3216fc2so44609085e9.1 for ; Mon, 27 Jan 2025 03:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977931; x=1738582731; 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=uL+nnGyGOIubwvzcr2z3yGpj5dC7Jx5PGuyfw3ZHtPA=; b=vFHi0fXoI5Y0r6xCKe8YY2REAlR7joZUigBzw9yjP9gdkJtQsscyeDE5GInmNaLnun 4gEu7NhdyOaUgo7oE1moQMa3RoanFD1TiBEBt+8CIUk/qyVRbLYjPOGthC6WKN2Rsri0 wwkNJTtvGwM3vT5PU2MaDzXedcsbFtNcf1yOofJ8GQrpZgo3NGZALxBkT2QK5/GIP0H4 PB67qrDKm6wKRoy+Um2v0joMee8WHFi+ErQUlVVDUOZPxsCfte23yLPCAoCb88nD41EO 8vgglxKaZooZVH2tXE+Dicxeph8AUtnJxAUIyj5z0pP7O5Ph0jlrXDiC2mH4EkmsbFJS qI9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977931; x=1738582731; 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=uL+nnGyGOIubwvzcr2z3yGpj5dC7Jx5PGuyfw3ZHtPA=; b=kdGNkDaOVwNrHHHtxma0gDzeckLthhLPfh59uBHJmsIruW3P1i6DmrvkDGUqIXgRdX 0MLyl1UkZz0KdZw7wFU6OkKmxKby7BD/tb1eD1UZxkF+u6egYuDEcz/FJQBWNBsKMeRd H2fJH+t3n+VnAsTyxsOJ6YpG4yKYWPSxUinSFCDq8DjtbQDJADFsR17Ib5d7zwvQ3DA+ TcO67fOC3k85Hu4qJPUpv8WM22iVJDW9s5SF5reH9wU9M6oduWs9M97FnRHwC9vgCb+D HdCNUQszw5Ha+YKenSGKKh+ibACbm/mYVIXzMVT073Y9pI+qlGSMAVQTYudgCuEY4en0 miVQ== X-Gm-Message-State: AOJu0YxVTiNXA//q9Mbs4G84pFZhZJyz+RfRQ1F9yl3PxT9AR0AaNYsJ igDzUHwDO+k4kaq8ztl//3R998+tETLBD11t8Exxui5ch54ezQWkWhGaMA628sqs2Bk4/+V9pwD HssQ= X-Gm-Gg: ASbGnctUYBUalnU3LKZVFfyVYErpL1LeEXc1wH8O8f0z1jRfHf6WhSeiNgT4c6nC/Xc x0EjNwPXvSraCti4h0ILI9a/vVb4xhdOqH7EuufaN/zYXEJTD28oKIwMnBagXNdK5wCVIVxZHqm iYpkIGZw+YHtt/OKMuR1rhlKsP3yWHZAhVR9gTsyCz/RBjvPU3BlNtks19tSLQ09Y2akKxDsxtM QG0KgJ2gXmqXCbegb0YVjl0IsXS7BLqgwZAbsWNtzNCNXixjnOF3Ne/TSEZ9LvQxjzjNds9gozf u4pafTR+PZYa5g5dQVzFK1PxR+Ufq5pYYUsIO0F90rCEPdTWqUaK9Q0= X-Received: by 2002:a05:600c:35c3:b0:438:a290:3ce0 with SMTP id 5b1f17b1804b1-438a2903f47mr322246355e9.8.1737977930619; Mon, 27 Jan 2025 03:38:50 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd54c0d1sm130524395e9.26.2025.01.27.03.38.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:49 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 5/6] hw/loader: Pass ELFDATA endian order argument to load_elf_as() Date: Mon, 27 Jan 2025 12:38:23 +0100 Message-ID: <20250127113824.50177-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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=unavailable 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 Rather than passing a boolean 'is_big_endian' argument, directly pass the ELFDATA, which can be unspecified using the ELFDATANONE value. Update the call sites: 0 -> ELFDATA2LSB 1 -> ELFDATA2MSB Note, this allow removing the target_words_bigendian() call in the GENERIC_LOADER device, where we pass ELFDATANONE. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/loader.h | 2 +- hw/core/loader.c | 8 ++++---- hw/arm/armv7m.c | 2 +- hw/arm/boot.c | 16 ++++++++-------- hw/avr/boot.c | 2 +- hw/core/generic-loader.c | 6 +----- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/include/hw/loader.h b/include/hw/loader.h index 8202c376043..84737c05b8d 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -162,7 +162,7 @@ ssize_t load_elf_as(const char *filename, uint64_t (*elf_note_fn)(void *, void *, bool), uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, - uint64_t *highaddr, uint32_t *pflags, int big_endian, + uint64_t *highaddr, uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as); diff --git a/hw/core/loader.c b/hw/core/loader.c index 0cd34425e9c..84c7f7987ec 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -413,7 +413,8 @@ ssize_t load_elf(const char *filename, int elf_machine, int clear_lsb, int data_swab) { return load_elf_as(filename, elf_note_fn, translate_fn, translate_opaque, - pentry, lowaddr, highaddr, pflags, big_endian, + pentry, lowaddr, highaddr, pflags, + big_endian ? ELFDATA2MSB : ELFDATA2LSB, elf_machine, clear_lsb, data_swab, NULL); } @@ -422,14 +423,13 @@ ssize_t load_elf_as(const char *filename, uint64_t (*elf_note_fn)(void *, void *, bool), uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, - uint64_t *highaddr, uint32_t *pflags, int big_endian, + uint64_t *highaddr, uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab, AddressSpace *as) { return load_elf_ram_sym(filename, elf_note_fn, translate_fn, translate_opaque, - pentry, lowaddr, highaddr, pflags, - big_endian ? ELFDATA2MSB : ELFDATA2LSB, + pentry, lowaddr, highaddr, pflags, elf_data_order, elf_machine, clear_lsb, data_swab, as, true, NULL); } diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index a67a890a33e..98a69846119 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -608,7 +608,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, if (kernel_filename) { image_size = load_elf_as(kernel_filename, NULL, NULL, NULL, &entry, NULL, NULL, - NULL, 0, EM_ARM, 1, 0, as); + NULL, ELFDATA2LSB, EM_ARM, 1, 0, as); if (image_size < 0) { image_size = load_image_targphys_as(kernel_filename, mem_base, mem_size, as); diff --git a/hw/arm/boot.c b/hw/arm/boot.c index b44bea8a821..cbc24356fc1 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -798,7 +798,7 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, Elf64_Ehdr h64; } elf_header; int data_swab = 0; - bool big_endian; + int elf_data_order; ssize_t ret; Error *err = NULL; @@ -814,12 +814,12 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, } if (elf_is64) { - big_endian = elf_header.h64.e_ident[EI_DATA] == ELFDATA2MSB; - info->endianness = big_endian ? ARM_ENDIANNESS_BE8 - : ARM_ENDIANNESS_LE; + elf_data_order = elf_header.h64.e_ident[EI_DATA]; + info->endianness = elf_data_order == ELFDATA2MSB ? ARM_ENDIANNESS_BE8 + : ARM_ENDIANNESS_LE; } else { - big_endian = elf_header.h32.e_ident[EI_DATA] == ELFDATA2MSB; - if (big_endian) { + elf_data_order = elf_header.h32.e_ident[EI_DATA]; + if (elf_data_order == ELFDATA2MSB) { if (bswap32(elf_header.h32.e_flags) & EF_ARM_BE8) { info->endianness = ARM_ENDIANNESS_BE8; } else { @@ -839,8 +839,8 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, } ret = load_elf_as(info->kernel_filename, NULL, NULL, NULL, - pentry, lowaddr, highaddr, NULL, big_endian, elf_machine, - 1, data_swab, as); + pentry, lowaddr, highaddr, NULL, elf_data_order, + elf_machine, 1, data_swab, as); if (ret <= 0) { /* The header loaded but the image didn't */ error_report("Couldn't load elf '%s': %s", diff --git a/hw/avr/boot.c b/hw/avr/boot.c index 6a91dcd12d0..e5a29c7218e 100644 --- a/hw/avr/boot.c +++ b/hw/avr/boot.c @@ -73,7 +73,7 @@ bool avr_load_firmware(AVRCPU *cpu, MachineState *ms, bytes_loaded = load_elf_as(filename, NULL, NULL, NULL, &entry, NULL, NULL, - &e_flags, 0, EM_AVR, 0, 0, NULL); + &e_flags, ELFDATA2LSB, EM_AVR, 0, 0, NULL); if (bytes_loaded >= 0) { /* If ELF file is provided, determine CPU type reading ELF e_flags. */ const char *elf_cpu = avr_elf_e_flags_to_cpu_type(e_flags); diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index 0ddb3a359a2..5fdbc3f3be2 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -31,7 +31,6 @@ */ #include "qemu/osdep.h" -#include "exec/tswap.h" #include "system/dma.h" #include "system/reset.h" #include "hw/boards.h" @@ -63,7 +62,6 @@ static void generic_loader_realize(DeviceState *dev, Error **errp) { GenericLoaderState *s = GENERIC_LOADER(dev); hwaddr entry; - int big_endian; ssize_t size = 0; s->set_pc = false; @@ -131,14 +129,12 @@ static void generic_loader_realize(DeviceState *dev, Error **errp) s->cpu = first_cpu; } - big_endian = target_words_bigendian(); - if (s->file) { AddressSpace *as = s->cpu ? s->cpu->as : NULL; if (!s->force_raw) { size = load_elf_as(s->file, NULL, NULL, NULL, &entry, NULL, NULL, - NULL, big_endian, 0, 0, 0, as); + NULL, ELFDATANONE, 0, 0, 0, as); if (size < 0) { size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, From patchwork Mon Jan 27 11:38:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 860244 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1970678wrq; Mon, 27 Jan 2025 03:39:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV5yMvd1yJlVIQGfbtXb3ZCp1n3uuHasU8STB6K1dIOtw8d77Bx+QyGylJfG15S53u2WnYvhA==@linaro.org X-Google-Smtp-Source: AGHT+IFis9yoSEWd4VMVO0khsAy2ANkfNoPSMF8TP1SqR5Kd43aEnpI6+1n3/Kqb/l2DTQVq3M9Y X-Received: by 2002:a05:622a:1986:b0:466:b2c9:fb00 with SMTP id d75a77b69052e-46e12a1fd6bmr696826631cf.3.1737977983420; Mon, 27 Jan 2025 03:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737977983; cv=none; d=google.com; s=arc-20240605; b=IkTRn4yh3CS4OEcahAOAyeu2760ohzFuFGbRI6sdgon41MEHwMchZ7I8MM0+KgdGi3 g/ooEEUSW01iiU+w+dXrBiyvijxn3ZxC3Di/s+rGcd7dP2swtONgund5g5bLpUPpMd4R xsD0l/VvQ7MLgMe/iN7IcdH9htBf7wDS9I/hOrkPvT1T7te/ItB9OO5/tkgReNCaUUiV Ogtu/tW4SAT86VZ9E+T3ANHLZa92+r50NGuP2raEGMfOnG65PSI5nyBQ9hT3DuQCb1B1 P/e7fDQgONLQ/rD1FOREmvP+HDq/yMy2cn5Id23TDpWTjoVTxdDV2l0Ugr2cEPv8XXu0 bXWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=IyWCR9+inWUNO9zM19VDCUUgmBaDIt6wZTx8GyyDKaM=; fh=nTj08K2Hq5weUBHsNsqSMy3CkMqm3wti1yKeq+rNqBI=; b=Ut/ooBe6A/WHZS7ihdcuYvYHiP5SydW7Skz5j9kVaPy+2WlhwsWcSW4Yyh2t9GqLKR szvwGRG4hzN87SDoomBdhJI/mBw5ZXTOOyDIir9hGpyO/ntBIZRCL9qd5Cw1p9ukTeCx eB9jos/soCs+GPsJahwa2douEwWJY2XayyP4qam0mgSCBzk1CgsvgRk+1bc3Slywezco rMaes2/jBhp1nYM8DRgZvvtbDdPK9Kq0u3AkktNgVSldAAECA7/ATZx8BJpyELNh68/n wnkOu/LnQPl19ihHR7wANKHZQ3VIKd+ZY3oML3m3oe1uymDw7Oioy/O2NS9F0nO44k48 fzag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rjYJngvB; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46e66b87abasi92709271cf.410.2025.01.27.03.39.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jan 2025 03:39:43 -0800 (PST) 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=rjYJngvB; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tcNSq-0006ZT-Tf; Mon, 27 Jan 2025 06:39:36 -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 1tcNSI-00062a-Nz for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:39:08 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcNSD-0005Fh-IT for qemu-devel@nongnu.org; Mon, 27 Jan 2025 06:39:02 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-38637614567so2017551f8f.3 for ; Mon, 27 Jan 2025 03:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737977935; x=1738582735; 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=IyWCR9+inWUNO9zM19VDCUUgmBaDIt6wZTx8GyyDKaM=; b=rjYJngvB4XNdjJjOgLhxu2ETLgzmxThOXe0yrT5b7vXlzHHMowAp+Pm1gm6/2WJ08r F41qX5k2+Z9BFZBib70UtgWpOA97MPZxymWg5Zm8H+3E9nt5l6T7qp9gZyXZMi9H8WkZ +MKiUk1P6omc80PEb28Y/gwoul0T/MiN6jemLDBGDknTA7xJ1s6BfDXwyt7l4DFvyury xNxVtg4aJuKAudSL30iC26S18AHweNEEBd+OHcx9jPOP7Rg2ywRZJRrQlb5JKzvZ/ZxH 87VfoOw1rHDp2uTrJxROCL9JBZIrEDF6+UPROahkloa3MNgfNtmCytWoDqmsmiqeB3ja 8rVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737977936; x=1738582736; 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=IyWCR9+inWUNO9zM19VDCUUgmBaDIt6wZTx8GyyDKaM=; b=bXrQzU/GNsmjrkNgx/+behNlvZAsjRehRFsaVs9/JLPB7R4ABsBTscrcI0N0DSkI8Y Z95X2UjARroiXROqc580vAgs7E2cuM62kqX2xlSYB2f4mbCKmutcAOfGzPBFJyywo2N6 U/ETwThY2PTc8pooZrr6sd+Kg1ca2jeJ0BbHhsIi7C90ayfx9NWxcSVV2Jas0cFfzTZb gLCWP2S03Gta2mFd9MX8JJe+RRZiM+56R3IzIDovsCiyipMqGIN2BJkG3JND2h4frHUb 7WLXmAve3iIaHdmrKAAlN4InDM0fqKXEGwzH8KIuxwuvgKbpJDIUCSwNL3B9dJSfNnx3 mmyQ== X-Gm-Message-State: AOJu0Yylgw3fPC7t9nCChKgPuQfZcfk7nYXWjFo04jGBtzytO/Ab/ikK wEEAEPNyNsaV1LDyzFyjtwvWgiHUHuO9w46MdHDt8PnltKXBEXSc+ByJI3Da4e7ijDBFpNxQQ1/ Kbco= X-Gm-Gg: ASbGncv7hcsBxcy8nbDTWRjc1UM82CkrNf8/gwJbpoypEuoxRYsqYYgP8erl1TwZ88g znzYPN/8o1UzEJjlcw73e1K2cwJEuRnwXBHIFipnMHvT3sbmqg4uoIvePNv9gqUb9e2TALgtNV0 MPJOAal/xkTmuwFAy/NmCxuaj3lxl4Hu1EGgN0aA5/Q7ALupnBGgp2h3K3d/mymb8Ixpj31LEFp jm2erMJjYFvxcz2iCqVpa1G94HoB1XTGBSa6umNVoDHahfEwovL49F2J8NYYbm3DZJrJ8OK6vA6 56J9aLG0I8975NGTT6yC/VMh2c0GUpaG1Bwz/ALEaEPaKXUdhCr64Jc= X-Received: by 2002:adf:a191:0:b0:385:e879:45cc with SMTP id ffacd0b85a97d-38bf566459fmr24276854f8f.19.1737977935430; Mon, 27 Jan 2025 03:38:55 -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-38c2a188fd0sm11086957f8f.58.2025.01.27.03.38.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 03:38:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 6/6] hw/loader: Pass ELFDATA endian order argument to load_elf() Date: Mon, 27 Jan 2025 12:38:24 +0100 Message-ID: <20250127113824.50177-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250127113824.50177-1-philmd@linaro.org> References: <20250127113824.50177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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=unavailable 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 Rather than passing a boolean 'is_big_endian' argument, directly pass the ELFDATA, which can be unspecified using the ELFDATANONE value. Update the call sites: 0 -> ELFDATA2LSB 1 -> ELFDATA2MSB TARGET_BIG_ENDIAN -> TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: BALATON Zoltan Reviewed-by: Richard Henderson --- Sorry, couldn't find good ways to split this patch... --- include/hw/loader.h | 2 +- hw/core/loader.c | 5 ++--- hw/alpha/dp264.c | 4 ++-- hw/hppa/machine.c | 4 ++-- hw/i386/multiboot.c | 4 ++-- hw/i386/x86-common.c | 4 ++-- hw/loongarch/boot.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/m68k/q800.c | 2 +- hw/m68k/virt.c | 2 +- hw/microblaze/boot.c | 6 ++++-- hw/mips/boston.c | 2 +- hw/mips/fuloong2e.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 5 +++-- hw/mips/mipssim.c | 3 ++- hw/openrisc/boot.c | 2 +- hw/pci-host/raven.c | 4 ++-- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 5 +++-- hw/ppc/mac_oldworld.c | 4 ++-- hw/ppc/pegasos2.c | 8 ++++---- hw/ppc/ppc405_boards.c | 2 +- hw/ppc/ppc440_bamboo.c | 3 ++- hw/ppc/sam460ex.c | 2 +- hw/ppc/spapr.c | 8 ++++---- hw/ppc/virtex_ml507.c | 4 ++-- hw/s390x/ipl.c | 6 +++--- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 5 +++-- hw/sparc64/sun4u.c | 6 +++--- hw/tricore/triboard.c | 2 +- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 3 ++- hw/xtensa/xtfpga.c | 3 ++- 36 files changed, 67 insertions(+), 59 deletions(-) diff --git a/include/hw/loader.h b/include/hw/loader.h index 84737c05b8d..784a93d6c17 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -174,7 +174,7 @@ ssize_t load_elf(const char *filename, uint64_t (*elf_note_fn)(void *, void *, bool), uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, - uint64_t *highaddr, uint32_t *pflags, int big_endian, + uint64_t *highaddr, uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab); /** load_elf_hdr: diff --git a/hw/core/loader.c b/hw/core/loader.c index 84c7f7987ec..8afb2d6cf35 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -409,12 +409,11 @@ ssize_t load_elf(const char *filename, uint64_t (*elf_note_fn)(void *, void *, bool), uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, - uint64_t *highaddr, uint32_t *pflags, int big_endian, + uint64_t *highaddr, uint32_t *pflags, int elf_data_order, int elf_machine, int clear_lsb, int data_swab) { return load_elf_as(filename, elf_note_fn, translate_fn, translate_opaque, - pentry, lowaddr, highaddr, pflags, - big_endian ? ELFDATA2MSB : ELFDATA2LSB, + pentry, lowaddr, highaddr, pflags, elf_data_order, elf_machine, clear_lsb, data_swab, NULL); } diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 52a1fa310b9..570ea9edf24 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -144,7 +144,7 @@ static void clipper_init(MachineState *machine) } size = load_elf(palcode_filename, NULL, cpu_alpha_superpage_to_phys, NULL, &palcode_entry, NULL, NULL, NULL, - 0, EM_ALPHA, 0, 0); + ELFDATA2LSB, EM_ALPHA, 0, 0); if (size < 0) { error_report("could not load palcode '%s'", palcode_filename); exit(1); @@ -163,7 +163,7 @@ static void clipper_init(MachineState *machine) size = load_elf(kernel_filename, NULL, cpu_alpha_superpage_to_phys, NULL, &kernel_entry, &kernel_low, NULL, NULL, - 0, EM_ALPHA, 0, 0); + ELFDATA2LSB, EM_ALPHA, 0, 0); if (size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 8230f43e41c..b062f5eec95 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -429,7 +429,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, size = load_elf(firmware_filename, NULL, translate, NULL, &firmware_entry, &firmware_low, &firmware_high, NULL, - true, EM_PARISC, 0, 0); + ELFDATA2MSB, EM_PARISC, 0, 0); if (size < 0) { error_report("could not load firmware '%s'", firmware_filename); @@ -456,7 +456,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, if (kernel_filename) { size = load_elf(kernel_filename, NULL, linux_kernel_virt_to_phys, NULL, &kernel_entry, &kernel_low, &kernel_high, NULL, - true, EM_PARISC, 0, 0); + ELFDATA2MSB, EM_PARISC, 0, 0); kernel_entry = linux_kernel_virt_to_phys(NULL, kernel_entry); diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 1d66ca3204a..cd07a058614 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -202,8 +202,8 @@ int load_multiboot(X86MachineState *x86ms, } kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry, - &elf_low, &elf_high, NULL, 0, I386_ELF_MACHINE, - 0, 0); + &elf_low, &elf_high, NULL, + ELFDATA2LSB, I386_ELF_MACHINE, 0, 0); if (kernel_size < 0) { error_report("Error while loading elf kernel"); exit(1); diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 008496b5b85..1b0671c5239 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -608,8 +608,8 @@ static bool load_elfboot(const char *kernel_filename, uint64_t elf_note_type = XEN_ELFNOTE_PHYS32_ENTRY; kernel_size = load_elf(kernel_filename, read_pvh_start_addr, NULL, &elf_note_type, &elf_entry, - &elf_low, &elf_high, NULL, 0, I386_ELF_MACHINE, - 0, 0); + &elf_low, &elf_high, NULL, + ELFDATA2LSB, I386_ELF_MACHINE, 0, 0); if (kernel_size < 0) { error_report("Error while loading elf kernel"); diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index bd8763c61c3..354cf458c81 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -243,7 +243,7 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info) kernel_size = load_elf(info->kernel_filename, NULL, cpu_loongarch_virt_to_phys, NULL, &kernel_entry, &kernel_low, - &kernel_high, NULL, 0, + &kernel_high, NULL, ELFDATA2LSB, EM_LOONGARCH, 1, 0); if (kernel_size < 0) { kernel_size = load_loongarch_linux_image(info->kernel_filename, diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c index 7b8210475ec..d97399b882b 100644 --- a/hw/m68k/an5206.c +++ b/hw/m68k/an5206.c @@ -74,7 +74,7 @@ static void an5206_init(MachineState *machine) } kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry, - NULL, NULL, NULL, 1, EM_68K, 0, 0); + NULL, NULL, NULL, ELFDATA2MSB, EM_68K, 0, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL, diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 409bb72574c..75cc076f787 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -372,7 +372,7 @@ static void mcf5208evb_init(MachineState *machine) } kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry, - NULL, NULL, NULL, 1, EM_68K, 0, 0); + NULL, NULL, NULL, ELFDATA2MSB, EM_68K, 0, 0); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL, diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index ca3adb9a8ae..aeed4c8ddb8 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -585,7 +585,7 @@ static void q800_machine_init(MachineState *machine) } kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, - &elf_entry, NULL, &high, NULL, 1, + &elf_entry, NULL, &high, NULL, ELFDATA2MSB, EM_68K, 0, 0); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index 87ec39eeae1..d967bdd7438 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -228,7 +228,7 @@ static void virt_init(MachineState *machine) } kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, - &elf_entry, NULL, &high, NULL, 1, + &elf_entry, NULL, &high, NULL, ELFDATA2MSB, EM_68K, 0, 0); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 3854bc2291b..60b4ef0abe7 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -144,13 +144,15 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian, /* Boots a kernel elf binary. */ kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &entry, NULL, &high, NULL, - !is_little_endian, EM_MICROBLAZE, 0, 0); + is_little_endian ? ELFDATA2LSB : ELFDATA2MSB, + EM_MICROBLAZE, 0, 0); base32 = entry; if (base32 == 0xc0000000) { kernel_size = load_elf(kernel_filename, NULL, translate_kernel_address, NULL, &entry, NULL, NULL, NULL, - !is_little_endian, EM_MICROBLAZE, 0, 0); + is_little_endian ? ELFDATA2LSB : ELFDATA2MSB, + EM_MICROBLAZE, 0, 0); } /* Always boot into physical ram. */ boot_info.bootstrap_pc = (uint32_t)entry; diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 67044af962a..364c328032a 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -792,7 +792,7 @@ static void boston_mach_init(MachineState *machine) kernel_size = load_elf(machine->kernel_filename, NULL, cpu_mips_kseg0_to_phys, NULL, &kernel_entry, NULL, &kernel_high, - NULL, 0, EM_MIPS, 1, 0); + NULL, ELFDATA2LSB, EM_MIPS, 1, 0); if (kernel_size > 0) { int dt_size; diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 16b6a5129e7..646044e2749 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -106,7 +106,7 @@ static uint64_t load_kernel(MIPSCPU *cpu) cpu_mips_kseg0_to_phys, NULL, &kernel_entry, NULL, &kernel_high, NULL, - 0, EM_MIPS, 1, 0); + ELFDATA2LSB, EM_MIPS, 1, 0); if (kernel_size < 0) { error_report("could not load kernel '%s': %s", loaderparams.kernel_filename, diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index f3cc7a8376f..2ec2394cfaf 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -358,7 +358,7 @@ static uint64_t load_kernel(CPUMIPSState *env) cpu_mips_kseg0_to_phys, NULL, &kernel_entry, &kernel_low, &kernel_high, - NULL, 0, EM_MIPS, 1, 0); + NULL, ELFDATA2LSB, EM_MIPS, 1, 0); if (kernel_size < 0) { error_report("could not load kernel '%s': %s", loaderparams.kernel_filename, diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 4e9cccaa347..8e9cea70b13 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -880,8 +880,9 @@ static uint64_t load_kernel(void) kernel_size = load_elf(loaderparams.kernel_filename, NULL, cpu_mips_kseg0_to_phys, NULL, &kernel_entry, NULL, - &kernel_high, NULL, TARGET_BIG_ENDIAN, EM_MIPS, - 1, 0); + &kernel_high, NULL, + TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB, + EM_MIPS, 1, 0); if (kernel_size < 0) { error_report("could not load kernel '%s': %s", loaderparams.kernel_filename, diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index a294779a82b..c530688e769 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -73,7 +73,8 @@ static uint64_t load_kernel(void) kernel_size = load_elf(loaderparams.kernel_filename, NULL, cpu_mips_kseg0_to_phys, NULL, &entry, NULL, - &kernel_high, NULL, TARGET_BIG_ENDIAN, + &kernel_high, NULL, + TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB, EM_MIPS, 1, 0); if (kernel_size < 0) { error_report("could not load kernel '%s': %s", diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c index 83c1fc6705e..0f08df812dc 100644 --- a/hw/openrisc/boot.c +++ b/hw/openrisc/boot.c @@ -32,7 +32,7 @@ hwaddr openrisc_load_kernel(ram_addr_t ram_size, if (kernel_filename && !qtest_enabled()) { kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, - &elf_entry, NULL, &high_addr, NULL, 1, + &elf_entry, NULL, &high_addr, NULL, ELFDATA2MSB, EM_OPENRISC, 1, 0); entry = elf_entry; if (kernel_size < 0) { diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 918a3237a9e..e3d8d206b73 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -357,8 +357,8 @@ static void raven_realize(PCIDevice *d, Error **errp) if (filename) { if (s->elf_machine != EM_NONE) { bios_size = load_elf(filename, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, 1, s->elf_machine, - 0, 0); + NULL, NULL, NULL, + ELFDATA2MSB, s->elf_machine, 0, 0); } if (bios_size < 0) { bios_size = get_image_size(filename); diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 4551157c011..26933e0457e 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -1194,7 +1194,7 @@ void ppce500_init(MachineState *machine) payload_size = load_elf(filename, NULL, NULL, NULL, &bios_entry, &loadaddr, NULL, NULL, - 1, PPC_ELF_MACHINE, 0, 0); + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (payload_size < 0) { /* * Hrm. No ELF image? Try a uImage, maybe someone is giving us an diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 6369961f78a..cb3dc3ab482 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -182,7 +182,8 @@ static void ppc_core99_init(MachineState *machine) if (filename) { /* Load OpenBIOS (ELF) */ bios_size = load_elf(filename, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + NULL, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (bios_size <= 0) { /* or load binary ROM image */ @@ -204,7 +205,7 @@ static void ppc_core99_init(MachineState *machine) kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(machine->kernel_filename, NULL, translate_kernel_address, NULL, NULL, NULL, - NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + NULL, NULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (kernel_size < 0) { kernel_size = load_aout(machine->kernel_filename, kernel_base, machine->ram_size - kernel_base, diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 59653e174b8..0dbcea035c3 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -136,7 +136,7 @@ static void ppc_heathrow_init(MachineState *machine) if (filename) { /* Load OpenBIOS (ELF) */ bios_size = load_elf(filename, NULL, NULL, NULL, NULL, &bios_addr, - NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + NULL, NULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); /* Unfortunately, load_elf sign-extends reading elf32 */ bios_addr = (uint32_t)bios_addr; @@ -161,7 +161,7 @@ static void ppc_heathrow_init(MachineState *machine) kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(machine->kernel_filename, NULL, translate_kernel_address, NULL, NULL, NULL, - NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + NULL, NULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (kernel_size < 0) { kernel_size = load_aout(machine->kernel_filename, kernel_base, machine->ram_size - kernel_base, diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index b3c21bdc57c..0364243f4fe 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -160,8 +160,8 @@ static void pegasos2_init(MachineState *machine) } memory_region_init_rom(rom, NULL, "pegasos2.rom", PROM_SIZE, &error_fatal); memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom); - sz = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, - PPC_ELF_MACHINE, 0, 0); + sz = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (sz <= 0) { sz = load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM_SIZE); } @@ -239,8 +239,8 @@ static void pegasos2_init(MachineState *machine) if (machine->kernel_filename) { sz = load_elf(machine->kernel_filename, NULL, NULL, NULL, - &pm->kernel_entry, &pm->kernel_addr, NULL, NULL, 1, - PPC_ELF_MACHINE, 0, 0); + &pm->kernel_entry, &pm->kernel_addr, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (sz <= 0) { error_report("Could not load kernel '%s'", machine->kernel_filename); diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index e9f65fab70d..969cac345ac 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -232,7 +232,7 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu) kernel_size = load_elf(machine->kernel_filename, NULL, NULL, NULL, &boot_entry, &kernel_base, NULL, NULL, - 1, PPC_ELF_MACHINE, 0, 0); + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (kernel_size < 0) { error_report("Could not load kernel '%s' : %s", machine->kernel_filename, load_elf_strerror(kernel_size)); diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 45c5b8678d9..099fda39092 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -228,7 +228,8 @@ static void bamboo_init(MachineState *machine) if (success < 0) { uint64_t elf_entry; success = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry, - NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + NULL, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); entry = elf_entry; } /* XXX try again as binary */ diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index e74642a3b71..3ecae6a9504 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -479,7 +479,7 @@ static void sam460ex_init(MachineState *machine) success = load_elf(machine->kernel_filename, NULL, NULL, NULL, &elf_entry, NULL, NULL, NULL, - 1, PPC_ELF_MACHINE, 0, 0); + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); entry = elf_entry; } /* XXX try again as binary */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 623842f8064..f3a4b4235d4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3022,13 +3022,13 @@ static void spapr_machine_init(MachineState *machine) spapr->kernel_size = load_elf(kernel_filename, NULL, translate_kernel_address, spapr, - NULL, &loaded_addr, NULL, NULL, 1, - PPC_ELF_MACHINE, 0, 0); + NULL, &loaded_addr, NULL, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (spapr->kernel_size == ELF_LOAD_WRONG_ENDIAN) { spapr->kernel_size = load_elf(kernel_filename, NULL, translate_kernel_address, spapr, - NULL, &loaded_addr, NULL, NULL, 0, - PPC_ELF_MACHINE, 0, 0); + NULL, &loaded_addr, NULL, NULL, + ELFDATA2LSB, PPC_ELF_MACHINE, 0, 0); spapr->kernel_le = spapr->kernel_size > 0; } if (spapr->kernel_size < 0) { diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index ea7ab8a5694..23238119273 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -242,8 +242,8 @@ static void virtex_init(MachineState *machine) /* Boots a kernel elf binary. */ kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, - &entry, NULL, &high, NULL, 1, PPC_ELF_MACHINE, - 0, 0); + &entry, NULL, &high, NULL, + ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); boot_info.bootstrap_pc = entry & 0x00ffffff; if (kernel_size < 0) { diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 4aa21c91fca..ce6f6078d74 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -162,8 +162,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) bios_size = load_elf(bios_filename, NULL, bios_translate_addr, &fwbase, - &ipl->bios_start_addr, NULL, NULL, NULL, 1, - EM_S390, 0, 0); + &ipl->bios_start_addr, NULL, NULL, NULL, + ELFDATA2MSB, EM_S390, 0, 0); if (bios_size > 0) { /* Adjust ELF start address to final location */ ipl->bios_start_addr += fwbase; @@ -187,7 +187,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) if (ipl->kernel) { kernel_size = load_elf(ipl->kernel, NULL, NULL, NULL, &pentry, NULL, - NULL, NULL, 1, EM_S390, 0, 0); + NULL, NULL, ELFDATA2MSB, EM_S390, 0, 0); if (kernel_size < 0) { kernel_size = load_image_targphys(ipl->kernel, 0, ms->ram_size); if (kernel_size < 0) { diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 84381254ad0..0aeaad3becc 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -380,7 +380,7 @@ static void leon3_generic_hw_init(MachineState *machine) kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &entry, NULL, NULL, NULL, - 1 /* big endian */, EM_SPARC, 0, 0); + ELFDATA2MSB, EM_SPARC, 0, 0); if (kernel_size < 0) { kernel_size = load_uimage(kernel_filename, NULL, &entry, NULL, NULL, NULL); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index e070360a2c7..a48d3622c5a 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -242,7 +242,8 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename, #endif kernel_size = load_elf(kernel_filename, NULL, translate_kernel_address, NULL, - NULL, NULL, NULL, NULL, 1, EM_SPARC, 0, 0); + NULL, NULL, NULL, NULL, + ELFDATA2MSB, EM_SPARC, 0, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, RAM_size - KERNEL_LOAD_ADDR, bswap_needed, @@ -703,7 +704,7 @@ static void prom_init(hwaddr addr, const char *bios_name) if (filename) { ret = load_elf(filename, NULL, translate_prom_address, &addr, NULL, - NULL, NULL, NULL, 1, EM_SPARC, 0, 0); + NULL, NULL, NULL, ELFDATA2MSB, EM_SPARC, 0, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); } diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 0980b446593..8ab5cf0461f 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -176,8 +176,8 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename, bswap_needed = 0; #endif kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, kernel_entry, - kernel_addr, &kernel_top, NULL, 1, EM_SPARCV9, 0, - 0); + kernel_addr, &kernel_top, NULL, + ELFDATA2MSB, EM_SPARCV9, 0, 0); if (kernel_size < 0) { *kernel_addr = KERNEL_LOAD_ADDR; *kernel_entry = KERNEL_LOAD_ADDR; @@ -441,7 +441,7 @@ static void prom_init(hwaddr addr, const char *bios_name) filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { ret = load_elf(filename, NULL, translate_prom_address, &addr, - NULL, NULL, NULL, NULL, 1, EM_SPARCV9, 0, 0); + NULL, NULL, NULL, NULL, ELFDATA2MSB, EM_SPARCV9, 0, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); } diff --git a/hw/tricore/triboard.c b/hw/tricore/triboard.c index 9cc8d282ff2..f5baa8ccbb3 100644 --- a/hw/tricore/triboard.c +++ b/hw/tricore/triboard.c @@ -39,7 +39,7 @@ static void tricore_load_kernel(TriCoreCPU *cpu, const char *kernel_filename) kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &entry, NULL, - NULL, NULL, 0, + NULL, NULL, ELFDATA2LSB, EM_TRICORE, 1, 0); if (kernel_size <= 0) { error_report("no kernel file '%s'", kernel_filename); diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c index c29db8b451c..3facfdfd611 100644 --- a/hw/tricore/tricore_testboard.c +++ b/hw/tricore/tricore_testboard.c @@ -42,7 +42,7 @@ static void tricore_load_kernel(CPUTriCoreState *env) kernel_size = load_elf(tricoretb_binfo.kernel_filename, NULL, NULL, NULL, &entry, NULL, - NULL, NULL, 0, + NULL, NULL, ELFDATA2LSB, EM_TRICORE, 1, 0); if (kernel_size <= 0) { error_report("no kernel file '%s'", diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c index 0a1fd900376..1cea29c66d4 100644 --- a/hw/xtensa/sim.c +++ b/hw/xtensa/sim.c @@ -100,7 +100,8 @@ void xtensa_sim_load_kernel(XtensaCPU *cpu, MachineState *machine) if (kernel_filename) { uint64_t elf_entry; int success = load_elf(kernel_filename, NULL, translate_phys_addr, cpu, - &elf_entry, NULL, NULL, NULL, TARGET_BIG_ENDIAN, + &elf_entry, NULL, NULL, NULL, + TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB, EM_XTENSA, 0, 0); if (success > 0) { diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 9efe91933f9..3f3677f1c9a 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -398,7 +398,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) uint64_t elf_entry; int success = load_elf(kernel_filename, NULL, translate_phys_addr, cpu, - &elf_entry, NULL, NULL, NULL, TARGET_BIG_ENDIAN, + &elf_entry, NULL, NULL, NULL, + TARGET_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB, EM_XTENSA, 0, 0); if (success > 0) { entry_point = elf_entry;