From patchwork Fri Dec 1 02:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 172223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp841047vqy; Thu, 30 Nov 2023 18:47:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw0jxrBSwv2JFfuwa+dDTfbtU2tT9RWdDKjKLc/KuasVXfRGzVuWPAP56lYOVcwj07rVZz X-Received: by 2002:a05:622a:1f86:b0:423:ab4a:b535 with SMTP id cb6-20020a05622a1f8600b00423ab4ab535mr23637742qtb.64.1701398876064; Thu, 30 Nov 2023 18:47:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701398876; cv=pass; d=google.com; s=arc-20160816; b=oAZrg4zmSbPow2M0ZveYAh1eHsmhnmHYov9tURZZihJ5eaGn0gRIf9GPwOhe8PN8Zv Bf3/6TJo5R5pSB/XY2UL2f4vYieUnT9xr40NqnShCb3EQ97a89Wq2lEF4Ckdie2+zKMZ ZGd95vJqDMF/pnPiMbUKDlmcPOy8IcFq3dUhp6KDUcM3e2g1exfSo/WEkv1ca8kXGHyY eW9ryGv/Q3zEpuK7S3RwluDOHbkiFop1eltAALaW23QoP4+ME8Eo7zTDpGl/9htMg5sG m8V2vW1w30ddSlYwmAxKxX1jybYtHM/SMFLUpLRhtFGKilCfGArSiLrI4f3Qm58S7ELV 5YEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=hVqfWKUShsQ3MRs6aBRsA/Oyt3+rQLFif+XFOcNOYjo=; fh=QlSljnFJ3Zn0en+1cQgkXTkvs9kvwdzigFnGYKIb/+E=; b=S5X1m2e2O3TmvKSWNMVHuaI9yJOvaFfDFjXQ2mLIiKZxgkZqvMrAqCoEXA5UJgoe0U rnu/Nss9RiNUP/TA5xookTsVGIo2kaH3JqgkD99/2UVBDtL4fsiABcwf+3OXE+7GAv2Q /GodKNoXWiDH6KUNXv/7B7HEh5q+7UxaAj3f18DkM1pEAtnsfsDYAUqNzcfckPOoKaAl OvZsDscRd7lzmJcuiOmC2YAbiBe3lIfMTHfDnoNstLgqUOq+b/3X7UHHhiFJ48NkFTAb eR3FMPz5xDCgKcy8QcGIoC2Wm5pFRyLwIhNXEZKv5m4sPFY+CF0w7FiRPVm96OgJjX3l wzXA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=oASDtbtQ; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i13-20020ac8764d000000b004236df71ca3si2193008qtr.165.2023.11.30.18.47.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 18:47:56 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=oASDtbtQ; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1D373858429 for ; Fri, 1 Dec 2023 02:47:55 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 1C9CA3858D38 for ; Fri, 1 Dec 2023 02:47:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C9CA3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1C9CA3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701398871; cv=none; b=tov1Nyar+CEvonvNNRg8R/sDfU7fsMBOGM8wiXTrEL69G1arbReWZH6uRGCaDL6xKFEZolcvhcs2dacEP1lYIqsUoSNVDnc3Yv4zg0XAmm5CiMHBm4gr0p+H3alySE8/+W6tW8TiJMPyo7vfmPN4koyEW9gn0OkQIZeExSrYj5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701398871; c=relaxed/simple; bh=MUpMLM7u69QcHFseTuRM7Vlm2obEag/x+wQdzQUre5U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qTw7Ph5LzRe3DQVb6h3zdW8a/sgZGybQvkjgXax9kqLzBlQpGfCoBaLWyzohuHtNAVEzrCBdprLnX0Pt/2FVnqm/CyUW7nzOIEdKgrECiUbmlppHgR6qAuasBotYG3btJGOLx0/cCfE/4JIO50jyh8kLTL95wVRonxLxOTysTK4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3b88f2a37deso50937b6e.0 for ; Thu, 30 Nov 2023 18:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701398867; x=1702003667; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hVqfWKUShsQ3MRs6aBRsA/Oyt3+rQLFif+XFOcNOYjo=; b=oASDtbtQsF7vTCFthhGzwqzTUvnq8ZtdHDJffJHvG1axTW34Pkl/9xWRXLyu/fvVE2 dXglwB/4hy2aJmKzZkEnSU9DaUY1kc5DWaVC+CpZcz8Q0HzFzDoUmGr/zz21xUWPEzHu IttJFqoVWLeOZdnhtI5+ini7zNONHsbxv8IftjXH0HDCMbJOXSb2tMAaVZjedW1S4kNK SeAwKL13GHd/pLme+XNMh7ftOI6y0iLBYnojPmSdxzoNMIbyVHdum9XocgS3/Cppe57v sqJ+9WmXObHwBKhUaXx441vf+ehBlgtJLS9yY0dFhGC4c3wYhmT26YvL5GJTYkh83DD2 PHxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701398867; x=1702003667; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hVqfWKUShsQ3MRs6aBRsA/Oyt3+rQLFif+XFOcNOYjo=; b=Lmizsf+wz5nfzYdSZ9ipg+IFrgpuM7Q88yV7s7okcOCVkcdQ+h/emCpLT0qR6Ylm8J i40Zk1xyz+LbvmmVM0E3clbxJLh7rzJhCL9YjXNNm8dsWItZxSiUdhbrgVQMSCjDE7lr NLryhHvZrlVgNorUUn20DOCMc5QCrG366H9czFjECrJkiIEPfwZRyyDJCbJDGHfbz9gq VOj/Gjuml20oJn+wYFQfyZZ6R9/NQhVC4g6RBehNDKpMrM+ZPt3kgf89WwOhPDS9F57+ Ar6HrhApMU6jwq32hDvNbjp8TA64f4XHJws5FJJOnbEsPba0GBA0RxQTM2fpo1e+EckE p/+g== X-Gm-Message-State: AOJu0YwITtL9HMSMvQj+x2LzSzw3imoI/Vry8OeP7G2Yrt+hTJ21h7Vz +EfhyrvJzNP+E91/a3qpFgEF31yBuySlN+SF6XaNnw== X-Received: by 2002:a05:6808:1592:b0:3b8:5e0a:c4af with SMTP id t18-20020a056808159200b003b85e0ac4afmr2063390oiw.18.1701398867747; Thu, 30 Nov 2023 18:47:47 -0800 (PST) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id p1-20020aa78601000000b006cb955dc54csm1895693pfn.58.2023.11.30.18.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 18:47:47 -0800 (PST) From: Patrick O'Neill To: binutils@sourceware.org Cc: kito.cheng@sifive.com, nelson@rivosinc.com, Patrick O'Neill Subject: [PATCH] RISC-V: Make riscv_is_mapping_symbol stricter Date: Thu, 30 Nov 2023 18:47:39 -0800 Message-ID: <20231201024739.1401739-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784046027449479894 X-GMAIL-MSGID: 1784046027449479894 riscv_is_mapping_symbol currently accepts any symbol that starts with $x or $d. This patch makes the check more strict, requiring exactly $x, $d, or $xrv. It also makes use of this stricter mapping in riscv_is_valid_mapping_symbol. ChangeLog: * bfd/cpu-riscv.c (riscv_elf_is_mapping_symbols): Match only strings that are exactly $x, $d, or $xrv. * opcodes/riscv-dis.c (riscv_is_valid_mapping_symbol): Use riscv_elf_is_mapping_symbols. Signed-off-by: Patrick O'Neill --- Tested using rv64gcv make report-linux and make report-binutils-linux. --- bfd/cpu-riscv.c | 5 +++-- opcodes/riscv-dis.c | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) -- 2.34.1 diff --git a/bfd/cpu-riscv.c b/bfd/cpu-riscv.c index a478797da69..79a82a599e2 100644 --- a/bfd/cpu-riscv.c +++ b/bfd/cpu-riscv.c @@ -147,6 +147,7 @@ riscv_get_priv_spec_class_from_numbers (unsigned int major, bool riscv_elf_is_mapping_symbols (const char *name) { - return (!strncmp (name, "$d", 2) - || !strncmp (name, "$x", 2)); + return (!strcmp (name, "$x") + || !strcmp (name, "$d") + || !strncmp (name, "$xrv", 4)); } diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index f7f4c0750ed..829070d809d 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -930,9 +930,7 @@ riscv_is_valid_mapping_symbol (int n, return false; name = bfd_asymbol_name(info->symtab[n]); - return (strcmp (name, "$x") == 0 - || strcmp (name, "$d") == 0 - || strncmp (name, "$xrv", 4) == 0); + return riscv_elf_is_mapping_symbols (name); } /* Check the sorted symbol table (sorted by the symbol value), find the