From patchwork Mon Oct 14 11:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cui, Lili" X-Patchwork-Id: 98852 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8E24A3857820 for ; Mon, 14 Oct 2024 11:02:11 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by sourceware.org (Postfix) with ESMTPS id 4F03F3858C5F for ; Mon, 14 Oct 2024 11:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F03F3858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F03F3858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728903706; cv=none; b=dOTz4noVt47CX66jwO+eRtNlQ9ARP9j3eD8ehLIRHcB48D8qXcFgPK/2HLA13EZAew/mhycENpjETYR/POP4GB/F0xa+SPvqCJYpHKY1wkhMPmRcvyTQCJvdkEViJi0aIZEoQZNKUl0ScycoLHe2dGSrQBK7+Z+DIPjgoedjU3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728903706; c=relaxed/simple; bh=GOM/waxgYdloBsA79V9YeoVmEHY0Y2oWHiqlxqMKLqw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=V/Iw+EYUyg0LuDK1PjRAyorCI3LSLhBV+bJ41WjnOy1oRFe2y56mvRjAQ3cQ1AtOtjbhNRAiHXGlZz0KmXu837MdJJGd550aPmTzMUz1QlNPCtOsfGIsk7/wJsPDfChSbXc2MZ7f9C8sWmKbUToxAyuiSnBsAibpTnFVbdf71WM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728903699; x=1760439699; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GOM/waxgYdloBsA79V9YeoVmEHY0Y2oWHiqlxqMKLqw=; b=Biiumh+mVU/37idcYhZ+B17VI3/0o23PFB+GEkL3ODoLQDnUXJL3uKZ7 NLuJYI2mnN3ZJFQ07rE051XbLdG0D5z+wmjD3ESOlRQNtNKRgm2FR0AdV rgA4HOCX5UWjx/LC77ZBVPqXQsQaB9vIIszI3LRa0qzZ29CUAWtTBkJP1 FswyYHGQv7t229ekg6qQwnKSosWPXsedFloq6WCSd9YfBWgyvaOPQ/XoN nuJPJj0iCwkD64Q0BIirCxgesE4sMcz9XSWYVF5p+lDQdmmOeH4Mwf+69 wH6Pj/UaGh/aBqVbWbbxmvMfs+rj5m8b7yRKJsUcFhcjYYy6k3mXAgmjn g==; X-CSE-ConnectionGUID: 8MJVTCByRGuwBeN0nSxM5g== X-CSE-MsgGUID: 8bqwPbXJTsC8+kuqOahU/Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28199788" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28199788" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 04:01:37 -0700 X-CSE-ConnectionGUID: YV/Iz7F1RwSKHB2vRDLkTg== X-CSE-MsgGUID: kWfcz1fESriuC2RqOJ9niw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,202,1725346800"; d="scan'208";a="77637195" Received: from scymds04.sc.intel.com ([10.82.73.238]) by fmviesa008.fm.intel.com with ESMTP; 14 Oct 2024 04:01:37 -0700 Received: from shgcc10.sh.intel.com (shgcc10.sh.intel.com [10.239.85.189]) by scymds04.sc.intel.com (Postfix) with ESMTP id DCE212003119; Mon, 14 Oct 2024 04:01:35 -0700 (PDT) From: "Cui, Lili" To: hjl.tools@gmail.com, jbeulich@suse.com Cc: binutils@sourceware.org Subject: [PATCH] x86: Refine instruction check in x86_check_tls_relocation Date: Mon, 14 Oct 2024 19:01:35 +0800 Message-Id: <20241014110135.1166703-1-lili.cui@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This patch is to Refine instruction check in x86_check_tls_relocation. Ok for master? Thanks, Lili. gas/ChangeLog: * config/tc-i386.c (x86_check_tls_relocation): Refine instruction check. --- gas/config/tc-i386.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index cdefde03717..cfab10d68b8 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -6747,9 +6747,10 @@ x86_check_tls_relocation (enum bfd_reloc_code_real r_type) && i.tm.mnem_off != MN_add && i.tm.mnem_off != MN_mov) return x86_tls_error_insn; - if (i.op[1].regs->reg_type.bitfield.class != Reg - || i.op[0].regs->reg_type.bitfield.class - || i.imm_operands) + if (i.imm_operands + || i.disp_operands != 1 + || i.reg_operands != 1 + || i.types[1].bitfield.class != Reg) return x86_tls_error_opcode; if (!i.base_reg) return x86_tls_error_no_base_reg; @@ -6769,9 +6770,10 @@ x86_check_tls_relocation (enum bfd_reloc_code_real r_type) */ if (i.tm.mnem_off != MN_add && i.tm.mnem_off != MN_mov) return x86_tls_error_insn; - if (i.op[1].regs->reg_type.bitfield.class != Reg - || i.op[0].regs->reg_type.bitfield.class - || i.imm_operands) + if (i.imm_operands + || i.disp_operands != 1 + || i.reg_operands != 1 + || i.types[1].bitfield.class != Reg) return x86_tls_error_opcode; if (i.base_reg || i.index_reg) return x86_tls_error_require_no_base_index_reg; @@ -6789,10 +6791,9 @@ x86_check_tls_relocation (enum bfd_reloc_code_real r_type) */ if (i.tm.mnem_off != MN_add && i.tm.mnem_off != MN_mov) return x86_tls_error_insn; - if (i.op[i.operands - 1].regs->reg_type.bitfield.class != Reg - || (i.op[0].regs->reg_type.bitfield.class - && i.tm.opcode_modifier.vexvvvv != VexVVVV_DST) - || i.imm_operands) + if (i.imm_operands + || i.disp_operands != 1 + || i.types[i.operands - 1].bitfield.class != Reg) return x86_tls_error_opcode; if (!i.base_reg) return x86_tls_error_no_base_reg;