From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20062.outbound.protection.outlook.com [40.107.2.62]) by sourceware.org (Postfix) with ESMTPS id 01480382EA0D for ; Fri, 26 Aug 2022 10:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 01480382EA0D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mAG+oFgn0XiKJlIncpKDR/nMFT2Q8CjjZrmjefM5QUjPaebkHoa3NFPpBzcn6a//mVPU9vvByP15lW++G3S3jrEVOLKoVJkSPYYIB8EqVoCOT2PcvftxX9gndvmhd5T6twl549OB9hWA00Cf+1ULP594Z8mg2+rwZKBnRgzXlbfW4v2dj6KX7w5okg00SWaXNW+qcYfpIhESYq4iobA8gPA8LSfHEjK8hZ/PCP0NgoEXQ2jRuXXpsH0xaL4HEtbfiR17Yd5FXxjR5MHiDg/PsuhX0/sCwF4C/Ifa3WDbGqqQH/dBOzG6zqnJ73U/EDPMtwWYzu9yYjS38yWsxxv+9w== 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=7L4XYFoA3hfWyiJO86LS5qgfKgIoOwUiEOLzf9JVirg=; b=AXJnJflAU7Htu9mJmrI9HKE2S5S5ZfEfWV18+7S/Kv+sKDzsruJiD5dkD4/pFusAHf8nvPOaRPOx845iWUemucaHEzK8a0TTrrWjBXS1VP1weLqI6Se9sDD4cIU2IImM/L8+fFJVFaCy67UPN3a0wEkww/okejZXqDFLj5v7uWCVAEG44AYyBvRPcdJvd7hBvOZY3lKZXT4l63IkAiTg6FOAuu+skcFUhuOd7nV+6GvRdAl11BbRJAn+EUyTMEJJ2Ryy9bKSqoePy6fBwYLtieVjo2LrXOJvfRNFRR4I1ynIqpiYxcm8RkkFgjYfULrsxqpifmAz15ACMlSxxLIuCw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7L4XYFoA3hfWyiJO86LS5qgfKgIoOwUiEOLzf9JVirg=; b=W33dQWlyFIIM8pIab0Kh0Dmk3yM3RnjXR17E3zhkaWikKfZEOCHXYZ3N9Ied8xz6WRKfAC6gAqEX7VZMlsV1roGmx3R81rHp3eH9DWSgkL/WoVyhrX7WjUeKKKHW+YSXHzac5LgZ9n5oc416XaewHFNZTgfuxbi4J7M4O/Tg5fJuXOl5FG1PuJASGtC58y77JnZuHDnWdgNwhcgRuMJNNetkIXJ1nFwuWR+DHs+52bR+X19VG6WIJpV9N6Z6Gh16fX9oCNA8WW3LyU1s1hyn65YGleeyiD3ypSe+C85a7lghLT9oAKTFyF5w8VbNW0voKbrnF7uhPRYbeqytH27XaA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AM8PR04MB7473.eurprd04.prod.outlook.com (2603:10a6:20b:1d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Fri, 26 Aug 2022 10:33:46 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad%4]) with mapi id 15.20.5566.015; Fri, 26 Aug 2022 10:33:46 +0000 Message-ID: Date: Fri, 26 Aug 2022 12:33:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: [PATCH v2 7/7] x86: move bad-use-of-TLS-reloc check Content-Language: en-US To: Binutils References: <4a27fbde-d2b2-e293-d09e-9709bc5b9792@suse.com> Cc: "H.J. Lu" From: Jan Beulich In-Reply-To: <4a27fbde-d2b2-e293-d09e-9709bc5b9792@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0091.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::11) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 001e822d-8b57-47b5-3705-08da874e74b6 X-MS-TrafficTypeDiagnostic: AM8PR04MB7473:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: //t6BK8R7aW3sOK0jYj4XSgMhYLKM215KtqT1yk6a2qfLn21Djy3lMRObH60M10ERhUyBQ//8X0y9URANXDtvG9p1mCoyayNB6tAGjdH2ePlSqE0rOQdGwd3SkmZbHEvzmMefEwJm9wl7AcW5irjmzR8hvcQu8HpKKfVVkSiN2eKmqno4wAzb9QPjHyKGCmJr/yIOLfzYUY1VotRRVcZ+L7zlkgjjOZhkP/hgG9AbScN09cSH06knvCbEWzylO0jganm2MhdXWH/zi8vP0SjpezB1mDDArpKUbIB0yKO6xHME7gkU7a89HYSrHxmv1WrzxhDF822chBlrgIG0DwFlXjDLc8hszxKPfoQrPfDQMj0VLwNPVo7XUgd7qfCDgBMdQOIv7D3ZHEVFYoCKrAFXGgOHoDKbqEFqTTpxALCqkJowUBzLxfe4ENJofixpm+RznVDVB/f75XXLXtTua8/rSNLDiTDcr1WIoeQgJH747euYscb1SLLcDbvU4HBd8dwDWcs3rZ9HtZ/vSc9MQabk8M0+uorG2YaaOFshwrr+agVcMFEosMaXBy94qEujfowt05M5XZc8EQkNS72Ivr7sJHsGRBdMMHE+ucVaNMh01cDSoKhcuSL3nJbK3iwUp65AVO47vOtOnteYIo5ITJ028Wnug+GvZgbdjPxDYwOyNnwB4lAy5rcVQ6KBFcjh17GO96hF5XemaAQs2hd6Yk07dD7XNJEEyIz8bSih4VbbO5OzhnRfD6HOPe/1VRBey5Np4rhXnVF46HHmTfjjPYi8R1ttdjnNAidv5C+3Db8C0Y= 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:(13230016)(346002)(39860400002)(376002)(136003)(396003)(366004)(6486002)(41300700001)(66946007)(2616005)(4326008)(66476007)(36756003)(186003)(66556008)(31686004)(8676002)(6512007)(31696002)(38100700002)(26005)(86362001)(5660300002)(6916009)(2906002)(8936002)(478600001)(316002)(6506007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?amU0M2t1WHdERUZteVFCbWNGb3MySDFWcGZ5c0VZcGI5K3hleTNQamZUNlZZ?= =?utf-8?B?UWhCN0grQmttUjNYZUZwNzBlMnB0a2F1bUlXaUlTU1dyR3VMZTJPY1d6QWU0?= =?utf-8?B?WXlzR3lZUGdsOVRIM1dxRXk4cGdiWmt1NG43TnJBdDkvR0N5NXNxbk01TEpy?= =?utf-8?B?T1dLY05GeU9VWWZjcEJaZ3I3ZVU4OWFyYjlFN1hOdDVuTzlWZTlJb2dYdDdq?= =?utf-8?B?MWgrNmpBUEJxZ0YwWlBzVlhCZEhLYWpsWWZt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1aNTZRT2JIcDczeWdSdVZVTFc3d1NYR2QxTFZVUnUxczVNb3lz?= =?utf-8?Q?exIovQANZQRd9C5blDfd6jlF0?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 001e822d-8b57-47b5-3705-08da874e74b6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 10:33:46.3987 (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: AtZ9AOdiJlntAOPSpp5833HjTAuNAov8uj2FlY9uZwLZjWkP0BQr7SgZL9ruOtALo6nC/crhaiLy+lRzEMOltw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7473 X-Spam-Status: No, score=-3030.1 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 List-Id: Having it in match_template() is unhelpful. Neither does looking for the next template to possibly match make any sense in that case, nor is the resulting diagnostic making clear what the problem is. While moving the check, also generalize it to include all SIMD and VEX- encoded insns. This way an existing conditional can be re-used in md_assemble(). Note though that this still leaves a lof of insns which are also wrong to use with these relocations. Further fold the remaining check (BFD_RELOC_386_GOT32) with the XRELEASE related one a few lines down. This again allows re-using an existing conditional. --- Is the set of relocations enumerated here actually complete? --- v2: New. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5116,14 +5116,30 @@ md_assemble (char *line) return; } - /* Check for data size prefix on VEX/XOP/EVEX encoded and SIMD insns. */ - if (i.prefix[DATA_PREFIX] - && (is_any_vex_encoding (&i.tm) - || i.tm.operand_types[i.imm_operands].bitfield.class >= RegMMX - || i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX)) + if (is_any_vex_encoding (&i.tm) + || i.tm.operand_types[i.imm_operands].bitfield.class >= RegMMX + || i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX) { - as_bad (_("data size prefix invalid with `%s'"), i.tm.name); - return; + /* Check for data size prefix on VEX/XOP/EVEX encoded and SIMD insns. */ + if (i.prefix[DATA_PREFIX]) + { + as_bad (_("data size prefix invalid with `%s'"), i.tm.name); + return; + } + + /* Don't allow e.g. KMOV in TLS code sequences. */ + for (j = i.imm_operands; j < i.operands; ++j) + switch (i.reloc[j]) + { + case BFD_RELOC_386_TLS_GOTIE: + case BFD_RELOC_386_TLS_LE_32: + case BFD_RELOC_X86_64_GOTTPOFF: + case BFD_RELOC_X86_64_TLSLD: + as_bad (_("TLS relocation cannot be used with `%s'"), i.tm.name); + return; + default: + break; + } } /* Check if HLE prefix is OK. */ @@ -6765,26 +6781,6 @@ match_template (char mnem_suffix) } } - switch (i.reloc[0]) - { - case BFD_RELOC_386_GOT32: - /* Force 0x8b encoding for "mov foo@GOT, %eax". */ - if (t->base_opcode == 0xa0 - && t->opcode_modifier.opcodespace == SPACE_BASE) - continue; - break; - case BFD_RELOC_386_TLS_GOTIE: - case BFD_RELOC_386_TLS_LE_32: - case BFD_RELOC_X86_64_GOTTPOFF: - case BFD_RELOC_X86_64_TLSLD: - /* Don't allow KMOV in TLS code sequences. */ - if (t->opcode_modifier.vex) - continue; - break; - default: - break; - } - /* We check register size if needed. */ if (t->opcode_modifier.checkregsize) { @@ -6815,12 +6811,19 @@ match_template (char mnem_suffix) && i.types[1].bitfield.instance == Accum && i.types[1].bitfield.dword) continue; - /* xrelease mov %eax, is another special case. It must not - match the accumulator-only encoding of mov. */ - if (i.hle_prefix - && t->base_opcode == 0xa0 + + if (t->base_opcode == MOV_AX_DISP32 && t->opcode_modifier.opcodespace == SPACE_BASE) - continue; + { + /* Force 0x8b encoding for "mov foo@GOT, %eax". */ + if (i.reloc[0] == BFD_RELOC_386_GOT32) + continue; + + /* xrelease mov %eax, is another special case. It must not + match the accumulator-only encoding of mov. */ + if (i.hle_prefix) + continue; + } /* Fall through. */ case 3: From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20062.outbound.protection.outlook.com [40.107.2.62]) by sourceware.org (Postfix) with ESMTPS id 01480382EA0D for ; Fri, 26 Aug 2022 10:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 01480382EA0D ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mAG+oFgn0XiKJlIncpKDR/nMFT2Q8CjjZrmjefM5QUjPaebkHoa3NFPpBzcn6a//mVPU9vvByP15lW++G3S3jrEVOLKoVJkSPYYIB8EqVoCOT2PcvftxX9gndvmhd5T6twl549OB9hWA00Cf+1ULP594Z8mg2+rwZKBnRgzXlbfW4v2dj6KX7w5okg00SWaXNW+qcYfpIhESYq4iobA8gPA8LSfHEjK8hZ/PCP0NgoEXQ2jRuXXpsH0xaL4HEtbfiR17Yd5FXxjR5MHiDg/PsuhX0/sCwF4C/Ifa3WDbGqqQH/dBOzG6zqnJ73U/EDPMtwWYzu9yYjS38yWsxxv+9w== 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=7L4XYFoA3hfWyiJO86LS5qgfKgIoOwUiEOLzf9JVirg=; b=AXJnJflAU7Htu9mJmrI9HKE2S5S5ZfEfWV18+7S/Kv+sKDzsruJiD5dkD4/pFusAHf8nvPOaRPOx845iWUemucaHEzK8a0TTrrWjBXS1VP1weLqI6Se9sDD4cIU2IImM/L8+fFJVFaCy67UPN3a0wEkww/okejZXqDFLj5v7uWCVAEG44AYyBvRPcdJvd7hBvOZY3lKZXT4l63IkAiTg6FOAuu+skcFUhuOd7nV+6GvRdAl11BbRJAn+EUyTMEJJ2Ryy9bKSqoePy6fBwYLtieVjo2LrXOJvfRNFRR4I1ynIqpiYxcm8RkkFgjYfULrsxqpifmAz15ACMlSxxLIuCw== 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 AM8PR04MB7473.eurprd04.prod.outlook.com (2603:10a6:20b:1d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Fri, 26 Aug 2022 10:33:46 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2d5d:bae0:430f:70ad%4]) with mapi id 15.20.5566.015; Fri, 26 Aug 2022 10:33:46 +0000 Message-ID: Date: Fri, 26 Aug 2022 12:33:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: [PATCH v2 7/7] x86: move bad-use-of-TLS-reloc check Content-Language: en-US To: Binutils References: <4a27fbde-d2b2-e293-d09e-9709bc5b9792@suse.com> From: Jan Beulich In-Reply-To: <4a27fbde-d2b2-e293-d09e-9709bc5b9792@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0091.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::11) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 001e822d-8b57-47b5-3705-08da874e74b6 X-MS-TrafficTypeDiagnostic: AM8PR04MB7473:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: //t6BK8R7aW3sOK0jYj4XSgMhYLKM215KtqT1yk6a2qfLn21Djy3lMRObH60M10ERhUyBQ//8X0y9URANXDtvG9p1mCoyayNB6tAGjdH2ePlSqE0rOQdGwd3SkmZbHEvzmMefEwJm9wl7AcW5irjmzR8hvcQu8HpKKfVVkSiN2eKmqno4wAzb9QPjHyKGCmJr/yIOLfzYUY1VotRRVcZ+L7zlkgjjOZhkP/hgG9AbScN09cSH06knvCbEWzylO0jganm2MhdXWH/zi8vP0SjpezB1mDDArpKUbIB0yKO6xHME7gkU7a89HYSrHxmv1WrzxhDF822chBlrgIG0DwFlXjDLc8hszxKPfoQrPfDQMj0VLwNPVo7XUgd7qfCDgBMdQOIv7D3ZHEVFYoCKrAFXGgOHoDKbqEFqTTpxALCqkJowUBzLxfe4ENJofixpm+RznVDVB/f75XXLXtTua8/rSNLDiTDcr1WIoeQgJH747euYscb1SLLcDbvU4HBd8dwDWcs3rZ9HtZ/vSc9MQabk8M0+uorG2YaaOFshwrr+agVcMFEosMaXBy94qEujfowt05M5XZc8EQkNS72Ivr7sJHsGRBdMMHE+ucVaNMh01cDSoKhcuSL3nJbK3iwUp65AVO47vOtOnteYIo5ITJ028Wnug+GvZgbdjPxDYwOyNnwB4lAy5rcVQ6KBFcjh17GO96hF5XemaAQs2hd6Yk07dD7XNJEEyIz8bSih4VbbO5OzhnRfD6HOPe/1VRBey5Np4rhXnVF46HHmTfjjPYi8R1ttdjnNAidv5C+3Db8C0Y= 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:(13230016)(346002)(39860400002)(376002)(136003)(396003)(366004)(6486002)(41300700001)(66946007)(2616005)(4326008)(66476007)(36756003)(186003)(66556008)(31686004)(8676002)(6512007)(31696002)(38100700002)(26005)(86362001)(5660300002)(6916009)(2906002)(8936002)(478600001)(316002)(6506007)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?amU0M2t1WHdERUZteVFCbWNGb3MySDFWcGZ5c0VZcGI5K3hleTNQamZUNlZZ?= =?utf-8?B?UWhCN0grQmttUjNYZUZwNzBlMnB0a2F1bUlXaUlTU1dyR3VMZTJPY1d6QWU0?= =?utf-8?B?WXlzR3lZUGdsOVRIM1dxRXk4cGdiWmt1NG43TnJBdDkvR0N5NXNxbk01TEpy?= =?utf-8?B?T1dLY05GeU9VWWZjcEJaZ3I3ZVU4OWFyYjlFN1hOdDVuTzlWZTlJb2dYdDdq?= =?utf-8?B?MWgrNmpBUEJxZ0YwWlBzVlhCZEhLYWpsWWZtYzVWZFlTSDBJTHJwRWxEbmNX?= =?utf-8?B?N01YbTg2eHJFZUZWTTl1SlFZTVoxT3pqelVocUw1anVYZ0sveFNRN0FSQ2NG?= =?utf-8?B?ajNsK1FkMTBCYnlqZTNMVTczM2hReHFXbk5ZdENUV1NxL3d2R1I1SXdtMnpa?= =?utf-8?B?bjFWS3ZpM1NhcW5UV2dCdVRhU3FhWDF0aXlxSy9jRzYzWlFqTWxxdXRHdUhI?= =?utf-8?B?SDBGNTZoS2dpVUJLRjVtVnNpcTBLTUZyeDl4SHdQUENzUllNY09PMEtlYlJC?= =?utf-8?B?emJMTVRYVU93a05CT0NDY3pFeVlFV2Urb3BMQWhaVEE0UDh2T3NXWHduQTl3?= =?ut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DZ1JseGhtd0RD?= =?utf-8?B?NDlYYkVaclE1OXVreUZHUDBLSEQwN0tOZ3lLNDBRREhKdk15ZDVPOGdrQlF3?= =?utf-8?B?MDRaM3F2WnU1RkN6ZkptSWxSYUh4RUJaS3VpeVN4Z05hVk1mKzlCUkxHRktk?= =?utf-8?B?V1BGY0ZicnJDU3pkZ0dHWUN1NUZxV0JqUVR1dnVBYmlBaW5iWmMxQmVjakFX?= =?utf-8?B?TGM2dFVUT2tDNUJiMjlENzJ5WTREdlN1MVZhUkxGaHcwbEk1cHpDMDFHYms5?= =?utf-8?B?RTJVdDlPQVBRanRleFNzb2NNb01paWV2QTZOU1JlMEF3Z3JjUi9jMHhmd2c4?= =?utf-8?B?bjZSRHhrS295NTZFKzA0bjdPeVRmUERwOVhzdjgzMHFQbDVQaVZhbTg4ODBh?= =?utf-8?B?OFdHdHoybVhzZ2pUQTJCZnNKRXhabVMzclllejFuNGsweWttQU9jbUhxWmZ5?= =?utf-8?B?cWpHV2pyVUUvT2lYNlZZK01MUU04MjN4dHFhMXRSaDFZR1BlSElHRTFJeDR4?= =?utf-8?B?ME5KNTREUFZEc1pRbWZzSjYrbXp5S3JHK0xGbjdvNzJQMnovdU1uazIzQzg1?= =?utf-8?B?SHdpbDhZSk1aNTZRT2JIcDczeWdSdVZVTFc3d1NYR2QxTFZVUnUxczVNb3lz?= =?utf-8?Q?exIovQANZQRd9C5blDfd6jlF0?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 001e822d-8b57-47b5-3705-08da874e74b6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 10:33:46.3987 (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: AtZ9AOdiJlntAOPSpp5833HjTAuNAov8uj2FlY9uZwLZjWkP0BQr7SgZL9ruOtALo6nC/crhaiLy+lRzEMOltw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7473 X-Spam-Status: No, score=-3030.1 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-List-Received-Date: Fri, 26 Aug 2022 10:33:49 -0000 Message-ID: <20220826103344.pGZvCkbj5KUtrYzDnQAApur6srmJTfAX8bKk_9fba5E@z> Having it in match_template() is unhelpful. Neither does looking for the next template to possibly match make any sense in that case, nor is the resulting diagnostic making clear what the problem is. While moving the check, also generalize it to include all SIMD and VEX- encoded insns. This way an existing conditional can be re-used in md_assemble(). Note though that this still leaves a lof of insns which are also wrong to use with these relocations. Further fold the remaining check (BFD_RELOC_386_GOT32) with the XRELEASE related one a few lines down. This again allows re-using an existing conditional. --- Is the set of relocations enumerated here actually complete? --- v2: New. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5116,14 +5116,30 @@ md_assemble (char *line) return; } - /* Check for data size prefix on VEX/XOP/EVEX encoded and SIMD insns. */ - if (i.prefix[DATA_PREFIX] - && (is_any_vex_encoding (&i.tm) - || i.tm.operand_types[i.imm_operands].bitfield.class >= RegMMX - || i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX)) + if (is_any_vex_encoding (&i.tm) + || i.tm.operand_types[i.imm_operands].bitfield.class >= RegMMX + || i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX) { - as_bad (_("data size prefix invalid with `%s'"), i.tm.name); - return; + /* Check for data size prefix on VEX/XOP/EVEX encoded and SIMD insns. */ + if (i.prefix[DATA_PREFIX]) + { + as_bad (_("data size prefix invalid with `%s'"), i.tm.name); + return; + } + + /* Don't allow e.g. KMOV in TLS code sequences. */ + for (j = i.imm_operands; j < i.operands; ++j) + switch (i.reloc[j]) + { + case BFD_RELOC_386_TLS_GOTIE: + case BFD_RELOC_386_TLS_LE_32: + case BFD_RELOC_X86_64_GOTTPOFF: + case BFD_RELOC_X86_64_TLSLD: + as_bad (_("TLS relocation cannot be used with `%s'"), i.tm.name); + return; + default: + break; + } } /* Check if HLE prefix is OK. */ @@ -6765,26 +6781,6 @@ match_template (char mnem_suffix) } } - switch (i.reloc[0]) - { - case BFD_RELOC_386_GOT32: - /* Force 0x8b encoding for "mov foo@GOT, %eax". */ - if (t->base_opcode == 0xa0 - && t->opcode_modifier.opcodespace == SPACE_BASE) - continue; - break; - case BFD_RELOC_386_TLS_GOTIE: - case BFD_RELOC_386_TLS_LE_32: - case BFD_RELOC_X86_64_GOTTPOFF: - case BFD_RELOC_X86_64_TLSLD: - /* Don't allow KMOV in TLS code sequences. */ - if (t->opcode_modifier.vex) - continue; - break; - default: - break; - } - /* We check register size if needed. */ if (t->opcode_modifier.checkregsize) { @@ -6815,12 +6811,19 @@ match_template (char mnem_suffix) && i.types[1].bitfield.instance == Accum && i.types[1].bitfield.dword) continue; - /* xrelease mov %eax, is another special case. It must not - match the accumulator-only encoding of mov. */ - if (i.hle_prefix - && t->base_opcode == 0xa0 + + if (t->base_opcode == MOV_AX_DISP32 && t->opcode_modifier.opcodespace == SPACE_BASE) - continue; + { + /* Force 0x8b encoding for "mov foo@GOT, %eax". */ + if (i.reloc[0] == BFD_RELOC_386_GOT32) + continue; + + /* xrelease mov %eax, is another special case. It must not + match the accumulator-only encoding of mov. */ + if (i.hle_prefix) + continue; + } /* Fall through. */ case 3: