Message ID | 20230221040650.2337395-1-yunqiang.su@cipunited.com |
---|---|
State | Accepted |
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1661053wrn; Mon, 20 Feb 2023 20:07:26 -0800 (PST) X-Google-Smtp-Source: AK7set8a++PIA9NkjKHosYKe3lsj1ErmOm6DphqXjvgevBkAf2fi9+cKMLUCfCB/olSh+xeQgBCZ X-Received: by 2002:a05:6402:5022:b0:4aa:dedd:41e0 with SMTP id p34-20020a056402502200b004aadedd41e0mr4548830eda.8.1676952446383; Mon, 20 Feb 2023 20:07:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676952446; cv=pass; d=google.com; s=arc-20160816; b=XHpn/Ia+qm1l48cgQcvTQVit1J0F3USHvICwhtnAbhcT5As+S7Oue4CjlUsf9QZHzq OjfOu3Wukw0YyllWRXocgWv2p3ECIa4PoshG+gM8ojjvRlDGDYCqrfPh7j+aCV7ZSDfb HeLPeT+uVITkMG9NoVuD05hLYQVRapEp+hfNA/ElQx3Xysg2ogx2obH7JpllW/RDNwcM zxLP3FE2gQ4RH3Nh1f0xiREuifCzxaD32a3Q8l8SWsKe05R125sy77+ZsQWDk9eLyjaM 6vAGnKUmiPRMhlLKiOwn+YRf6/iJVo/PleayepmEw2vt2R9cZoPf2AxfYsd9aq1WrDau mOjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dmarc-filter:delivered-to; bh=Xa/JQbihBNrHDneutpULPSca2050Pp8RfiUssSyCFb0=; b=jPMvYnWsyjrPwUg8LRvUw4ITaWGsK/cEohQGYrfKVeEUKdeiZsaR4NDYUXMV9nrYw5 QVoXR75E2QLaSTWfWWUJpO8wN1A+SEgfUsB8+1a1q4uJF77YFrq93WaS8nlRkehxr2kl rWR+HHNUTJUxebpjUhC5ojVXI5knmYERqbqvpHY+JcF5x0xrgMGnTzSezyjcAuk9dsBD yrheSNfqFwkEHeBPmUccHsmnvXIDf/eZcmj/ouvG/BLcs39caR1j7JymQ1eJazmLb2l8 L8zDDFYdBwz0l6XGbtXVegU3D3sVkwy5logR5RkbZXVkWbUY/DSU18CzXQtlhv0VR5tk 54mg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=VjsZrVe1; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c4-20020a056402120400b004ace62d6ea9si16729084edw.529.2023.02.20.20.07.26 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 20:07:26 -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=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=VjsZrVe1; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35DD9385841C for <ouuuleilei@gmail.com>; Tue, 21 Feb 2023 04:07:25 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2100.outbound.protection.outlook.com [40.107.215.100]) by sourceware.org (Postfix) with ESMTPS id 9A9673858D1E for <binutils@sourceware.org>; Tue, 21 Feb 2023 04:07:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A9673858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TrRkrzHqK/A69KqGJithEgD7GKQbMFIsq3xIXfe8unoCfIoiVBWQhj9g82ESO9ru9md3KIS+R1xzJ9nFi20HknC8BmDX6eEsFattQvtKiVr9R4Ww8cFnYUwVTbLGi3Rh0B2B9wwin5hl++cBTY74MA2ZwYG1Huc60NiHRyBQBnVkd7WDl81cfHZ8nmm7p31zni/oaiFteZHUofwvTTJNpYLfzDcdRjMB9Vz/h5qtIW5EGINMJcRrRax6jDTWwD73KZVSWvNwmZGgGoBl4WIRQgvNW0dKxGKPWEjJQBX7QU5IBf8eA3gSNUo4Kx5bIzAPH9z1H6DY9spehHElIOyyfw== 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=Xa/JQbihBNrHDneutpULPSca2050Pp8RfiUssSyCFb0=; b=DQZ6pvrfDM59zrInn3NhJXBMGN3YYl4Z/3QE1oSgXaYClPncR9KLVM0TghCj8Kn0ISzep7bGDX1XRirpbOJqD6BUOSSW+WANVI1GOR242AZylO0rZZqeHjMcY5IhRPP7yLm5Hpf9aMtC/cs4WQyyDQdtX/GjNNCqaTBgUOG/h56+xw/eWuImElBzJ3bNB55e/zefBqaddrDAAf2O0pTze0iExEUEkQxA83cR19/Qu0WBnC9TVDnkZtHo31l2yjtBo6yxepLoWsJR3XufGElrF50Xw73T74ykFB/oeDABXwdCKgW231CP2c6LNBjfu5Yp97jyDGEaMhVRaME6Xaxj6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xa/JQbihBNrHDneutpULPSca2050Pp8RfiUssSyCFb0=; b=VjsZrVe1fHlvrROBx9hTDEe0/hn7uY/MkYu8WICEGLuLeMhIzVZMG6vygg2PDccXr42YZC7Ozv1hLRvSaB87x3VmNsMcEzSiO5zUPO53PgYD1i0zMaks+OWQDY/uF6JQC44M7kva57D2DuIaSkdJmGehaNY136xs3xad2ptxodI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) by SEZPR04MB6156.apcprd04.prod.outlook.com (2603:1096:101:98::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.21; Tue, 21 Feb 2023 04:07:09 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a%2]) with mapi id 15.20.6111.021; Tue, 21 Feb 2023 04:07:08 +0000 From: YunQiang Su <yunqiang.su@cipunited.com> To: binutils@sourceware.org Cc: syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, richard.sandiford@arm.com, jiaxun.yang@flygoat.com, YunQiang Su <yunqiang.su@cipunited.com> Subject: [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic Date: Tue, 21 Feb 2023 12:06:50 +0800 Message-Id: <20230221040650.2337395-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230207024424.4000862-1-yunqiang.su@cipunited.com> References: <20230207024424.4000862-1-yunqiang.su@cipunited.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCPR01CA0143.jpnprd01.prod.outlook.com (2603:1096:400:2b7::15) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|SEZPR04MB6156:EE_ X-MS-Office365-Filtering-Correlation-Id: 88b9853f-b5cb-490b-26de-08db13c119b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HS/Ph9C+sFeViUrtGYbSDm5UVV4nGbDMrmXfbLDSrq0kHW8YYfcrpx0DjTn1eKMQge7rxk55Irs2Ze374UIVYyerOnJ01XVl2deszD/yUExjtolp+J7eqgU/keZt8OX30VrKhwwhCmT/Oo8EqNZ8WnPh1DPPd+/o7PGQzPBq2p2M1CLUNoJbRqw3NgtJq58wONW9/L9UQPieCwowpfyb6QK5BgToB88jquM9VfOXXwULtWcQHEjU40dw7BUSik/49Iy/VvtxosocUh3VA2BLVqRfwrKuR/9Ofg+xW2SLN8MKjtRE1IypOk5ZQB/ZtHyTOwLqwneDwVcMVf2fi/CfV7PlATkN3qKf7r5KMDXmMw3dG42XWsGnl1KK6X7Pb8Vz8902PmkG1uYkV14QZfvjW6IV53bnAuBIM17SDQxzPvooYhwkpZqGG2+q85qKes622nZj+73yNnOt7lONH0Pq1xaGHp/uCr3fXiHSUPD9/jUTeGkI8IcsKDvKJEbK/SOaTK4BO6bgP5QeSzZ0/Q4qYESpZHQ30Nwy4T2zsqMXTk5PIfMOkQ7cP+7Wn+54Zbf+9GUyjFhZqLQ8CKZFWb0iGS3WCBEiAZvtuVr+4GC2+IAgpIjO2/cD9rV+gnm2Esh3WG9LUs5V5jkVFKfUPH0jX/uI2PAq9/JJKUbAPIt275kehyxvIygkT3EvG7OZyA35NYZhFu8I7i0Zt4SVf8NCtA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB6117.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(136003)(396003)(39830400003)(376002)(346002)(366004)(451199018)(38350700002)(38100700002)(83380400001)(36756003)(86362001)(2906002)(8936002)(41300700001)(5660300002)(186003)(26005)(6512007)(6506007)(107886003)(6666004)(1076003)(2616005)(316002)(4326008)(66946007)(66556008)(6916009)(52116002)(66476007)(6486002)(8676002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uPJKquWktTHg5wOhSpUwmqjlKctjM8tVusQISZ7r3phIn95qpu6yulTKifB3EJxDCegIsDcfTCTaPoUeQbgFPZynNp2HW2zT/7Bd1+63z2ON8B0FLNdRVVwhEsIYWALxZxQHoBRr4IF39yUdnEIIepDfkJ0JtxQ+rxmADTV0jLgDlogMtuiarUSerSbcKxGdpjuyE3ZmIX+F4zXulVWKAg5kF46ZEiob8f0xbPsT9TB8tzIbTrKyNZx3NzFCARYqjoMIh7VcHwlm+LtUfwbXVkhe2rHWu3WIz6rhrps8ewNLmzD0e1VbbDoMpz+ycAaBwwelj6KrFtLeBtIbhSRN45iAfgqYYltuWFL9LOx+Jl1lPTQcgcSYMuI0u+B0hAsuMW+wj5A0MmWl2HC9qfKHo5yLH/EdQCgLviY72lYqGS3oAA6zjuLRxniEsetcYfNEWeb1nJ+QgKJj5cUP2qawXDsdLcDL94oThHbze8UD7UUcWnS87cSrsXUeqXIL2p5c9EGlUSPSt0AOuONLwiAiYL8poX7j1Kx0xbNrke5+z9AfrD2xg/6i68hMbA5aLjX3jFSEqOSKg7QNlnwwBxj9lcLcGqsLK2L5rfT2MPULFfEX0nEdjaEPRuceEpg81ZblU7ihXjlpifTyLwhvqhYnGxOQijpLoOunBP3/Ew4tjPE2aB0wsP7MeoWtdNlJlcI6ohscdqhlzCR5JgtiUgpOqBtMR32Wo8U9279dr1Oa7aTMxxq8NZAHwJO+5efAg5qrEPtaXePEg9kGURdnjhz0+r3J8KrpqnoL3AV6Jkj1TuC//coQJmI/G0P7QqjaL8xUVlACpzCNu9Wl+d6cwAvkcidUg0y1oVoXbezVHSyp2yGpzC46pBUr6b+0By7TrUwfl7HrYZ0VRofOcw4U4dVWvdkKoS+RXfh9U3cGaCMafHu1pzYkINV/+dHmmDQUPnmiTfRL9r4DShGUga79NW8C7/kSKNlxzr4SzZy5n1556uRnzx4Kt4FRYIYcGflzfVH7N//3Up4VSLK4koMOL6vEsPzmf6edpqWRot3rcv3CgAP6iaio0/26HoUPjbpnrOSrmH1+ua3RuWWUO/KHIGUFrloRAEwPDI2uRH8uuo+WzlOJQjnHCjEOP1Ysx7FNs61SdZ6bryEJkJmQxTD1rUiByqwsaQ68GuWVdld6UeUkNDckUzdo941WSNrrvw/ZOGOBaMN8wGkfDiSdIzQhiWx7maco3pwj0N6GuhUawlhrpn6hkDUKzeYAVo8PPEgiDB8dysi2fpuoIQk/ufWalE5kCH5JqI77ex1cauw56yYs89ChdrNZuxhZbXfz7k1xU8njmpZLnke09X+7DAPiJGDuemaXWVRvcpgZqY/ImikDt7qhxX04hYk5D3TDsqcF8HqsbY/5+Ros6uyAs0vXT0Nv/W/cQO2bsXQSCrOyd6oAR58xuKKZlODf6nROvZlVf5j96br0UU77fe1nyI+zXTXuymVvI/lBcr8DmWoHuy/+2+Ka9Z3rD/jEEmnUm944+Fj5XOo3bMqWrma1Od9eIyjp+tjyECq4pLOttSbnEu4dUjDTLWBOmE9bFD8ZVoM8OoeS6KOzRM5PUcnS7yt786Pn0A== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88b9853f-b5cb-490b-26de-08db13c119b3 X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2023 04:07:08.8687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Sg7NpJhO7QZOibOs8lwZGF0dx+N4o4NMdZAqw6lV3AUzhicnsG2IwrBwz5O3hsD/7g0dCDYjcVq1trtpDdI/N2n9Yv4Wtvc2ZamdPtlk9Ds= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB6156 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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 <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758412088143109859?= X-GMAIL-MSGID: =?utf-8?q?1758412088143109859?= |
Series |
MIPS: make mipsisa32 and mipsisa64 link more systematic
|
|
Checks
Context | Check | Description |
---|---|---|
snail/binutils-gdb-check | success | Github commit url |
Commit Message
YunQiang Su
Feb. 21, 2023, 4:06 a.m. UTC
Introduce `static const struct mips_mach_extension mips_mach_32_64[]` and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`, to make mipsisa32 and mipsisa64 interlink more systemtic. Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1), so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64. Note: R6 is not compatible with pre-R6. bfd/ChangeLog: * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and mipsisa64 interlink more systematic. (mips_mach_32_64): new struct added. (mips_mach_extends_32_64): new function added. --- bfd/elfxx-mips.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
Comments
Sorry for the slow review, been away. YunQiang Su <yunqiang.su@cipunited.com> writes: > Introduce `static const struct mips_mach_extension mips_mach_32_64[]` > and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`, > to make mipsisa32 and mipsisa64 interlink more systemtic. > > Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and > mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1), > so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64. > > Note: R6 is not compatible with pre-R6. > > bfd/ChangeLog: > > * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and > mipsisa64 interlink more systematic. > (mips_mach_32_64): new struct added. > (mips_mach_extends_32_64): new function added. > --- > bfd/elfxx-mips.c | 38 ++++++++++++++++++++++++++++---------- > 1 file changed, 28 insertions(+), 10 deletions(-) > > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c > index e9fb61ff9e7..e9480ea3954 100644 > --- a/bfd/elfxx-mips.c > +++ b/bfd/elfxx-mips.c > @@ -14505,6 +14505,16 @@ struct mips_mach_extension > unsigned long extension, base; > }; > > +/* An array describing how BFD machines relate to one another. The entries > + are ordered topologically. */ I don't this comment really applies to the new array. How about: /* An array that maps 64-bit architectures to the corresponding 32-bit architectures. */ > +static const struct mips_mach_extension mips_mach_32_64[] = > +{ > + { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 }, > + { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 }, > + { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 }, > + { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 }, > + { bfd_mach_mipsisa64, bfd_mach_mipsisa32 } > +}; > > /* An array describing how BFD machines relate to one another. The entries > are ordered topologically with MIPS I extensions listed last. */ > @@ -14584,27 +14594,35 @@ static const struct mips_mach_extension mips_mach_extensions[] = > > /* Return true if bfd machine EXTENSION is an extension of machine BASE. */ > > +static bool > +mips_mach_extends_32_64 (unsigned long base, unsigned long extension) > +{ > + size_t i; > + > + if (extension == base) > + return true; > + > + for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++) > + if (extension == mips_mach_32_64[i].extension) > + return base == mips_mach_32_64[i].base; > + > + return false; > +} > + I think this should go before the "Return true if..." comment and should have its own comment. How about: /* Return true if bfd machine EXTENSION is the same as BASE, or if EXTENSION is the 64-bit equivalent of a 32-bit BASE. */ OK with those changes, thanks. Richard > static bool > mips_mach_extends_p (unsigned long base, unsigned long extension) > { > size_t i; > + unsigned long extension1 = extension; > > - if (extension == base) > - return true; > - > - if (base == bfd_mach_mipsisa32 > - && mips_mach_extends_p (bfd_mach_mipsisa64, extension)) > - return true; > - > - if (base == bfd_mach_mipsisa32r2 > - && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension)) > + if (mips_mach_extends_32_64 (base, extension)) > return true; > > for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++) > if (extension == mips_mach_extensions[i].extension) > { > extension = mips_mach_extensions[i].base; > - if (extension == base) > + if (mips_mach_extends_32_64 (base, extension)) > return true; > }
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index e9fb61ff9e7..e9480ea3954 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -14505,6 +14505,16 @@ struct mips_mach_extension unsigned long extension, base; }; +/* An array describing how BFD machines relate to one another. The entries + are ordered topologically. */ +static const struct mips_mach_extension mips_mach_32_64[] = +{ + { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 }, + { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 }, + { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 }, + { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 }, + { bfd_mach_mipsisa64, bfd_mach_mipsisa32 } +}; /* An array describing how BFD machines relate to one another. The entries are ordered topologically with MIPS I extensions listed last. */ @@ -14584,27 +14594,35 @@ static const struct mips_mach_extension mips_mach_extensions[] = /* Return true if bfd machine EXTENSION is an extension of machine BASE. */ +static bool +mips_mach_extends_32_64 (unsigned long base, unsigned long extension) +{ + size_t i; + + if (extension == base) + return true; + + for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++) + if (extension == mips_mach_32_64[i].extension) + return base == mips_mach_32_64[i].base; + + return false; +} + static bool mips_mach_extends_p (unsigned long base, unsigned long extension) { size_t i; + unsigned long extension1 = extension; - if (extension == base) - return true; - - if (base == bfd_mach_mipsisa32 - && mips_mach_extends_p (bfd_mach_mipsisa64, extension)) - return true; - - if (base == bfd_mach_mipsisa32r2 - && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension)) + if (mips_mach_extends_32_64 (base, extension)) return true; for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++) if (extension == mips_mach_extensions[i].extension) { extension = mips_mach_extensions[i].base; - if (extension == base) + if (mips_mach_extends_32_64 (base, extension)) return true; }