From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 667453857B9C for ; Tue, 23 Jan 2024 09:39:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 667453857B9C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 667453857B9C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706002751; cv=pass; b=TZe721S63+vudfynxkKGY0goDFXKNUsLcy47pVrRVLUVg+UhEaKj6WmobxoR2K6bBTh8mvKq2ZJqZUOzuZNbuAcYTqAfktO7M0LefviiYHEKUd/lQHZ0DcQITwHTbWjylczNhUf8VBOnUzBBA9f9YiW4Iv/XLbZ67tauvpxlD40= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706002751; c=relaxed/simple; bh=YkiBAVmA14tYeMP9xMlmO6w2ihbSuk8C2W1mTSkjj9s=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=ll7b49OO72ldHVD3552PXOeyIMbuVI+s14w2B7Xf51sslkgZJ4J7TyECS2arX0yNBT9Npzkj8VEnnhMyxNfrMPAWKd38uoqPHM6IbC9fLFqEHzzFXOVjUoWoUKunaMe7uEVSHvudzbKCyxgUqgblcGsSUI1GEXxzEGNKbO8Nm6Q= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40N6ZIe2008700 for ; Tue, 23 Jan 2024 09:39:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=RSKYW1pYog8EyQQpsY7gcYYeXe25FtgVvTYeXsVfPoI=; b=hjbOTk7fu30FPOov4duKBR4OgtAgHh/SQLBiOSmcp406VDkSlUnSRQ05m/8xJmNtIerp YWp9fQ9/ybRiVFtx+xttv6jZ40q0VEYviP1v9dDG8640HYNqOghlpzk0UFDXdHyEC/v4 9PtHNo7QX5mILApGkDFEvOX85sq0sex2LvYbWlzunWW/k8PJAGmxRk8BGRAxdfJq+dEu 4YuLMdZfkPpaVcz7XrAW/YqtBkzbg2zLmPr88r7hUzs0EyEu5pb5Lra94BKrQwfb5AhG PGCbDuhsByEIXU6WTfdHXQ6sYihDvnm+N95NyWjQ5W/gUD7tlPOOpUCCUgjVrIOWeJOu TA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vr79ndv1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 23 Jan 2024 09:39:07 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40N80iq1033464 for ; Tue, 23 Jan 2024 09:38:59 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vs3710u9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 23 Jan 2024 09:38:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=REyLkPapsB6TIxfbBzjmy0Cr84Hlv47pYyOdFF6uEKo6peqdPCvX1nfxAluIXDpR1saoDxcYSCn53+wq9qNmqnCPNbIVwukTOFKWXuUvUSa/qEsRJQPXyZlfQ2+LLLHyOvGJlOavC7kItnKiOwiyzEripjU2n9IodjLQefunL0B/MIMXYecn8adWq/1V0x0ByX7nMY0SHzUBXvZuFfc2s/qq5a0oi2NExtMuRRiVMweO10Z3FZTb1+q16RDayR6kW+vMFKFzscpALKMKacn6t2/07k+2OJLPvS01Z2sQOXq+rNXb34XwBukL8eSHROB8AJS0E+V0lstNzkU0q3Uapg== 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=RSKYW1pYog8EyQQpsY7gcYYeXe25FtgVvTYeXsVfPoI=; b=Zro8AAK+OMWTJviSDAXZK6lEogZNH4dTvEjXd1pshHxJtJhxcvtr4dS6F3XqUmyaUhFhxiXhkBbXgR+SXkdRxuCvvTdGgh6cE52NS7TGXl01NfAuIC7eyzo/sc5hLP/f7LWVSbo+T3V3mj6PF5eytXB7G9TU/W0KuNEx+uZoQposncL8VygDV43gRUQXQbGSNjdluyYM0tsAVjuFvpxGQvyyYdD8Wuk5iwMhTFEuhzfnlasPuA+T36JJtng4PHznQVAP7eiv6K7+JkIgxedT0NdciNZ7SGYqaPXDe3o8lIjZZItVsBqMW1Dlba7NulDtXjWP3UVtTG3ZrMj+Rr9KRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RSKYW1pYog8EyQQpsY7gcYYeXe25FtgVvTYeXsVfPoI=; b=WsxgrcNyHhZCHrJxvMTJHstEVCFj1+bfnJ4y87aWnVw++/sdzKEBOvdC0dGlfc19DMpwJByEy0WAbYsTQOdMw4KTz8P3tDehrOftUsMTt5XA/1SaaZDz0oagPswMM5epKBCOqUOZdgdRUUPf4AFxKWmfs8oDi1TGPU+V8bjgGQI= Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by SN7PR10MB6548.namprd10.prod.outlook.com (2603:10b6:806:2ab::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34; Tue, 23 Jan 2024 09:38:57 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::fde7:fb92:8ea1:a5ac]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::fde7:fb92:8ea1:a5ac%4]) with mapi id 15.20.7202.031; Tue, 23 Jan 2024 09:38:57 +0000 From: Indu Bhagat To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH] gas: x86: ginsn: adjust ginsns for certain lea ops Date: Tue, 23 Jan 2024 01:38:55 -0800 Message-ID: <20240123093855.3617792-1-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.43.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MW4PR04CA0310.namprd04.prod.outlook.com (2603:10b6:303:82::15) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|SN7PR10MB6548:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cbba440-2b55-4807-9355-08dc1bf71f3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZeIKB5Rv74yjBX9iBDIuKLDo7mDuu854l45pIz5yr/e8KEmb4xlAjJi41WSIJMT+6uVL1/V/+mNa4aKqPEtrwtYpk7NdheIHInVHxsBfTmWKMRCBCYCGwMeqtEAdCmXXnbzLiOCItH5RvqnutO08ecubdMuP8StGC88pUEudGqv9xukdxQYod9qCeRzbXfDkKKz7UYriIg16yMQalhqLXa5UBHDB/Qj43fLThxn4nbTeWjq6PoPhnJ97h4PceInYb/ZuPtX2TxOPV83KE+yTlYmF5+ERrBDe1ltVfdc6gWQjf64h9eTQzcYViFPDnB1b/ibTRIDOEQe4gS29baIk70bhGjRjVkxKFS77+9hFAE1FYe+/kZR+c7TlBNWh+8BiMjc8Y228/Rz6G64dzPeWAB/9uyPGhCMsFZR9V3HiZWzF37eezWVeDo52QHTvVmq2FCHrZc43lYPcPRk3Tu3K2/euQwNdGzxWolf7MnbLaDxuxYRWrLWapnrDitiKBmX2RvVIOZUury54T6qcQWCOerc7hiE1UlM8Z4FDKCWF9h0HQaHYDBIxtYFqyfxnUVkn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2158.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(366004)(376002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(86362001)(38100700002)(36756003)(2616005)(1076003)(83380400001)(107886003)(6506007)(6486002)(6512007)(66946007)(8676002)(6916009)(66556008)(66476007)(478600001)(44832011)(5660300002)(4326008)(2906002)(316002)(41300700001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EAALzDD1w0Vy8M90Ik+v0wNfq8+bYo96IGvNhYaPV65RBNp3aJXtIqcXD7Bp?= =?us-ascii?Q?0PFwMB0zyhJd7HdgDfbwKM94uafwDxb8/DUCTwgHJ2nlWq7+829GObjk3OlA?= =?us-ascii?Q?PwrCWXqq4rq48x+FvVqTAG/fm1s3v7VQiE66RaGT/etUxi4MT8NE/IYcNPeM?= =?us-ascii?Q?z/aVvaWgJsM7ANpNS0kehtJNmaIHtmtIZlsy1xIx7fynFTts0EzINP8KSxCr?= =?us-ascii?Q?WdRKNKSe9EJvuv4eMRDh8KyX1/uwvBoEuqkOA/jj8zUpPl3SRNF4TCXXH2bs?= =?us-ascii?Q?NV2LAB2RAqmxB9/nOUSv9PT4kmawq4qW1PwdHyfBEojyXZgubVVPyRy8VAUY?= =?us-ascii?Q?BCM0NtrvXEI1k7bwNibxmgWT/AYgItwh6duIJZ7wLpQ8m/r1oCqX+HKlCTC4?= =?us-ascii?Q?zHO6Jkqg5wIeUGCDqeGgO9oAdS0fYEs7xJof3NPvxULSbj5seVDwc+3hXoVN?= =?us-ascii?Q?E4o+8OwEvqtdJl7F47QGfz3o4w6GfGAWIBg6wTey8oOvcMkvQF+5TUBvhaMJ?= =?us-ascii?Q?RF7lr0XdKMtewo4J7Cq1D1yv/9bwN1v81+/tqqZvuR4z5wkwYyVvY7WcoJ0Q?= =?us-ascii?Q?BHcxkigHYGDjrgsBjnJcYHd5s4wPBQTlAn1gjtPyVnnZ6yzErRrSMETDgFi4?= =?us-ascii?Q?9Huh41yyPr04OoHsINFrFAL4qB8OT77KrwRDg5+GiXKxB4BefJda4waVOtwW?= =?us-ascii?Q?+Iru3FdLcqLoSHHUJ/gLN34eqi9orbix1fvt8b4FruP/r68WV0EUMAi9Ceaw?= =?us-ascii?Q?BWfEtamx/ia1QVhSyGRTbfG1Mj+Wu6prTkzUdrQ4nlgoy7jJQ4xXeH+1nBTF?= =?us-ascii?Q?Zl2GcryAW78wvOVVwTCDsyuv44ykClnaNmo9m+oPFnqLVRwu2Vh2bMC0Vrh/?= =?us-ascii?Q?lfjqx7wALommcNuM4+olS4VzDH4pUKI8LW9GLx7xXnlPlgDZzwQ0JU5pRGMD?= =?us-ascii?Q?mVhOhmGMfukFpXH7doxHf21QsaoI1HUgjrtthRPKqNsuI0ssBFsNLPlLx26T?= =?us-ascii?Q?8ZNmwOd5QJL2TQe8BBcOZ69l/4KfEju3Y2PlrZ+slLSfrGBOZ0xSUz3r9c9h?= =?us-ascii?Q?M1yQe4XmAQiPOTQsKCDkrywBn8bay1MsLc3nQqPqXvkvb6ReL/IjhWFcx3D4?= =?us-ascii?Q?j6O1nwEb429YxoA3KyT0TtZip046EYXk7Q3kcwT72syORd8vaTsstUF776uI?= =?us-ascii?Q?iritEM1PPRt5xXOxPNNmC0t3jmw0TptCJkmk9FSl74nV6RvUPc1vQXv2Qw4b?= =?us-ascii?Q?ZnGE+OpEqV144/yJI8z4cXPJXTIE1OreNQ5VfzOoNZEQQqQlI7PXnqEfRbrz?= =?us-ascii?Q?BteVymcUeyG4s/yBznR9gGjXHcQ6Q9ERcvnqlk7vYcrib6oGt88uECAXJgyf?= =?us-ascii?Q?cVIKtLgVFIeFOKC751E0KjcfUVuLQ1UPiMPn/3urJXTY07ACyoveK9oTJrLV?= =?us-ascii?Q?BKtY/A/nzO5O8IPs7SK8cH66U5PIwukQgnOfcuN1syvwAO0W7TC0HxEVBj/S?= =?us-ascii?Q?5JOrMC39P+QiUrEVSGYudyuv7JgJxNQVqLfPd6DyvHzZC5dpf4nbEbuCRwQm?= =?us-ascii?Q?HmO2fxTZI3WLumNcmmmXOTAOxm6i2NrPAN05TdYH21vH8MsL2n4yGKxuPXSW?= =?us-ascii?Q?Ue5uy2L9STNWcLgxm5gIVuE=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9a7BcIJyt+kJljUoGsbDymLRJfqcdFX8wiVeSS6vosrs+9SyLAb/mGDAgv0OjcTp1tR6BzPC38g4ajGul/oWAR4D78oBMFqyy3/iOYTVmpdYvCeGB6JxWbcPKIH9qcCgvIMRRstUcicBFBkMMCSaM5gUcUmN+mo5G5E7BqkQq2t6/kbRkSGBHbIYlBXurPkRA9B0kB9l76nFhv8NqGrz1jxPJMaxj4vyR0FkAajg1+7/7zuCcCm97KeeVJ0r6n7cGFcgnmr/eZzOF/CHcc6Rtckq/NLFyyCzCAWx/lcspSy6fgL85fXG5skFvgeztuY9WYLT1WhE+OAznDPtncyL1V6BfkhyUrlisGH6T+t0iePtmEbjXSAku0bhA9Qp4a/vyG3WPQyyDmNEI1a1V1TSBKMHtfgRNbcOJ8VAg01ZtZyG7NT8enPFLYP8gorPcOiTzRc6/7TdgaYST0JQs9OmgtD/+PbHb7np31t18aG332A/+APvNULg3GVc+kbfVtnionhWnPrK4PG0BtDAkwLL66K+mx36hSlKbWv9rH2Dl3NQSchcBZl28EXMFtSW7akEzWej2vM1DS8cJLwu6cgdMXBcKXErrjzcs8s6NepHFB0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cbba440-2b55-4807-9355-08dc1bf71f3e X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 09:38:57.5711 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Z3qCOUGKpckk7EjeQloT3nAusHBMxgpvSESKwSYNHP0UI2hC2qcyo0VKsvlMwMfLgq6H1wy7SzqjJn9brRb/aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6548 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-23_04,2024-01-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=822 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401230069 X-Proofpoint-GUID: lk7CWiZbQ4Zuj4JDvjAr58QeoD1O8Dsf X-Proofpoint-ORIG-GUID: lk7CWiZbQ4Zuj4JDvjAr58QeoD1O8Dsf X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: A review comment on the SCFI V4 series was to handle ginsn creation for certain lea opcodes more precisely. Specifically, we should preferably handle the following two cases of lea opcodes similarly: - #1 lea with "index register and scale factor of 1, but no base register", - #2 lea with "no index register, but base register present". Currently, a ginsn of type GINSN_TYPE_OTHER is generated for the case of #1 above. For #2, however, the lea insn is translated to either a GINSN_TYPE_ADD or GINSN_TYPE_MOV depending on whether the immediate for displacement is non-zero or not respectively. Change the handling in x86_ginsn_lea so that both of the above lea manifestations are handled similarly. gas/ * gas/config/tc-i386.c (x86_ginsn_lea): Handle selected lea with no base register similar to the case of no index register. gas/testsuite/ * gas/scfi/x86_64/ginsn-lea-1.l: New test. * gas/scfi/x86_64/ginsn-lea-1.s: Likewise. * gas/scfi/x86_64/scfi-x86-64.exp: Add new test. --- gas/config/tc-i386.c | 88 ++++++++++--------- gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.l | 32 +++++++ gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.s | 13 +++ gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp | 1 + 4 files changed, 93 insertions(+), 41 deletions(-) create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.l create mode 100644 gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.s diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 51166ef3f02..7810e1de40d 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5666,6 +5666,8 @@ x86_ginsn_lea (const symbolS *insn_end_sym) ginsnS *ginsn = NULL; unsigned int base_reg; unsigned int index_reg; + unsigned int src1_reg; + const reg_entry *src1; offsetT index_scale; unsigned int dst_reg; @@ -5678,47 +5680,7 @@ x86_ginsn_lea (const symbolS *insn_end_sym) GINSN_SRC_IMM, 0xf /* arbitrary const. */, 0, GINSN_DST_REG, dst_reg, 0); } - else if (i.base_reg && !i.index_reg) - { - /* lea -0x2(%base),%dst. */ - base_reg = ginsn_dw2_regnum (i.base_reg); - dst_reg = ginsn_dw2_regnum (i.op[1].regs); - - if (i.disp_operands) - src_disp = i.op[0].disps->X_add_number; - - if (src_disp) - /* Generate an ADD ginsn. */ - ginsn = ginsn_new_add (insn_end_sym, true, - GINSN_SRC_REG, base_reg, 0, - GINSN_SRC_IMM, 0, src_disp, - GINSN_DST_REG, dst_reg, 0); - else - /* Generate a MOV ginsn. */ - ginsn = ginsn_new_mov (insn_end_sym, true, - GINSN_SRC_REG, base_reg, 0, - GINSN_DST_REG, dst_reg, 0); - } - else if (!i.base_reg && i.index_reg) - { - /* lea (,%index,imm), %dst. */ - /* TBD_GINSN_INFO_LOSS - There is no explicit ginsn multiply operation, - instead use GINSN_TYPE_OTHER. Also, note that info about displacement - is not carried forward either. But this is fine because - GINSN_TYPE_OTHER will cause SCFI pass to bail out any which way if - dest reg is interesting. */ - index_scale = i.log2_scale_factor; - index_reg = ginsn_dw2_regnum (i.index_reg); - dst_reg = ginsn_dw2_regnum (i.op[1].regs); - ginsn = ginsn_new_other (insn_end_sym, true, - GINSN_SRC_REG, index_reg, - GINSN_SRC_IMM, index_scale, - GINSN_DST_REG, dst_reg); - /* FIXME - It seems to make sense to represent a scale factor of 1 - correctly here (i.e. not as "other", but rather similar to the - base-without- index case above)? */ - } - else + else if (i.index_reg && i.base_reg) { /* lea disp(%base,%index,imm) %dst. */ /* TBD_GINSN_INFO_LOSS - Skip adding information about the disp and imm @@ -5732,6 +5694,50 @@ x86_ginsn_lea (const symbolS *insn_end_sym) GINSN_SRC_REG, index_reg, GINSN_DST_REG, dst_reg); } + else + { + /* lea disp(%base) %dst or lea disp(,%index,imm) %dst. */ + gas_assert ((i.base_reg && !i.index_reg) + || (!i.base_reg && i.index_reg)); + + index_scale = i.log2_scale_factor; + src1 = (i.base_reg) ? i.base_reg : i.index_reg; + src1_reg = ginsn_dw2_regnum (src1); + dst_reg = ginsn_dw2_regnum (i.op[1].regs); + /* It makes sense to represent a scale factor of 1 correctly here + (i.e., not using GINSN_TYPE_OTHER, but rather similar to the + base-without-index case). */ + if (!index_scale) + { + if (i.disp_operands) + src_disp = i.op[0].disps->X_add_number; + + if (src_disp) + /* Generate an ADD ginsn. */ + ginsn = ginsn_new_add (insn_end_sym, true, + GINSN_SRC_REG, src1_reg, 0, + GINSN_SRC_IMM, 0, src_disp, + GINSN_DST_REG, dst_reg, 0); + else + /* Generate a MOV ginsn. */ + ginsn = ginsn_new_mov (insn_end_sym, true, + GINSN_SRC_REG, src1_reg, 0, + GINSN_DST_REG, dst_reg, 0); + } + /* TBD_GINSN_INFO_LOSS - There is no explicit ginsn multiply operation, + instead use GINSN_TYPE_OTHER. Also, note that info about displacement + is not carried forward either. But this is fine because + GINSN_TYPE_OTHER will cause SCFI pass to bail out any which way if + dest reg is interesting. */ + else + { + gas_assert (i.index_reg); + ginsn = ginsn_new_other (insn_end_sym, true, + GINSN_SRC_REG, src1_reg, + GINSN_SRC_IMM, index_scale, + GINSN_DST_REG, dst_reg); + } + } ginsn_set_where (ginsn); diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.l new file mode 100644 index 00000000000..f4629f37fe1 --- /dev/null +++ b/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.l @@ -0,0 +1,32 @@ +GAS LISTING .* + + + 1 ## Testcase with a variety of lea. + 2 .text + 3 .globl foo + 4 .type foo, @function + 4 ginsn: SYM FUNC_BEGIN + 5 foo: + 5 ginsn: SYM foo + 6 0000 488D05FE lea -0x2\(%rip\), %rax + 6 FFFFFF + 6 ginsn: ADD %r4, -2, %r0 + 7 0007 678D4C18 lea -0x1\(%eax,%ebx\), %ecx + 7 FF + 7 ginsn: OTH %r0, %r3, %r2 + 8 000c 678D4C58 lea 0x55\(%eax,%ebx,2\), %ecx + 8 55 + 8 ginsn: OTH %r0, %r3, %r2 + 9 0011 678D0C1D lea -0x3\(,%ebx,1\), %ecx + 9 FDFFFFFF + 9 ginsn: ADD %r3, -3, %r2 + 10 0019 678D0C1D lea -0x3\(,%ebx,\), %ecx + 10 FDFFFFFF + 10 ginsn: ADD %r3, -3, %r2 + 11 0021 678D0C5D lea -0x3\(,%ebx,2\), %ecx + 11 FDFFFFFF + 11 ginsn: OTH %r3, 1, %r2 + 12 .LFE0: + 12 ginsn: SYM .LFE0 + 13 .size foo, .-foo + 13 ginsn: SYM FUNC_END diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.s new file mode 100644 index 00000000000..1861d069f39 --- /dev/null +++ b/gas/testsuite/gas/scfi/x86_64/ginsn-lea-1.s @@ -0,0 +1,13 @@ +## Testcase with a variety of lea. + .text + .globl foo + .type foo, @function +foo: + lea -0x2(%rip), %rax + lea -0x1(%eax,%ebx), %ecx + lea 0x55(%eax,%ebx,2), %ecx + lea -0x3(,%ebx,1), %ecx + lea -0x3(,%ebx,), %ecx + lea -0x3(,%ebx,2), %ecx +.LFE0: + .size foo, .-foo diff --git a/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp b/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp index 2b291800b65..d32cb290d92 100644 --- a/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp +++ b/gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp @@ -26,6 +26,7 @@ if { ([istarget "x86_64-*-*"] && ![istarget "x86_64-*-linux*-gnux32"]) } then { run_list_test "ginsn-dw2-regnum-1" "--scfi=experimental -ali" run_list_test "ginsn-add-1" "--scfi=experimental -ali" + run_list_test "ginsn-lea-1" "--scfi=experimental -ali" run_list_test "ginsn-pop-1" "--scfi=experimental -ali" run_list_test "ginsn-push-1" "--scfi=experimental -ali" -- 2.43.0