From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) by sourceware.org (Postfix) with ESMTPS id B079B3858414 for ; Fri, 25 Feb 2022 09:23:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B079B3858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-vk1-xa34.google.com with SMTP id x62so1245370vkg.6 for ; Fri, 25 Feb 2022 01:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uJaQo/101cj1g2uLCLRTNUvqWBe7hW5EWksGjEii3Uw=; b=bop+OOHb7gl8QnDx8DNLzX4M82aW1dVR665CU7R7QbxrSfQPWZoXvIOhns3pJmkCvL LXjdcNK99dPyCZ9N+EskUmtBOAsGamP2DLngLQI6hcMtF5eN6RNs+ttUlC3MnqtrNhD3 qpmutQrfDQFhA5+cQFx8u6EiuAicHYSo7tT9OdpTi9sgC1k3Bv7s7lnb1Bt0CXl3nYxJ rtwB6YYpPftKV3RNIxzW16VxyEdMp5R1D2VFmBlL8OIuJgaOleueWTNglCpMsSHTXCt3 plsBQvBN5q7P0gqK+FwOjJo4dDkMHT1Vd5RydfDQC9LOyM51eDc/xz2mR5cmhmfbxkEu RuTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uJaQo/101cj1g2uLCLRTNUvqWBe7hW5EWksGjEii3Uw=; b=fxdW0FNtJglSoA9drsx/kFdOH5RTxK1l25Wy5ZVyE9OEpWG6RTPxZpZcLVaa8clyZB IxQXBtrgmbJOL8DG76PExbi1umUjUREya+brVSRl/LKy3TfF9Mc6EbCV6pBPoAjPOHiH S7CwP068AC/m6LmqJiVjm/t51fS5GY+OZa+5S1riQ97lTx0anp9L03VwbvBZoD5JvBMA +jrEqNw7sS+AdAc3QoWl6Lvu/ypgwbVOV9w5iuTQ7IWfGG2EutVGcKI0EDeVtOjQjLio 5IFz11la5uPRAc1GQIqNB4anILgyBkMCSnMHd1K1DLLOtcsWUzC/1KUoAlFLvpRCQMaa ZfnA== X-Gm-Message-State: AOAM5305EzVTeis/fGUI5S6XYzb+xibt/Zw7Q3aFXB0Yc8pMD9LNGvUD Dr1iAUChtKc/rpvFtz/2NzeeESN63qaBuoPecPzghXBELkq6rA== X-Google-Smtp-Source: ABdhPJwFYD8FoqZ9uynzVTmPZWeT/y/5kg44TTNT+9Sd+xrrXB6/GztUV53kelOLQdGMfYzcfWWy4Cv6EHc3Kxdl/s8= X-Received: by 2002:a1f:30ce:0:b0:32b:8671:deaf with SMTP id w197-20020a1f30ce000000b0032b8671deafmr3183211vkw.36.1645780987220; Fri, 25 Feb 2022 01:23:07 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nelson Chu Date: Fri, 25 Feb 2022 17:22:56 +0800 Message-ID: Subject: Re: [PATCH 2/3] RISC-V: Stricter underscore handling for ISA To: Tsukasa OI Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2022 09:23:09 -0000 On Wed, Feb 23, 2022 at 9:49 AM Tsukasa OI via Binutils wrote: > > Double underscores and trailing underscore in an ISA string are invalid. The ISA spec does say that "Extensions with the Z prefix must be separated from other multi-letter extensions by an underscore". But I am not sure if we need the stricter underscore checking for now. The discussion [1] said that we can set the ISA string in any order, so I think the checks will be more and more user friendly. I know that these are two different questions, and I don't have a strong opinion. Maybe see if anyone else has any suggestions. Thanks Nelson [1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14 > bfd/ChangeLog: > > * elfxx-riscv.c (riscv_parse_std_ext): Make handling for > underscores in ISA string more strict. > (riscv_parse_prefixed_ext): Likewise. > --- > bfd/elfxx-riscv.c | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c > index 329dcaed304..ee4b442ba89 100644 > --- a/bfd/elfxx-riscv.c > +++ b/bfd/elfxx-riscv.c > @@ -1650,6 +1650,8 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > const char *arch, > const char *p) > { > + unsigned char underscores = 0; > + > /* First letter must start with i, e or g. */ > if (*p != 'e' && *p != 'i' && *p != 'g') > { > @@ -1669,8 +1671,15 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > if (*p == '_') > { > p++; > + if (++underscores == 2) > + { > + rps->error_handler > + (_("%s: double underscores"), arch); > + return NULL; > + } > continue; > } > + underscores = 0; > > bool implicit = false; > int major = RISCV_UNKNOWN_VERSION; > @@ -1709,7 +1718,7 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > riscv_parse_add_subset (rps, subset, major, minor, implicit); > } > > - return p; > + return p - underscores; > } > > /* Parsing function for prefixed extensions. > @@ -1731,14 +1740,22 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps, > int minor_version; > const char *last_name; > enum riscv_prefix_ext_class class; > + unsigned char underscores = 0; > > while (*p) > { > if (*p == '_') > { > p++; > + if (++underscores == 2) > + { > + rps->error_handler > + (_("%s: double underscores"), arch); > + return NULL; > + } > continue; > } > + underscores = 0; > > class = riscv_get_prefix_class (p); > if (class == RV_ISA_CLASS_UNKNOWN) > @@ -1843,6 +1860,12 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps, > } > } > > + if (underscores) > + { > + rps->error_handler > + (_("%s: trailing underscore"), arch); > + return NULL; > + } > return p; > } > > -- > 2.32.0 >