From patchwork Mon Jan 6 08:22:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Zeng X-Patchwork-Id: 104116 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F6323858D38 for ; Mon, 6 Jan 2025 08:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F6323858D38 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [52.237.72.81]) by sourceware.org (Postfix) with ESMTP id 9512D3858D28 for ; Mon, 6 Jan 2025 08:22:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9512D3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9512D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=52.237.72.81 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736151764; cv=none; b=CrkAdd6p1iBbxd9rGZLdh4xtIFYV/LkF94cTtAmmwLzQTlQ8doo1XSCiKL+L/CnTdLxw1X9rMvLmmiXinK4tkwRUO9Hl89dpb2p6FxEcivdaztHxQ8Ap8p8F+SCFfngvM3hPpvod/v0IGOuRT3yuka3r2zU8fdouKi4MON3f0h8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736151764; c=relaxed/simple; bh=2nLR5WvfE085vBG1ycYPv5SSa7V5ZaNoxW27ALkriOU=; h=From:To:Subject:Date:Message-Id; b=RODcoHr/PD3hJVqALglKzQNfzGj15+iTXFDFPCQ/mPK3lw0BGHrm5jTMW7L2xZKsehAhR1Rt0j7W9MGVpnD9iaH9sMTWk1zkbQxBveMe17ZLiNUl9M7EtozpJ40f0K2oLtzEoBpPsE0iyrrlbTw2C1Rl9hNHdxmO6AGaFfE9tb8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9512D3858D28 Received: from localhost.localdomain (unknown [10.12.130.38]) by app1 (Coremail) with SMTP id TAJkCgDnN6bKkntnBg4MAA--.57404S5; Mon, 06 Jan 2025 16:22:36 +0800 (CST) From: Xiao Zeng To: binutils@sourceware.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, nelson@rivosinc.com, zhengyu@eswincomputing.com, jiawei@iscas.ac.cn, Xiao Zeng Subject: [PATCH] RISC-V: Correct as --dump-config output for --target=rv64* Date: Mon, 6 Jan 2025 16:22:33 +0800 Message-Id: <20250106082233.12546-2-zengxiao@eswincomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20250106082233.12546-1-zengxiao@eswincomputing.com> References: <20250106082233.12546-1-zengxiao@eswincomputing.com> X-CM-TRANSID: TAJkCgDnN6bKkntnBg4MAA--.57404S5 X-Coremail-Antispam: 1UD129KBjvJXoW3WrW5CrW8WFyUGFWkKw1Utrb_yoWxGr4xpw 4rZFWjkrZ3JF9rtr9rKr17Xa17Aw109rya9ryxC3s7A3ySk3yxJwn7tw47AFs8ta1Uuw45 Zw43Cr45CrW5Aa7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPa14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWUAVWUtw CY02Avz4vE-syl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r 1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxV WUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU e5r4UUUUU X-CM-SenderInfo: p2hqw5xldrqvxvzl0uprps33xlqjhudrp/ X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org gas/ChangeLog: * config/tc-riscv.c (riscv_target_format): Correct as --dump-config output for --target=rv64*. * testsuite/gas/riscv/elf32-bigriscv_dump.d: New test. * testsuite/gas/riscv/elf32-littleriscv_dump.d: New test. * testsuite/gas/riscv/elf64-bigriscv_dump.d: New test. * testsuite/gas/riscv/elf64-littleriscv_dump.d: New test. * testsuite/gas/riscv/linux32-bigriscv_dump.d: New test. * testsuite/gas/riscv/linux32-littleriscv_dump.d: New test. * testsuite/gas/riscv/linux64-bigriscv_dump.d: New test. * testsuite/gas/riscv/linux64-littleriscv_dump.d: New test. Signed-off-by: Xiao Zeng --- gas/config/tc-riscv.c | 12 ++++++++++++ gas/testsuite/gas/riscv/elf32-bigriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/elf32-littleriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/elf64-bigriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/elf64-littleriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/linux32-bigriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/linux32-littleriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/linux64-bigriscv_dump.d | 6 ++++++ gas/testsuite/gas/riscv/linux64-littleriscv_dump.d | 6 ++++++ 9 files changed, 60 insertions(+) create mode 100644 gas/testsuite/gas/riscv/elf32-bigriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/elf32-littleriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/elf64-bigriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/elf64-littleriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/linux32-bigriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/linux32-littleriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/linux64-bigriscv_dump.d create mode 100644 gas/testsuite/gas/riscv/linux64-littleriscv_dump.d diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index a915c8b4995..35d19ac4e5d 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -734,6 +734,18 @@ riscv_check_mapping_symbols (bfd *abfd ATTRIBUTE_UNUSED, const char * riscv_target_format (void) { + /* When as --dump-config is used, xlen is not initialized, resulting in + bfd-target being set to elf32-*riscv even with --target=rv64*. */ + if (xlen == 0) + { + if (strcmp (default_arch, "riscv32") == 0) + xlen = 32; + else if (strcmp (default_arch, "riscv64") == 0) + xlen = 64; + else + as_bad ("unknown default architecture `%s'", default_arch); + } + if (target_big_endian) return xlen == 64 ? "elf64-bigriscv" : "elf32-bigriscv"; else diff --git a/gas/testsuite/gas/riscv/elf32-bigriscv_dump.d b/gas/testsuite/gas/riscv/elf32-bigriscv_dump.d new file mode 100644 index 00000000000..28cbef31666 --- /dev/null +++ b/gas/testsuite/gas/riscv/elf32-bigriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mbig-endian -dump + +alias = riscv32-unknown-elf +canonical = riscv32-unknown-elf +cpu-type = riscv32 +bfd-target = elf32-bigriscv diff --git a/gas/testsuite/gas/riscv/elf32-littleriscv_dump.d b/gas/testsuite/gas/riscv/elf32-littleriscv_dump.d new file mode 100644 index 00000000000..8b05a89c22c --- /dev/null +++ b/gas/testsuite/gas/riscv/elf32-littleriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mlittle-endian -dump + +alias = riscv32-unknown-elf +canonical = riscv32-unknown-elf +cpu-type = riscv32 +bfd-target = elf32-littleriscv diff --git a/gas/testsuite/gas/riscv/elf64-bigriscv_dump.d b/gas/testsuite/gas/riscv/elf64-bigriscv_dump.d new file mode 100644 index 00000000000..9942545af0f --- /dev/null +++ b/gas/testsuite/gas/riscv/elf64-bigriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mbig-endian -dump + +alias = riscv64-unknown-elf +canonical = riscv64-unknown-elf +cpu-type = riscv64 +bfd-target = elf64-bigriscv diff --git a/gas/testsuite/gas/riscv/elf64-littleriscv_dump.d b/gas/testsuite/gas/riscv/elf64-littleriscv_dump.d new file mode 100644 index 00000000000..7bf1b380cb4 --- /dev/null +++ b/gas/testsuite/gas/riscv/elf64-littleriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mlittle-endian -dump + +alias = riscv64-unknown-elf +canonical = riscv64-unknown-elf +cpu-type = riscv64 +bfd-target = elf64-littleriscv diff --git a/gas/testsuite/gas/riscv/linux32-bigriscv_dump.d b/gas/testsuite/gas/riscv/linux32-bigriscv_dump.d new file mode 100644 index 00000000000..edf0d2fc4ea --- /dev/null +++ b/gas/testsuite/gas/riscv/linux32-bigriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mbig-endian -dump + +alias = riscv32-unknown-linux-gnu +canonical = riscv32-unknown-linux-gnu +cpu-type = riscv32 +bfd-target = elf32-bigriscv diff --git a/gas/testsuite/gas/riscv/linux32-littleriscv_dump.d b/gas/testsuite/gas/riscv/linux32-littleriscv_dump.d new file mode 100644 index 00000000000..49fcad0f343 --- /dev/null +++ b/gas/testsuite/gas/riscv/linux32-littleriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mlittle-endian -dump + +alias = riscv32-unknown-linux-gnu +canonical = riscv32-unknown-linux-gnu +cpu-type = riscv32 +bfd-target = elf32-littleriscv diff --git a/gas/testsuite/gas/riscv/linux64-bigriscv_dump.d b/gas/testsuite/gas/riscv/linux64-bigriscv_dump.d new file mode 100644 index 00000000000..3aedd1d1d97 --- /dev/null +++ b/gas/testsuite/gas/riscv/linux64-bigriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mbig-endian -dump + +alias = riscv64-unknown-linux-gnu +canonical = riscv64-unknown-linux-gnu +cpu-type = riscv64 +bfd-target = elf64-bigriscv diff --git a/gas/testsuite/gas/riscv/linux64-littleriscv_dump.d b/gas/testsuite/gas/riscv/linux64-littleriscv_dump.d new file mode 100644 index 00000000000..2b2deac6fcf --- /dev/null +++ b/gas/testsuite/gas/riscv/linux64-littleriscv_dump.d @@ -0,0 +1,6 @@ +#as: -mlittle-endian -dump + +alias = riscv64-unknown-linux-gnu +canonical = riscv64-unknown-linux-gnu +cpu-type = riscv64 +bfd-target = elf64-littleriscv