From patchwork Fri Apr 21 12:17:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 86274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1022531vqo; Fri, 21 Apr 2023 05:18:10 -0700 (PDT) X-Google-Smtp-Source: AKy350Zn6XZTvGRs5aOIJkPa9Zfm7ELMxE3d/W8Je8qMZTo2YquEIkxTClbhayuLd0M6TZ/0zbyR X-Received: by 2002:a17:906:f2d0:b0:94e:c6ad:1119 with SMTP id gz16-20020a170906f2d000b0094ec6ad1119mr2015603ejb.13.1682079490581; Fri, 21 Apr 2023 05:18:10 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hb12-20020a170906b88c00b0094f95d214d4si3709309ejb.234.2023.04.21.05.18.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 05:18:10 -0700 (PDT) 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=@sourceware.org header.s=default header.b="ABZuzfh/"; arc=fail (signature failed); 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"; 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 5F3043858C36 for ; Fri, 21 Apr 2023 12:18:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F3043858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682079489; bh=h0LghhGeBh2wO0TfAhmSDIkrivi9HKM/x758fg+tv5o=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ABZuzfh/b27M8FXFLZXILb5F+injn+lfMZ44nN0wavjYtxDkP0jzrVDc+H8eGU1Cv dYvvTSg7srnt77ABpLQ5tb4CuzFdZ8o8YGa0qPxtOe4yIV5NUJiT3ViSJrK0QLdw/s U2XBIqWUy5fBHPn6MO3mfl6wXqaeBlCnKsOT/yp8= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2048.outbound.protection.outlook.com [40.107.14.48]) by sourceware.org (Postfix) with ESMTPS id BB5B23858C83 for ; Fri, 21 Apr 2023 12:17:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB5B23858C83 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UmgPuw04kKOUpoZ0crf24qd11j90jQ5woGsb6lv2BlznggBJztu/p1jYW97RnA9JVcj1ocUn1IVEY3QlDnGVIWjCF5wJUvSs9Wl+o45lXdxye7PkejiBOzP0RU3QScvKhJCwC39/KTgcN87jjQsI/oYGSORP4y99P46oCqJ09g2R+ubulqjfhe6U3kEUTEblMmPUf7lHQXvkkh97yp5ADqr0HJoiscpYY4lGT1hbGME/TnE4OUAsldN0NGPKgsEBnJA19gX3tGQZ9pP2XgEHVpQopI9wnVDytvFPnBxoOcFQYfIrNE376lZUgb8AfVPp1oCzCh7HBhIXfWNMFNzIfw== 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=h0LghhGeBh2wO0TfAhmSDIkrivi9HKM/x758fg+tv5o=; b=i5vhKSi38y+8f6YDWiBaot/4gz4zCa4dewMeqfGegOVh/+QqnN8H72XyKpeXKdx3stsBH/9qpwSmmMkcd+7EsIOirYbTbrLqsQRm9GcpCIkgUEqMZa8RRqf2Cxp7KyAjSR2BnTEQBgzSRBmg9xU9QRF3RIWGFc3/MCRP5mtkynXLDnDYoGjrVi64Ar/RHYGzxMzxeqdzwALtxRq9w0r2eVOxZaoNu3gT10NrVJiYUYjQkHDsT6EmjuuAC2oOz73LcdNR0OcjXupsU6FlLk30HHG3LM1PTEDQK+8tBqLeV15sUQlEzCu1mF8YlcSJXPB1ZjR/5qwVe2L47V0scQ2YSQ== 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 DB9PR04MB9791.eurprd04.prod.outlook.com (2603:10a6:10:4ce::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.21; Fri, 21 Apr 2023 12:17:56 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::52b2:f58:e19:56ae]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::52b2:f58:e19:56ae%2]) with mapi id 15.20.6319.022; Fri, 21 Apr 2023 12:17:56 +0000 Message-ID: <4c40b0d1-8375-9284-cfaf-ce63b8df1b9b@suse.com> Date: Fri, 21 Apr 2023 14:17:54 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-US To: Binutils Cc: Alan Modra , Peter Bergner , Geoff Keating , "H.J. Lu" Subject: [PATCH] gas: equates of registers X-ClientProxiedBy: FR3P281CA0097.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::15) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DB9PR04MB9791:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b4be5ca-267a-49f7-b7b7-08db42627079 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nWPtf73EMSmJ5Dut6mvOg2x/WuGsSAW+OnhvD2amhavCdzMZA/en33S8ScAbCallaUc34BVjk/vzJ3cCHSS1Azb+eQWASryZRWZChCE8plOMxEoM8raZlRzMWZkFVZ2DLn54WGcCg4F/Zqcy2A2auaWf2geQt/cRZ9E2dfasqP36/QR45sYQQm/Q5DTqUbyKD3RIUJ4LSSNMxFfDtpW96H0RlI7IjNrRN2L7/kFQwbH+g7cOvuiYvDwxeXOGVHp36ppsPf+yRWZp1NpY2pl9i+hR20EgwNqKoFHXkNum/x7gDvrEyZNZAkBBEw1ugS5rumxgTNfaYNJ+2P+H8/DupZl2LfJjLRZiQ/AANdSfRuhu6IbvBe7HEWhsp43F6Xny9U5BOgnTx/I7sNTyV7gblAIleN5z1omOH5GbIdQA8y1nTSWqOW8qd1FjPPq4hxW6+5HVutB59ZGdnwtUe7Hq+9QHH4HM3bzRV6WePjsvKhh88SRYHrLeL5kSnIAS7wqUlHsNTfBYhyq/p+6kmvGZzEb4AE6nb40UBSTw1QBWkwqp5tilxhMJQqsXZhmj/ztn+6QY4O/JfRhE1KBB0gN7SAKLROhqCAeTV0r9CkbUR0it78xtISu7Qwtr+kv/yOdbS6b7YNb441Dk0Fnj6t6ULA== 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:(13230028)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199021)(8676002)(41300700001)(31696002)(83380400001)(66556008)(66946007)(66476007)(2616005)(86362001)(316002)(6916009)(4326008)(38100700002)(36756003)(2906002)(54906003)(6506007)(6512007)(478600001)(8936002)(26005)(186003)(5660300002)(31686004)(6486002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ou1DY12VcblvmyXf4ewGm77qNNu9?= =?utf-8?q?xIZLVkIa8NBOHff3jk+FIgeZYf8Ab7TA5kFVrJLeQLena7h9WPbVFU/PujoLP0tG8?= =?utf-8?q?Xf7AVzm6Nh3cBD/MwWdjsIQiqd3saVsVUDrUPMhImA4XJ07pz4KV56yEShAiW7WwP?= =?utf-8?q?7Xi4c9Mhzo1zFuUIMek1IGTlIEnrjleEz42vrOTrbNNOiI0qVD+d1BVK6iX7VWi6s?= =?utf-8?q?fimvxrUBtlTL/HLE/Z8mPj6JofJBqgZMPhEiashYxHJXYk41Y7BM5WNnYW6I/RR4z?= =?utf-8?q?ccwiNe4Q9+QtlJnho7t+N/XQCoUhdu2YlUBah1D8PlUBlDTVn0QgdakvKhydZ6Xs7?= =?utf-8?q?fYPPbXMgFS4OuaHY0D/ZnRDzf4qwnPRqpDEaJeb1Rwwg9kdmd/BVGmgBYjJPEYJQI?= =?utf-8?q?aK8P62JDl1kdhxbYcv9PC+VLeTobl2CEpzehsPCBtNGhHSp9JNvckGyH5VsxMfiXo?= =?utf-8?q?FtBu0QEYHudfoZ2+xZZ3Dw5wtz1qUh91z9R82Pk/ZjQHetLzkPYQDU0E8/RW1PrX1?= =?utf-8?q?6dZP7d+jV2xaoqVuv54Hph4R1dMGoaPYn6DubI1IPZPa1yV2HsogYQ1/UDEkFmda0?= =?utf-8?q?nPloCFOWTNUPBd9EChpLrA5rIiOZxzsar1y+OqKW8Y9VzqPfQ5lCZ7xZE1NC+YDQ8?= =?utf-8?q?9sQzlc/tXz5ewJlJe58+aL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Exchange-CrossTenant-Network-Message-Id: 7b4be5ca-267a-49f7-b7b7-08db42627079 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2023 12:17:56.6603 (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: 7HKs8mPmtPrhsMrya1PCiLgMlOVzkAByFIxPgU8PTe4SY+XWHi76WqmBuCZbnQAWalLQwoh6FQrKf/7v+2bvFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9791 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?1763788184155324409?= X-GMAIL-MSGID: =?utf-8?q?1763788184155324409?= There are two problems: symbol_equated_p() doesn't recognize equates of registers, and S_CAN_BE_REDEFINED() goes by section rather than by expression type. Both together undermine .eqv and .equiv clearly meaning to guard the involved symbols against re-definition (both ways). To compensate pseudo_set() now using O_symbol and S_CAN_BE_REDEFINED() now checking for O_register, - for targets creating register symbols through symbol_{new,create}() -> symbol_init() -> S_SET_VALUE() (alpha, arc, dlx, ia64, m68k, mips, mmix, tic4x, tic54x, plus anything using cgen or itbl-ops), have symbol_init() set their expressions to O_register, - x86'es parse_register() also can't go by section anymore when trying to "look through" equates; probably symbol_equated_p() should have been used there from the beginning, if only that had worked for equates of registers, - ppc's md_assemble() needs to "look through" equates (which also helps transitive forward equates). This was uncovered by code reported in PR gas/30274 (duplicating PR gas/30272), except that there .eqv was used when really .equ was meant. Therefore that bug report is addressed here only in so far as gas wouldn't crash anymore; the code there still won't assemble successfully, just that now the issues there are properly diagnosed. --- Clearly equates of constants have the same issue of not being viewed as equates by symbol_equated_p(). Changing that isn't the purpose of the change here, and I'm afraid is also yet more likely to trigger issues elsewhere. For ppc I wonder whether the "looking through" equates really should be limited to registers only: This might be as applicable to constants (including O_big), and finding e.g. O_illegal right away might be helpful too. If the setting to O_register was to occur in S_SET_VALUE() instead of in symbol_init() (which overall would seem more consistent), all callers would need to make sure that they call S_SET_SEGMENT() (if at all) ahead of S_SET_VALUE(), not afterwards. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -13832,11 +13832,11 @@ parse_register (const char *reg_string, input_line_pointer = buf; get_symbol_name (&name); symbolP = symbol_find (name); - while (symbolP && S_GET_SEGMENT (symbolP) != reg_section) + while (symbolP && symbol_equated_p (symbolP)) { const expressionS *e = symbol_get_value_expression(symbolP); - if (e->X_op != O_symbol || e->X_add_number) + if (e->X_add_number) break; symbolP = e->X_add_symbol; } --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -3475,6 +3475,28 @@ md_assemble (char *str) str = input_line_pointer; input_line_pointer = hold; + /* "Look through" register equates. */ + if (ex.X_op == O_symbol) + { + symbolS *sym = ex.X_add_symbol; + offsetT acc = ex.X_add_number; + const expressionS *e = symbol_get_value_expression (sym); + + while (symbol_equated_p (sym)) + { + if (e->X_op != O_symbol) + break; + sym = e->X_add_symbol; + acc += e->X_add_number; + e = symbol_get_value_expression (sym); + } + if (e->X_op == O_register) + { + ex = *e; + ex.X_add_number += acc; + } + } + if (ex.X_op == O_illegal) as_bad (_("illegal operand")); else if (ex.X_op == O_absent) --- a/gas/read.c +++ b/gas/read.c @@ -4000,6 +4000,10 @@ pseudo_set (symbolS *symbolP) return; } #endif + /* Make sure symbol_equated_p() recognizes the symbol as an equate. */ + exp.X_add_symbol = make_expr_symbol (&exp); + exp.X_add_number = 0; + exp.X_op = O_symbol; symbol_set_value_expression (symbolP, &exp); S_SET_SEGMENT (symbolP, reg_section); set_zero_frag (symbolP); --- a/gas/symbols.c +++ b/gas/symbols.c @@ -387,6 +387,8 @@ symbol_init (symbolS *symbolP, const cha } S_SET_VALUE (symbolP, valu); + if (sec == reg_section) + symbolP->x->value.X_op = O_register; symbol_clear_list_pointers (symbolP); @@ -2463,7 +2465,7 @@ S_CAN_BE_REDEFINED (const symbolS *s) return (((struct local_symbol *) s)->frag == &predefined_address_frag); /* Permit register names to be redefined. */ - return s->bsym->section == reg_section; + return s->x->value.X_op == O_register; } int