From patchwork Wed Oct 30 22:51:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 99855 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 7E88F3857707 for ; Wed, 30 Oct 2024 22:53:00 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id C4D093858D3C for ; Wed, 30 Oct 2024 22:51:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4D093858D3C Authentication-Results: sourceware.org; dmarc=pass (p=reject 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 C4D093858D3C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1730328696; cv=pass; b=qaaXiaLiFpoY8Yp/aBCAJiQt5EHYLXmjU/bqxPa/O57xgD9JnP3+DmxgLuX8mZ+BWhJ5DG8GMQJ1OwRTF6jqBrSP/zoMNigTfXJExWLVKZHiWQuXipEo18h3ZHGGudPphjt141SIRGRpUo7sqzQrzwKT0HgTk2sEM+qpkrYDhu0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1730328696; c=relaxed/simple; bh=mu6WXYETcQDtD/dvR/LG+XJjit3v5RIhnbVVKNoSU0E=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=umN5iK/vHYgjclfgBZ1dbjZ4dBU+rQNcKR9yuEwPuCdTEVsjC9LYP1IRa44SRupRcFOkwnAdmyXn1hVSCcDYDbWk131k6k9+rJzFaNCNAmc6cVkBs1aL9QoQc/79wrasYCs8Hnsle5rNtamojY5jtCjhewEawpzTx4CO5GK+Qt0= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UJBXSP005140; Wed, 30 Oct 2024 22:51:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=xDlKRowNTpnnTokNzCh+scT3x1Y3rIQYEGGc1/HpbvU=; b= hLecc/atidhbWApumMyRah5MitMVxsR758w3VwU6qIHRsrmQUyBL8u+k8dCJa44T /uszFrvKtf0iDab1ub0x0ZR/tRls6ZoRxEeffxeeT5x2BhBB38ehdAYqIyGsZBcs h5fzC9bS3InAQUx/dwZR/Wcm3TMY6Jf6D6HjCTIe94XYXgS30mYBqOimXOeEBGG3 TA6fkQLXAB5vsMvP17F5jbU3RmN3Kn9LDBgHkHHo2A+cqsIf13buSJGSMwqy/197 VE8EGBpwRMkDB7g4V9ryljCyzv8nzrANNzBw7BHDhq9n19CdoJsndPV/jgsA3eRW rYQlTCcGBMcGYefFHCpALA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grgmharh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 22:51:30 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49UKfoxi011891; Wed, 30 Oct 2024 22:51:30 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnaeq40j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 22:51:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pcWzPAGt0dDnUG8qHcofnvoADJ+QEmlNalKtIL9iDGyvtL97jlOGoKgSo/QdLKP743S/AmnI5EtrCjXdOUDVepJxOyUnCQ6lDYSiuhqa5h5rruxPA+zFFxNQoliCUVPSSdMzkpyOIbt1i22XW363UYdwQoDa9N+1HuX0b7JH5gi39v6/A+6He1HEkQvJBs0BG/0AGTg3MUOs4ZfXdJYLj8hS1JbnzOETLKodd6zOIZ2F8qPDYCCGJcZI7nrJC619pGYGa4/yCS3FLgZT0ouNG5U4mQmVNRv3PMrTtKfwhzf7YZvqXxIwq+ux8IO77tHGJevA6P262mCSKBh/rX5Fmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xDlKRowNTpnnTokNzCh+scT3x1Y3rIQYEGGc1/HpbvU=; b=qznoGOpboNzYA50KGYBcvN11TZgsRR20pjCXoEfGdj/H9nbfAd+/I9t3ppFA4XRGTC9S8WUezL2Bj6xBqEgKcqywjTMNPzlXybGYMN5T45o1htdpV33KGh0ElYjDyKAUhquIWV7HNmUsB3qA1jOoN1o1EiyPL6OwM68K3IHg1IYrMduDWRO7f6W/Qb+t0GOFl6dkC5sR7nF1Q7CIyq+XpShHUPaFDTM4/SstHSamwThLPcZMfAXd938J9NfLEVhyp1v5w9bc4fsDE/7Exd9q8kdgfUpxAvSrxd4ce4KvMGIHroHCoJa97kiiaG9TZFBZt+qdlaajvs09Vkr8y+pCYg== 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=xDlKRowNTpnnTokNzCh+scT3x1Y3rIQYEGGc1/HpbvU=; b=F/58ND7XEyI9PE6P07D5oqQHWG+ZrVX7EgqfzWfGhrQHlJdtNlRwbWb1hydA5qSxDURx6o5LTbox8bIgRuy5+I6ZN6c/DeVimgQKGGMOXUVfkSur7w4k4dJFmNwHftBKWjNoJjIKSfBqnSr3uTYvXD1j35KrqODZJtBJLHXpkF4= Received: from BN6PR1001MB2180.namprd10.prod.outlook.com (2603:10b6:405:32::23) by DS0PR10MB7901.namprd10.prod.outlook.com (2603:10b6:8:1a8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 22:51:27 +0000 Received: from BN6PR1001MB2180.namprd10.prod.outlook.com ([fe80::34e:408e:c7a1:2446]) by BN6PR1001MB2180.namprd10.prod.outlook.com ([fe80::34e:408e:c7a1:2446%4]) with mapi id 15.20.8026.020; Wed, 30 Oct 2024 22:51:27 +0000 From: Indu Bhagat To: binutils@sourceware.org Cc: Josh Poimboeuf Subject: [PATCH 2/3] ld: fix wrong SFrame info for lazy IBT PLT Date: Wed, 30 Oct 2024 15:51:07 -0700 Message-ID: <20241030225108.3377357-3-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241030225108.3377357-1-indu.bhagat@oracle.com> References: <20241030225108.3377357-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4P222CA0016.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::21) To BN6PR1001MB2180.namprd10.prod.outlook.com (2603:10b6:405:32::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR1001MB2180:EE_|DS0PR10MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: ccb81edc-be51-41db-59e3-08dcf93562ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|10070799003|366016; X-Microsoft-Antispam-Message-Info: eVPHweDht6GsTwQY29ySvUbMlyozmFBUlz1sxOMrGJ+savQyidmpLASpYjQPA0SIQHZChbTIz8rF8M+Mc0jZrZww0XKoFicvfzlvSIk5yjQKTFShm6adtGaWo5Ne3t2H13JSep2/03MPJslgVPHbQmoN+uEvDLTzqcMzEKk7eNZ9lmupTFQMQzPmv6mp2BTVgYo/P9tU8/ZP33uZEXXq7Npl82E9UOlvTGBxBo/uU5quAlXPeSNcgqdDd9dO/XEq2mZ4ZPbK2ioh8wMlauzHoltG36GGtk9bOxNVQA5cCSIVTEr2MtmcAOMx/wzmq76FynJ6wz4sfwCcqmgta5/CjWuzDt5Rb3wG47rW1CZYOw9yRynfmt+LtIxpqQ2fWuYrDwFn32iY10q6dZ+BA4WCDgn1qDXDrfnYO6XMHgsmLrbYLr2AzkkszyaiEns1C6i2WKNmCMGPpRYukXkeY0gi58nJi3X6r7dBDkWl3H36gRg52dK2JbsV4py9RjD8fiqEHNqo6GjXpcR4HhElE7h8P1GcQeW1TWP5Kxd30CeYoopDOV5zJWL3khRxrjZYOaSESmS08vEWVtpIkwy6dMlQSIr46qMIQfnMyPX5mFEfGbe1JzeAJFfE8cE5URCPqZqZhZfLCxVsSFeP6A04r/7iLjxXBe1ZHbcvfslSNomy8+2UKakGaqMMmBydq2dL7vCjGqLrITaSdLG90KhfDbtZX3zRX7bPDmUrnvaImdEUK/orZmG7AdLogC1ESweOEC1jQpRRiXOjccaDhjufOAgngSeT/M85YS6CThqF2hz4Lj3AXB6EFSiOE1qqHAT7PVHyDagyXt1ZpJPbz6lZNO4UcIUSGfYos0uqSlB58ZZaju0YGG6MZceyFQvadu6KpsQa0a7oqLmYKhne6yKlTo4/hkXMNPtlQn6cDH8yjYX0z3wvbdAIwOlpnzi4U/bxEmnHO4V/CIemjcbkPTtM1xylE4yw3uJcbbFXrxP5SBqZqGQ9DbYySlKUtwhg5qDoQf9NtJI/2RAXMsFx32GloRwPz3QWgteNiY7kpow60yQcM4hBr7thJlbttszZzDTENZ+T4wqNYGXmMthc0OmpYMf5wEouBiw6PEoJINsnRQ8rL4UOYG0TjEgdGD8gONyeMMDAAYeIfMo8FxGFSLc49SljWItrLkQQ7fhfktjxx4AGaJmTZnd+XOIh78xWlI8VJEg4U229rvBaFnxpOX9UN7ydY0P0jMM9cUTc+JX2zwebGILwt8W4DBp2IlGIJT5R2cLQUmHZhkMfnD998ZuKnOaFuq9+8CrrumnSbQXK9JKt0Wg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR1001MB2180.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(10070799003)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GgP4pr6vf6pSuXVtQJsHWZnRRvQHe2T7dMWiaPZxwCKaCvnoIr+8b+sAAHiBGwFMLWTPChQCP1PW8eqn2MUnFgqcN+/hf/6FciXhpf5za6Bb92KaHytCSEUSyPpDvQ+14PYEvZmBblSV/gY473SstSnJvLPzsFZGx8qMq5L4/lJvPEEvmkBInuwCUj5zv7uTr12xS9z3tH+WNB1s7Q07EiTjzHP8p0j9vV1w9zaXGI9M/qD48W+emNJnO7qQI+VlB3HDZyxOkQ56j4e36Xih+EK8RxG4BWLC3zX///026mhw98Rl2thOjwxtKwu3Wb+SLCPmZ6KZb+yge9E03spZyeGmR0piZ6coMY2no6o4F96/mr/Ykzn5DvkGdPD0Vgq+9ZeOaS0p6dfZ+ZTYA+w34ly+hSGt5kmcNiGi+KhsoUDFNIHj3ic9oTfjWrHtzT/sGMafEITwLYWLB1An5rvfcEMNnQopmfWOKhqky77TNhUZAwcIwaGH1fSfNO0L3QoJH9Sn1UsBtuHQqxQyZkoLKU4ChqSG6XrwNL6Cf099ZYHJhXPU4bRcKMB9kpgprH9u87vOORS9X8LBzZDAzqffbsMbPeiFVQK/dXpTNBU9MbEzf7yT3Cdzw2ZKLiyUvpuJijw40mPZqrS4e9WKy5bBjGJtVfCuBX3hxg+hwf/hGDGOBpXBazfv1j3nyjkDUG8BAF2DKVXOsf38IPXJbT98kxM+JxidNafnPRZ20atmCZojuNh0I8qsgk4tOH/UhL8XVek6coZDCpbOR8KUM2D+sFPHi5CfRczXxq7MLqrymHo6nuqSUW3kE3ugtPe/Lu5118V7yQYnB+QLCh1gU0u4rdkIlNCpWXHdF2vA1gMeJP43NSPnzJDdlM3jY2jdCSh59tOuvAtqsCXSgUtgZc4zQb+JiHJUOy4a5BcqcJ1RV9X3wsIqSPWactD2V4A47pVdrtKoFcgzcHEqgPd3TO6MFgHuOjwdIPXYpvl9QoewtQ//wdtf4ocakMvl64nyteYPxiSvPwekg2nUojeLoknJyHxSbMs5gJ1yLBHJFe0yn/HdxeOUWxlISr5jKTNUT8Y3qxOgPZZoQbynKjHz8SkFS61WNGT5YmciMG2vhOofu911/Y7XLDYhAawehhk60JxI4ovHgrdwxyZQ4c9MB/0a7hjcgIl5aB2pA2u+eGyVQNnk/IsAquhH8coImLZxoqDHR5YvfNBGfbDWXdbuFZbw4fh+P1V2R4Jr7DLjRv855Ylzqrb/0Uzow3z4K8dC1ifPGIPs5oLcARAdrmCGE+qaCW+9X052Hg1BFjMToQ2/pe49DP6g/9OPa3qOWUU1sgK3jOk24jlvKCPw52HHaO8R92gW2JBSr18ziA1480B8hETcIum3CKzmuL2PBcVSxvtGrmrNPkg2jpbIclUS1tFd0GEalUQRKp7XIAyRb0o9Pdy9fYDtsrfIwHtNfbeE5gUTrmH8BS1NTnIWEO1BJBcEe60NU8k3bHl9SHoSSYbvlePc6lOkshhbpes2yHKso/Ups79mQZE+pA+wXcVNZ+Dj90pByqMG4GYu+yYc0GIneURU+R+ZvrpoXUVEdzCb9AO4NGUPwoa5aoRP6ggqxKl1cE21JRgxI55rpMgf08p9pDY= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MUcU0rgYHqmExsZQGo3UZYB5vd7TPU5X2Jfyhc3BIBrF56VTkCLbaymi/7Xtf9LAgMSR5h33jbUzNfdy45tPeLrHetummJ506UPI0cdDnjMRO1FxBbO3PizDGj97ujLl8Fo8AA75moCzHpn+BSONUUQQOlAwNzjxJMJdDIZfeL84rlHMB55fchti96Rm4Ewb1X0iPK/oiM5u6EX+uB6R93YUKVs7403kVX8mtnPy6pB7/8nxiLfPppCPFzfizr7hc64ypitIWz5a9woqNvwOkgZ+pdwYZeHvXZ/T1SNNk/O/ywCdGWA+k5LvRFsxpAgoCI9g8V7CtYU2p+wWQ1bumWo5o/nVRWrNekSDi+dhic4TwpGteQwu3G3E+xARt7skyg7ZFjcIKTDfBDmjB4htGNz4v2G8cyenuAC6pnSKPAyD+WirfwSvnqUC5D0y7Geq+xOWtYqBDzEMdXr1OuvRgVbqYP+7odv5RLNxO5OHzp4KzqueT+3ayF8FvEC8e9coLSFsiaGt5otPECJco2oagU9a56XqDXN13VWa2dDr8ivKxSFiXCfQmw4wK6GSRIuH4jBYEF7jPDw1LW3J6WqkT/7ShWjj9jo8ujXrxGxdjgI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccb81edc-be51-41db-59e3-08dcf93562ea X-MS-Exchange-CrossTenant-AuthSource: BN6PR1001MB2180.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 22:51:27.0499 (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: UKieFGQCJEETcL4ScsfzxoG5AEtRxggdENxv8PcbR1F8wghjEOj+LdWzdWAu+NdSwdSNdBFETQO/Fg0SO7UWkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7901 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_14,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300177 X-Proofpoint-GUID: VgwywLYs5ggaSDrdsH49e9f9vvWK_23P X-Proofpoint-ORIG-GUID: VgwywLYs5ggaSDrdsH49e9f9vvWK_23P X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 From: Josh Poimboeuf Fix PR/32296 sframe: wrong SFrame info for pltN and .plt.sec for -z ibtplt The x86 psABI defines a 2-PLT scheme for IBT which uses .plt and .plt.sec entries. It was observed that SFrame information for .plt.sec section was incorrect. The erroneous assumption was that SFrame stack trace information for .plt.sec with lazy binding is the same as SFrame stack trace information for .plt with lazy binding. This is corrected now by initializing a new SFrame PLT helper object elf_x86_64_sframe_ibt_plt for lazy PLT with IBT. Add a testcase where linking with -z ibtplt generates .plt.sec entries and ensure correct SFrame information for it. ChangeLog: PR/32296 * bfd/elf64-x86-64.c (elf_x86_64_sframe_ibt_pltn_fre2): New definition elf_x86_64_sframe_ibt_plt. Use it in elf_x86_64_sframe_plt. (elf_x86_64_link_setup_gnu_properties): Lazy IBT PLT entries are different from lazy PLT. * bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for SFrame for IBT PLT. * ld/testsuite/ld-x86-64/x86-64.exp: Add new test. * ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d: New test. --- bfd/elf64-x86-64.c | 34 +++++++++++++++++++---- bfd/elfxx-x86.c | 29 ++++++++++--------- ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d | 33 ++++++++++++++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 4 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 4330bbd1648..abbebbe92b4 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -906,6 +906,14 @@ static const sframe_frame_row_entry elf_x86_64_sframe_pltn_fre2 = SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info. */ }; +/* .sframe FRE covering the .plt section entry for IBT. */ +static const sframe_frame_row_entry elf_x86_64_sframe_ibt_pltn_fre2 = +{ + 9, /* SFrame FRE start address. */ + {16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* 12 bytes. */ + SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info. */ +}; + /* .sframe FRE covering the second .plt section entry. */ static const sframe_frame_row_entry elf_x86_64_sframe_sec_pltn_fre1 = { @@ -930,7 +938,7 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_plt = { &elf_x86_64_sframe_null_fre } }; -/* SFrame helper object for lazy PLT. Also used for IBT enabled PLT. */ +/* SFrame helper object for lazy PLT. */ static const struct elf_x86_sframe_plt elf_x86_64_sframe_plt = { LAZY_PLT_ENTRY_SIZE, @@ -942,9 +950,25 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_plt = /* Array of SFrame FREs for plt. */ { &elf_x86_64_sframe_pltn_fre1, &elf_x86_64_sframe_pltn_fre2 }, NON_LAZY_PLT_ENTRY_SIZE, - 1, /* Number of FREs for PLTn for second PLT. */ - /* FREs for second plt (stack trace info for .plt.got is - identical). Used when IBT or non-lazy PLT is in effect. */ + 1, /* Number of FREs for second PLT. */ + /* Array of SFrame FREs for second PLT. */ + { &elf_x86_64_sframe_sec_pltn_fre1 } +}; + +/* SFrame helper object for lazy PLT with IBT. */ +static const struct elf_x86_sframe_plt elf_x86_64_sframe_ibt_plt = +{ + LAZY_PLT_ENTRY_SIZE, + 2, /* Number of FREs for PLT0. */ + /* Array of SFrame FREs for plt0. */ + { &elf_x86_64_sframe_plt0_fre1, &elf_x86_64_sframe_plt0_fre2 }, + LAZY_PLT_ENTRY_SIZE, + 2, /* Number of FREs for PLTn. */ + /* Array of SFrame FREs for plt. */ + { &elf_x86_64_sframe_pltn_fre1, &elf_x86_64_sframe_ibt_pltn_fre2 }, + LAZY_PLT_ENTRY_SIZE, + 1, /* Number of FREs for second PLT. */ + /* Array of SFrame FREs for second plt. */ { &elf_x86_64_sframe_sec_pltn_fre1 } }; @@ -5678,7 +5702,7 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info) { init_table.sframe_lazy_plt = &elf_x86_64_sframe_plt; init_table.sframe_non_lazy_plt = &elf_x86_64_sframe_non_lazy_plt; - init_table.sframe_lazy_ibt_plt = &elf_x86_64_sframe_plt; + init_table.sframe_lazy_ibt_plt = &elf_x86_64_sframe_ibt_plt; init_table.sframe_non_lazy_ibt_plt = &elf_x86_64_sframe_non_lazy_plt; } else diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 0d83ce57d4f..cb90f688b6f 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -1831,7 +1831,6 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, struct elf_x86_link_hash_table *htab; const struct elf_backend_data *bed; - bool plt0_generated_p; unsigned int plt0_entry_size; unsigned char func_info; uint32_t fre_type; @@ -1845,14 +1844,11 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, unsigned plt_entry_size = 0; unsigned int num_pltn_fres = 0; unsigned int num_pltn_entries = 0; + const sframe_frame_row_entry * const *pltn_fres; bed = get_elf_backend_data (output_bfd); htab = elf_x86_hash_table (info, bed->target_id); /* Whether SFrame stack trace info for plt0 is to be generated. */ - plt0_generated_p = htab->plt.has_plt0; - plt0_entry_size - = (plt0_generated_p) ? htab->sframe_plt->plt0_entry_size : 0; - switch (plt_sec_type) { case SFRAME_PLT: @@ -1860,7 +1856,10 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, ectx = &htab->plt_cfe_ctx; dpltsec = htab->elf.splt; - plt_entry_size = htab->plt.plt_entry_size; + plt0_entry_size + = htab->plt.has_plt0 ? htab->sframe_plt->plt0_entry_size : 0; + plt_entry_size = htab->sframe_plt->pltn_entry_size; + pltn_fres = htab->sframe_plt->pltn_fres; num_pltn_fres = htab->sframe_plt->pltn_num_fres; num_pltn_entries = (dpltsec->size - plt0_entry_size) / plt_entry_size; @@ -1870,12 +1869,15 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, case SFRAME_PLT_SEC: { ectx = &htab->plt_second_cfe_ctx; - /* FIXME - this or htab->plt_second_sframe ? */ - dpltsec = htab->plt_second_eh_frame; + dpltsec = htab->plt_second; + + plt0_entry_size = 0; plt_entry_size = htab->sframe_plt->sec_pltn_entry_size; + pltn_fres = htab->sframe_plt->sec_pltn_fres; num_pltn_fres = htab->sframe_plt->sec_pltn_num_fres; num_pltn_entries = dpltsec->size / plt_entry_size; + break; } default: @@ -1897,7 +1899,7 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, /* Add SFrame FDE and the associated FREs for plt0 if plt0 has been generated. */ - if (plt0_generated_p) + if (plt0_entry_size) { /* Add SFrame FDE for plt0, the function start address is updated later at _bfd_elf_merge_section_sframe time. */ @@ -1934,16 +1936,17 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, plt0_entry_size, /* func start addr. */ dpltsec->size - plt0_entry_size, func_info, - 16, + plt_entry_size, 0 /* Num FREs. */); sframe_frame_row_entry pltn_fre; - /* Now add the FREs for pltn. Simply adding the two FREs suffices due + /* Now add the FREs for pltn. Simply adding the FREs suffices due to the usage of SFRAME_FDE_TYPE_PCMASK above. */ for (unsigned int j = 0; j < num_pltn_fres; j++) { - pltn_fre = *(htab->sframe_plt->pltn_fres[j]); - sframe_encoder_add_fre (*ectx, 1, &pltn_fre); + unsigned int func_idx = plt0_entry_size ? 1 : 0; + pltn_fre = *(pltn_fres[j]); + sframe_encoder_add_fre (*ectx, func_idx, &pltn_fre); } } diff --git a/ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d b/ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d new file mode 100644 index 00000000000..26be4dfc6a0 --- /dev/null +++ b/ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d @@ -0,0 +1,33 @@ +#as: --gsframe +#source: ibt-plt-3.s +#objdump: --sframe=.sframe +#ld: -shared -z ibtplt --no-rosegment +#name: SFrame for IBT PLT .plt.sec + +.*: +file format .* + +Contents of the SFrame section .sframe: + Header : + + Version: SFRAME_VERSION_2 + Flags: SFRAME_F_FDE_SORTED + CFA fixed RA offset: \-8 +#... + + Function Index : + + func idx \[0\]: pc = 0x1000, size = 16 bytes + STARTPC +CFA +FP +RA + + 0+1000 +sp\+16 +u +f + + 0+1006 +sp\+24 +u +f + + + func idx \[1\]: pc = 0x1010, size = 32 bytes + STARTPC\[m\] +CFA +FP +RA + + 0+0000 +sp\+8 +u +f + + 0+0009 +sp\+16 +u +f + + + func idx \[2\]: pc = 0x1030, size = 32 bytes + STARTPC\[m\] +CFA +FP +RA + + 0+0000 +sp\+8 +u +f + + +#... diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index bd7574d6965..0632397bccc 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -547,6 +547,7 @@ run_dump_test "pr32191-x32" if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" run_dump_test "sframe-plt-1" + run_dump_test "sframe-ibt-plt-1" } if ![istarget "x86_64-*-linux*"] {