From patchwork Fri Mar 10 09:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 67308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp773432wrd; Fri, 10 Mar 2023 01:36:47 -0800 (PST) X-Google-Smtp-Source: AK7set9DIhV/74TThipQO2iq9rRFVF7o9xYg87rQDKodBhLFtpSs/V3dhxWmi/NtnRZRrJrZu5ty X-Received: by 2002:a05:6402:1645:b0:4aa:a4f0:2c17 with SMTP id s5-20020a056402164500b004aaa4f02c17mr23339202edx.4.1678441007176; Fri, 10 Mar 2023 01:36:47 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sa30-20020a1709076d1e00b008c7405fca46si176395ejc.476.2023.03.10.01.36.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 01:36:47 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="v/2ut9qS"; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DF753858296 for ; Fri, 10 Mar 2023 09:36:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DF753858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678441004; bh=x7qD1TsN+up11/6Gxp1s9N0LhIdQ7v9dxeNN9lyjZ4s=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=v/2ut9qSnS7KxZdP9HtegpZoe8fa9AaUSwQsSio1kZtAsyxKdjJ1OOWKdxIrrrCvA 3ZUq49uK/rDJEU9oGHk07dACFUVy0WM8d1WcO8dRtNGhqmbl3wvDDYTKxrLziXaIXa LPd5xST+3O1M5a9wYXQT1jSzLXgOvFDaVZtIILnc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2076.outbound.protection.outlook.com [40.107.20.76]) by sourceware.org (Postfix) with ESMTPS id 254CA3858C5E for ; Fri, 10 Mar 2023 09:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 254CA3858C5E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CXYlWcnWCfX7BFmzg0grMH4V636uvbyhqBRo6BKrnPUoSXJSNrZyHZ0nOXUAdwerdMBwpxbdPy70qsYMJ0l51cr6ku8QpogN0lm1i8UgJRIPzcmgcBzrLZoqM3d3LipHNRibyDNBoMZPnMm2OVG7hFFJy19xl302EM4gQ+ZcpA9Mi+JG/v2JlFunJ9ErT7lncmTjbKixDuLHm54X5jGKHguY3y/Bzvm3yC3pmHNHbHjDofMGVq1nXZiLeeYJur/WGnx/naCB6k86dXcARRt1DYjgGj+JY1ekBBG9h1BP9kj68eOig5EIk2cVBYuyvmmfdea03AfNnHdk09v+MovuKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x7qD1TsN+up11/6Gxp1s9N0LhIdQ7v9dxeNN9lyjZ4s=; b=JLFILmFQS8s/yEPTRyDg1G+0JezwupXxAJ/5MHoOfEAigQisRqbZl3ntNAj6Uwwxfv1kWw1bb4m7Ffkai8Zm9jhhvvhK0oetzQBS9MRZqeDE9eJib8ft/Ei6yrpSwH1EF1E4smCQIvmiIFqJKTbvKqeeB7GNdPIx3xAhlQJ8sERotVvHYlaIP2jTOUvzdfBfVwwhgqXH6538aRojJFM1YarqYvq3dc+/XQmC7jF7MEFWLmGQrXrFwZbkRhRHhgwTFt/to1kCC+0c4GvmaucWM/uuvOO/zU92njxJI1vnbb2CfuW2z7FqMXkBpNpxrXth4hbqA+vnG2oxSqVfr5H/wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by PA4PR04MB9464.eurprd04.prod.outlook.com (2603:10a6:102:2ac::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 09:36:33 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%5]) with mapi id 15.20.6178.019; Fri, 10 Mar 2023 09:36:33 +0000 Message-ID: <150b4184-62af-3f5c-c07b-24b0c2ae788f@suse.com> Date: Fri, 10 Mar 2023 10:36:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: Binutils Cc: Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu Subject: [PATCH RFC] RISC-V: alter the special character used in FAKE_LABEL_NAME X-ClientProxiedBy: FR3P281CA0156.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::17) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB9464:EE_ X-MS-Office365-Filtering-Correlation-Id: 9226922f-cd60-4406-2b23-08db214aef76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S6Op21+yWT1aboh4Io8gigDpFygyI/xCBMXrwaFsmxV0k299ZPWopb1YujO5LQghUEL5ME+8anM7JfGhyXRhAgtKDs7AQ/HkAK/QKvlIXMyb1y7Y29U500yuWesLqeho9Pcr6lVJY0VTKaPCmty4HWvS8jNKuHCoZFi+5tMupbjlj40MwiA5vSeOe+zKI3IjBhLSv5AgtS/E3gPn+FduTBB/L/zyCEWgfJDHtV2MciPUbZGRiMzsTI/jPM+Uj4a0XllAErJgQy2v8C5Qzzq4x0xgR0r/BA+NUGXv3TEkC57/Ctta9uq6veetWjdsU02CW2lWgnS8gZ8N2f40K43pPTM4jjZUQlrxHbGwxPhqoSnyEPdxPnKEcMfgj8jWyJGcT+7gyndEc9RQMVl8Lwjj2vKyAGQdDz4ZAPHbbpZgusiqo6K+1O3sCLZdZFGXKSAeC/tIoAQx1ZER70cnCeCCD2+691jsgCzdiaTXfGd3No55exkvUCAnu2nFge/QCIq8mczZRTMd19FvIPDtl6fcoRQneVGUoxzoeYO6U5TophrrzakjMtDVh9Q4aJW6C+HCLpTVxBHGE9CYljma9g9m8zPd0gKM97vWIr8fQww1mNz/d2LKzksHuAz9NggIjkwiBD91buoQpfFyfLgDPuQe++bbZ/rbASeM2u5Jlhl0I2HxMU9DeV7L/ZD96A6i98czGkFmgbGubz8NOI6fFHaPFdSlH1Edl+AKDgirsoCmnM0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(376002)(136003)(396003)(366004)(346002)(39860400002)(451199018)(31686004)(54906003)(36756003)(31696002)(38100700002)(86362001)(6512007)(26005)(83380400001)(186003)(2616005)(6506007)(316002)(5660300002)(478600001)(6486002)(41300700001)(6916009)(66556008)(4326008)(8936002)(2906002)(66946007)(66476007)(8676002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mfe8F0fr8Dx9X4w3LXXxdCn32CFm?= =?utf-8?q?3hvAsZNJxyfMOGlJTY01b10powfdtIY3Z4LA14netncaIqnRiCecbsHZa7ZOx22YH?= =?utf-8?q?dD9QA2iNWgBXLbSIT/cZ/n03GFAXWsUiLkWfp25Gzd1kSanr61Bjm6f8miuB0TdIj?= =?utf-8?q?B5aQ3Pdd2+3IUniqEbd/2/qb5q3Ifafd037pT9qlIncZDwPOajtMwY0JjckbZ7eN6?= =?utf-8?q?lNIBq0wyjhJuGmKqQBCuTEn3HhkO/EhzsNp9Ipjy+nPis5ELmpxXbC8yjzNMhlkg4?= =?utf-8?q?N00ZvuGXJ+xFSssI4Ynxxfqc5oPj11ePkcxenDe8KY8X4ZZksoNkNaJRKR8Or3k46?= =?utf-8?q?ETDVHXVgpYP+sxa7UYgpRsyJr4Hmqq0TSP12OwHGMSGoDkA9djhTqTBk8NizQA8st?= =?utf-8?q?PZrAD6+JAJtwHEXRoVrZJ47ZR3aWYuTp3J3HzQN1Dcn73sayOCUWjzB0mEQDPhebb?= =?utf-8?q?uqRu7IiPTp/PvrhDZDl4bXfecxkzutU75itZva6YNBFrN0DW7hErhfCP79+gpAbsP?= =?utf-8?q?SG3zugzTJHyD87mrTVOecUqhwJM6UM6OpW0z73jiiRrRaFYVDT3rtlEEZDALTtSoU?= =?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htFpg0O3pXeUVAxXq1ZH81BCEdcLwXjpXCnPtrGl+fb1cTAbO7a9aBqL9SdLF?= =?utf-8?q?R+kEIxwy8t14?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9226922f-cd60-4406-2b23-08db214aef76 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 09:36:33.3258 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wgxPRU1EHka35OaqSB8BAEQY+ZAPIkh5w0ACPzUFLXNuqnLaNL9r8GN1cSvWl7O+heoFUm2k6IzffZ+QSk2cKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9464 X-Spam-Status: No, score=-3027.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759972957629997924?= X-GMAIL-MSGID: =?utf-8?q?1759972957629997924?= The use of a space char there collides with anything using temp_ilp(), i.e. at present at least with the special % operator available in alternate macro mode. Further uses of the function may appear at any time. This likely is a result of write.h's comment not properly spelling out all the constraints placed on the selection of the special character used. Then again RISC-V anyway violates a constraint which has been properly spelled out there: Such labels _do_ appear in assembler output. --- RFC: Of course this breaks interoperability between older gas / new objdump and vice versa. But I don't see a way to resolve the issue at hand without introducing such a discontinuity. To limit "damage" a little, riscv_symbol_is_valid() could of course be tought to also ignore old style fake label names. (Personally I view this tying of functionality between assembler and disassembler as problematic anyway.) Thoughts? I question the use of FAKE_LABEL_NAME in make_internal_label(). The comment in tc-riscv.h isn't correct anyway because of (at least) this use - the symbols generated there are never used for Dwarf. And them all being the same makes it rather hard to associate relocations resolved to symbol names (e.g. "objdump -dr" output) with the actual instance that's referenced. Their naming should imo rather follow the model of {fb,dollar}_label_name(). Considering the special casing of FAKE_LABEL_CHAR in read_symbol_name() and get_symbol_name() I wonder in how far LOCAL_LABEL_CHAR and/or DOLLAR_LABEL_CHAR don't also need recognizing there (and then also be marked in lex[] just like done here). I can't point out a specific case though where there could be a problem. The checking for *_LABEL_CHAR in S_IS_LOCAL() looks to collide with uses of these characters in quoted symbol names. --- a/gas/app.c +++ b/gas/app.c @@ -200,6 +200,11 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_U lex['-'] = LEX_IS_SYMBOL_COMPONENT; #endif + /* If not otherwise used (which it shouldn't be - see write.h), mark the + fake label character as a possible part of symbol names. */ + if (!lex[(unsigned char) FAKE_LABEL_CHAR]) + lex[(unsigned char) FAKE_LABEL_CHAR] = LEX_IS_SYMBOL_COMPONENT; + #ifdef H_TICK_HEX if (enable_h_tick_hex) { --- a/gas/config/tc-riscv.h +++ b/gas/config/tc-riscv.h @@ -38,8 +38,7 @@ struct expressionS; #define LOCAL_LABELS_FB 1 /* Symbols named FAKE_LABEL_NAME are emitted when generating DWARF, so make - sure FAKE_LABEL_NAME is printable. It still must be distinct from any - real label name. So, append a space, which other labels can't contain. */ + sure FAKE_LABEL_NAME is printable. See write.h for constraints. */ #define FAKE_LABEL_NAME RISCV_FAKE_LABEL_NAME /* Changing the special character in FAKE_LABEL_NAME requires changing FAKE_LABEL_CHAR too. */ --- a/gas/testsuite/gas/all/altmacro.d +++ b/gas/testsuite/gas/all/altmacro.d @@ -8,4 +8,4 @@ Contents of section .data: 0000 01020912 61626331 32332121 3c3e2721 .* - 0010 3c3e27.* + 0010 3c3e27a2 11.* --- a/gas/testsuite/gas/all/altmacro.s +++ b/gas/testsuite/gas/all/altmacro.s @@ -33,3 +33,9 @@ m4 "!!<>'" .altmacro m3 "!!<>'" + + .macro m2b v1, v2 + m1 %v2-v1 17 + .endm + + m2b 81 243 --- a/gas/write.h +++ b/gas/write.h @@ -30,7 +30,8 @@ /* This is a special character that is used to indicate a fake label. It must be present in FAKE_LABEL_NAME, although it does not have to be the first character. It must not be a character that would be - found in a valid symbol name. + found in a valid symbol name, nor one that starts an operator, nor + one that's a separator of some kind. Also be aware that the function _bfd_elf_is_local_label_name in bfd/elf.c has an implicit assumption that FAKE_LABEL_CHAR is '\001'. --- a/include/opcode/riscv.h +++ b/include/opcode/riscv.h @@ -323,9 +323,10 @@ static inline unsigned int riscv_insn_le /* These fake label defines are use by both the assembler, and libopcodes. The assembler uses this when it needs to generate a fake - label, and libopcodes uses it to hide the fake labels in its output. */ -#define RISCV_FAKE_LABEL_NAME ".L0 " -#define RISCV_FAKE_LABEL_CHAR ' ' + label, and libopcodes uses it to hide the fake labels in its output. + See gas/write.h for constraints. */ +#define RISCV_FAKE_LABEL_NAME ".L0?" +#define RISCV_FAKE_LABEL_CHAR '?' /* Replace bits MASK << SHIFT of STRUCT with the equivalent bits in VALUE << SHIFT. VALUE is evaluated exactly once. */