From patchwork Fri May 5 12:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 90430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp376687vqo; Fri, 5 May 2023 05:51:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HfVV7YCgPrWnx9xA2hhOI8uS/7UlwnfIp3EhTypwoumlf4aOV4o1wzQmpKUi+wN5Q3Ap9 X-Received: by 2002:a17:907:7da3:b0:94a:5306:3952 with SMTP id oz35-20020a1709077da300b0094a53063952mr1359874ejc.57.1683291081391; Fri, 05 May 2023 05:51:21 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n20-20020a170906089400b009658615d30csi1212880eje.919.2023.05.05.05.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 05:51:21 -0700 (PDT) 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=GzKyF1f0; 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 0E790385701D for ; Fri, 5 May 2023 12:51:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E790385701D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683291080; bh=YSpVna0TVsBY1KBiMb9YhjMa2XGUeBkW9x0s7sNUGEY=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GzKyF1f0DYw1DxmEqueJJnJgt5zZjLTUUo/3MKySFoCYdFS4dn3WYi6zPKbe5KNbo gIojfdPRp8CQtxDWz01CK2djeH6JPEpfVcGBawjmPdf0O9S9U4MHDO7EjxLlkAO8NL mQNO4on4ArEyeINUJVM7sjXVklBX93NsTY+KRF8Y= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2053.outbound.protection.outlook.com [40.107.15.53]) by sourceware.org (Postfix) with ESMTPS id 5C8683858D20 for ; Fri, 5 May 2023 12:51:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C8683858D20 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VatCCIjwc8n5txmrkEe8sxKCvDgXuvsWNz2ItTlrJFe1N3wZmX5D5eBfCYOU5VvfGHLsaSjne+yhn75Ag1Mk1SEMfjgyKsphskEHsE0PCh9lCist/SZvh+4vXW8KjEiw8vGZrpb6XO4s40fQ09eW174OfjgCEd0UetQ9nLl0Fzo1KjxE3cWH6amhh/tOZH8P6tuKUfPZapKYkmlKSyklADbS07KzJVTs7EaoWdOPETMi0556yHH8w9yJ4MjV0RU1IRcLLo20c4QJ1brDC9fprIgzJ9+CX0EnooIXQol+0LKcwjVCICZizZIa8IgXF/lMlKcQ7GNH0ad8+rzSqElBNA== 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=YSpVna0TVsBY1KBiMb9YhjMa2XGUeBkW9x0s7sNUGEY=; b=nWRxupZCv56ljeRW42ctmiwWX9a+WYO0BLQ16V+r9gUcccj4HbR07DMm3CAHFKAm/BWgN0i/jhDwMpamdg+iYB1QyC9m1+dx0/W4KVltLmlzo3ICQcutKk8M8AvKquoKhJ+jKh+5vpiJZKtcMZVO6cp/GhOcP+nzaFGbUipWhDeiIuCWfxD52VLI8zP3cDrDx8LljwdCQ081SUIwvtPNuZO6BgJMLwmqJRYpYkzehuzviVuszKiQbD0gszAxv/3eyEU7z8ePP5m4qFGV7qkNQG1puQwGmvPGryaHSNpQTOefVqCfxI5od++jlfy8q4EPneBKGJ8sc5tixGxKMUtMOQ== 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 AM6PR04MB6551.eurprd04.prod.outlook.com (2603:10a6:20b:fa::20) by DU0PR04MB9395.eurprd04.prod.outlook.com (2603:10a6:10:35a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.27; Fri, 5 May 2023 12:51:07 +0000 Received: from AM6PR04MB6551.eurprd04.prod.outlook.com ([fe80::768c:6df7:9afb:acd7]) by AM6PR04MB6551.eurprd04.prod.outlook.com ([fe80::768c:6df7:9afb:acd7%7]) with mapi id 15.20.6363.027; Fri, 5 May 2023 12:51:06 +0000 Message-ID: <4735d366-fe31-0092-2edc-d166184b8567@suse.com> Date: Fri, 5 May 2023 14:51:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: [PATCH 1/2] x86: don't recognize quoted symbol names as registers or operators Content-Language: en-US To: Binutils Cc: "H.J. Lu" References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0070.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9a::9) To AM6PR04MB6551.eurprd04.prod.outlook.com (2603:10a6:20b:fa::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6551:EE_|DU0PR04MB9395:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a4b81ac-10d7-4f1a-fb01-08db4d676498 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1bxRhM9pLHJblnQXf82fUIur7M7UfMDQUSjd+hqMwsgXAnX96vivrJXtGqXR2mhSkhXQnBBUiDtbbvTStugo7nAVzGTEgWjAYsSpDveAwB6fdYMCQr1WY5rkNoSMSgOl6K4SWne+LEl7OxC5V3Ktx+Txv/RYZ5N02gv4lH3quA0WrFgpVrVAkzOx/hkGOmJjX0VW6buDi3cY0wu2qjtDHIhQJa9lmDTUsQgEQ6uPr/skSW8eqfaXKsNWda3UNy2HespcWUfTVTXAPR6p22OI1i3kWWiMSKWKq/QlkSMsc2ekous40q6FCMPVs4NHhLTFzqHXYUR9ES2iuhTdpNnTXdOWbBeMlKslkGgus1ig2+uR10XxD7C7Fb39GtfDiK0HavmoOotcDA5lNFGQuNKOVVilF6yjCIC4t7YC95cWZBRxszBMFBCINWWTRJr2WDnlY/UvLVQyPzRPreW1cko7FATFVhIs/tbgvoIRYaYZds5bgcOdrBQ6S/RSg0lmpzqw7MUt/8gef4PI+hFyyoJGpi+UH+Um1yWGa09g5HOcj4fWJFWx/RrFoIO2zJl8WopoFE0iR1sVC+BFENIB2e7ZMhBkyWdguibZP4cIYt3A9WO2XumyeEZdYklOFzD6syoUrjow4exx+0kxwxMjPjfwwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6551.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(396003)(346002)(376002)(366004)(136003)(451199021)(83380400001)(2616005)(186003)(2906002)(38100700002)(36756003)(31696002)(86362001)(8936002)(8676002)(5660300002)(4326008)(6916009)(66556008)(66476007)(66946007)(41300700001)(6486002)(31686004)(316002)(478600001)(26005)(6506007)(6512007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HmpMs+0EgqLIYWfxXF7ysTr06ZET?= =?utf-8?q?55P/ViAC/IIEUBOCm6fIT6UMuJ9A6R5uFsWKzegoYHUR34tDBtwexHD2G6oltvbVp?= =?utf-8?q?qL9BN1zZdkSVs7YlQAncME1NvrDiaPJMgj+n35TCheY/kTOzCQV6z8Dq5RN5OyXI0?= =?utf-8?q?qWRs8KzbAt0VOLGyw+T327TcRXDrEilYAb0Nkni223LB0XKhKwcrDC5UDH5MpMA2r?= =?utf-8?q?8wKAk8blwfEPvJa1rrCx/J0wA4zaAU0Ij3lBr+CiIecXlmQOjTHD8gifu1ouO3cOY?= =?utf-8?q?siHNol4UNqytZIoc8ljK+EhRQLsc0TzSgabSxH/zr2sNmmaxjnB6UfhhUZxNNLV3o?= =?utf-8?q?f314XTK+0zN29Z0ppEbEkdcHwW+N434+NaILa6LBCI2j7A3T41gFjSx6S5lj58VqZ?= =?utf-8?q?Ds58FSM69IugrKLerZEQaNgxOFCX6BR4GoU+8kyD5X6+TpK4rirPmtk6MLksp+dpv?= =?utf-8?q?x0oPjcJY7p9pRsu/rl0ddJCwZgCbfKyJPHA33owZuD0Q/dL+yuU128sve2Ab1esJk?= =?utf-8?q?zMjXq0EheMP8VwavwljEILwHvP2a2lD07HXo4i8hiv41brDdYguETWCpztJ+w9fzf?= =?utf-8?q?ux3JveIKWFzy7Ja6fgAcW1pKdhXVvdOYobDpKoNgWoalk9jErAfdGaYBEtcbIOj+S?= =?utf-8?q?jvZOMyhHuOYRtcsgbl/XyVEPTESXZCqkWd9uXx+cS+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-Exchange-CrossTenant-Network-Message-Id: 0a4b81ac-10d7-4f1a-fb01-08db4d676498 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6551.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2023 12:51:06.9045 (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: gw4imCJbE1DJ9Eospu+EXSks2nAH7+5uWqmEvEQpZC8u/tEYTHFajkJVXWVFm8Mb6CbqXy8durzLJHtBxROw2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9395 X-Spam-Status: No, score=-3028.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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.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?1765058561437960009?= X-GMAIL-MSGID: =?utf-8?q?1765058629302208740?= The concept of quoted symbols names was introduced pretty late. Utilize it to allow access to symbols with names matching that of a register (or, in Intel syntax, also an identifier-like operator). This is primarily to aid gcc when generating Intel syntax output; see their bug target/53929. --- If desired, the i386_parse_name() could of course be restricted to Intel syntax only. But --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -13868,6 +13868,13 @@ i386_parse_name (char *name, expressionS const reg_entry *r = NULL; char *end = input_line_pointer; + /* We only know the terminating character here. It being double quote could + be the closing one of a quoted symbol name, or an opening one from a + following string (or another quoted symbol name). Since the latter can't + be valid syntax for anything, bailing in either case is good enough. */ + if (*nextcharP == '"') + return 0; + *end = *nextcharP; if (*name == REGISTER_PREFIX || allow_naked_reg) r = parse_real_register (name, &input_line_pointer); --- a/gas/config/tc-i386-intel.c +++ b/gas/config/tc-i386-intel.c @@ -169,6 +169,10 @@ operatorT i386_operator (const char *nam return O_illegal; } + /* See the quotation related comment in i386_parse_name(). */ + if (*pc == '"') + return O_absent; + for (j = 0; i386_operators[j].name; ++j) if (strcasecmp (i386_operators[j].name, name) == 0) { --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -105,6 +105,7 @@ if [gas_32_check] then { run_list_test "equ-bad" run_dump_test "divide" run_dump_test "quoted" + run_dump_test "quoted2" run_dump_test "unary" run_dump_test "padlock" run_dump_test "crx" --- a/gas/testsuite/gas/i386/quoted.d +++ b/gas/testsuite/gas/i386/quoted.d @@ -18,4 +18,11 @@ Disassembly of section .text: [ ]*[a-f0-9]+:[ ]*ff 15 00 00 00 00[ ]+call \*0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\) [ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\) [ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)?32 x\(y\) +[ ]*[a-f0-9]+:[ ]*b8 00 00 00 00[ ]+mov \$0x0,%eax [a-f0-9]+: (R_386_|dir)?32 %eax +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 %eax +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 ecx +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 xmm0 +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 not +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)?32 and +[ ]*[a-f0-9]+:[ ]*b8 00 00 00 00[ ]+mov \$0x0,%eax [a-f0-9]+: (R_386_|dir)?32 edx #pass --- a/gas/testsuite/gas/i386/quoted.s +++ b/gas/testsuite/gas/i386/quoted.s @@ -14,3 +14,13 @@ quoted: call *"x(y)" call *%es:"x(y)" call %es:*"x(y)" + + mov $"%eax", %eax + mov "%eax", %eax + + .intel_syntax noprefix + mov eax, "ecx" + mov eax, "xmm0" + mov eax, "not" + mov eax, "and" + mov eax, offset "edx" --- /dev/null +++ b/gas/testsuite/gas/i386/quoted2.d @@ -0,0 +1,15 @@ +#objdump: -r +#name: i386 quoted symbols (data) +# Mach-O relocations appear in inverse order +#notarget: *-*-darwin + +.*: +file format .* + +RELOCATION RECORDS FOR \[\.data\]: +OFFSET +TYPE +VALUE +0+00 (R_386_|dir)?32 +%ebx +0+04 (R_386_|dir)?32 +%rdx +0+08 (R_386_|dir)?32 +eax +0+0c (R_386_|dir)?32 +cr0 +0+10 (R_386_|dir)?32 +k0 +#pass --- /dev/null +++ b/gas/testsuite/gas/i386/quoted2.s @@ -0,0 +1,9 @@ + .data +quoted: + .long "%ebx" + .long "%rdx" + + .intel_syntax noprefix + .long "eax" + .long "cr0" + .long "k0"