From patchwork Wed Oct 30 22:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 99854 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 AD7073857BA2 for ; Wed, 30 Oct 2024 22:52:05 +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 BFB933857BA2 for ; Wed, 30 Oct 2024 22:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFB933857BA2 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 BFB933857BA2 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=1730328690; cv=pass; b=epcrMxYjaL8H9BpydPrOyWIZ5uPCFdlOlmPmiTLIo9PN/wgtGTdu87C2ygvw/Dt27DvSozjwgX7AoqIZ6jP/FpXi29YUOdwuP8/cV8jccavsRfYhfTdm4ZOCyJgbN9bscW7rcGRHLBAc46Qp1uksNIMAwHmCQIFt0WLenslCKxY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1730328690; c=relaxed/simple; bh=85vuTURWVWcmnIN6djW7z1/8TRstU113Hv9xKRee/gI=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=vyga7qAHcs77RDIQirSJymvrXox0W9HT1Q3Scpiil4IHL37NoZU2/ZnszRs1b1DHT13G/CKd1VGbZS3VxYjr/zCcTmL6VZQXcdYk5bt01yZqZz4oplyP0iWCiPfVux8y8Dvu9S0rwj6lEbe0v6o5J7lBuF+TJxwgduasSOSUU/c= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UJBcnb004989; Wed, 30 Oct 2024 22:51:26 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=/23DzmzG4bsIEFCgECowFMOaiiDTrvK8b2IgKMg0WB8=; b= oXs3ZwZAYPOI61DeYZhDv6iT/Hq6tRBK0d0VvaixRy+qZ5ryKDPf9+9c/4faQ3sS uJEMVkYQBS6tn5kLp2Krrcm4zTs1swJHj/XYC5RVDPvdfnPXRIkAbVoQ0Nhfpk/A LN40Qc1Fj189y2yG6z+LFraTXW1vmxyWAza/k70uFf2tZacZSfNHouNjyHYIHm+9 d9mOtPIzQWqopn9gc93sDAs/Utsl5hftylUpsN6+HFvjnqWjM/9ghD8jgO6GIr4c 9CTBAMbP5tm3Fn/X7x+G9kmazr9gkDZv96oL8PI20q9AULIlWiSoHR93bTnPT79o 9UORNluIabDOwJvtB6zCCw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc2156g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 22:51:25 +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 49UKxORV011821; Wed, 30 Oct 2024 22:51:25 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnaeq3yj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 22:51:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WO8SUKPWRMdbPPevHj6e3dOmf0IXS1MW04f8RL/d/t9hy0giSXKSakN2Tl0IMSIO3x0UZqCVNvVnG72+Xgyf7iW6on0bwsHA7KcEax26AZpht2Ki2MZB6elXdmMslMM52+zKIhsBpKub4Y7VFQFKWNSezvvSPoquLq8wnMbP+SZdc61l/7ICugyJKnAkWkffJdT/nLiZkcW5/nm0wkbtUMUDOPRkRvqA4aUsiL3Nu8GYwfrya8+jgCw0XEYPRKEohmH4geHvuufdA9ex/P7X16VcMj+9YqLMhjCJPHBFKm4103w4m3c0K4zUFIEhQXwPuWzMSVSKmFVuYhCbXN6yhg== 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=/23DzmzG4bsIEFCgECowFMOaiiDTrvK8b2IgKMg0WB8=; b=OX720TXfHidHjqXYghyUBCTXNiYeDV6/JQES7IGj7PIrrfrvZwHoq489590JJ7bZpb8iqe/2lfHzqZfTDdqwnycc5+JTPeBQC0vxyxOE5v0iBmoAheNli6r7/9Hdr+T9BZx0mm3SYXRXGNGVXvE92k6k2m87nnQuQWgZtDa4Q0WFyDmTGiBSxr8H40G/iED5WtgtW83jT0MnwKiWGrzVcSO1V4w47Y7hDT+4LggV/3C+3DWtK8c2+wZIlhKfRiX0/m56JHxqjGItm5ZO55R1sKR4bGsdKtajSQ8n0cXSm4XO4G6qyWV99nN8sULoDckK8/LxYkxsEBGMailbKci8EA== 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=/23DzmzG4bsIEFCgECowFMOaiiDTrvK8b2IgKMg0WB8=; b=ZihEyOh0ZM+9fwpkqg7V8/rpJzXjtIkVC1ySGEPGkNdvckJM8rZsrm+OpSgBrSYOQ8N5QTxHUN+hrDdpOY8+BIulaGz6fLPNe4VRjeznjL3Ocz5lsXd25DV9Iwa4VxilC9M1M/51kMS5bhWxK2xdVB5ME9DxVfiiCE3ILj8V4aU= 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:23 +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:22 +0000 From: Indu Bhagat To: binutils@sourceware.org Cc: Josh Poimboeuf Subject: [PATCH 1/3] ld: fix PR/32297 Date: Wed, 30 Oct 2024 15:51:06 -0700 Message-ID: <20241030225108.3377357-2-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: MW4P223CA0020.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::25) 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: b37228ae-2b84-443b-dfbc-08dcf9356069 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: 4Y8ZxT0+oBigLfMjvOGkEVGiNfdH4Set5MzXn9qSjaltdbz/T9cx00XXrf3V+McIDqjvZS2QEZonkPSwVgaX2SuTFU25N7esFX17TGmuOm/M0RGI/01OWPNN41OX/xWFSc8ZIHM5v5VsFj+dZcAkJagd1GvZ1CvTVpbXwKNmWCe3hjH59WE3eMzACqgiLo01CBVlN5BovzxPOY4DAdPW6ozGkYDQ5zvFOc9XP0yC3EAi5muCLuFyibT+l1bzd3riesA+goQA4AezJxAX+3huOYPzNz34XMB9FoHOy5Swyka0TKSOs7+XoyqzljJ8KjxOsSxsUnnchQkv/xlhlW1/2a81eOmZCpik5XWxodQ3AHVHHtROHogm7rW/w14CdHGc4d+CJEquXwkj+RneML9YKK07abP+brqWEQLvFqAFsD81x8UAPYUuDkfBpgSAGYp1h1rj5o6WA7WOTQCfHsqBLO8vHB5e/I6C0WFPD7lOfzj6YenjUQ5IQY9BrdxUwsOabE3G/bwJr+JZIq9Zz58wKJnHMLObDgduaoraqRSh3wdpyT+TKHvYOVkHUd9CV4Ya5Nkp6ptkcGjskLC3fOf5ljJTVLSTekmtzX11jXOswDE2rkkOz4ORmWw/FCMcjUJzgbUY0PFxtdW1eSEvOg86kH+ObdD01zlnY1s+bljNjjUnh/9guAdr62zJGcFTNeOd78O8+xlUsdi6dx+2E6/+m7velLkXQX1a9yjtLQeeh38IEhSdtg5KRDLL6yGphyGzW+3a9UaBvrGt4BpEmt34X8NrEDkXyZUseKV3WtXnLH+iaOnbkl9jeQmzxm0TfrSpP0eaTCKxCtmOJIu6KKokxA1NA8Hmyq59Jk4rn0jx9EhIgqz5JrONhBM4aKgzMMYeUBbBS1z+y34sI3mmJSiaZEWNPspS9CQiYh+0SjPdgeI39EkykJ03+bn1HO46h6LckLOe0HeJZQUdDtj9mJhdLkQzVkkpycSsSjpBtfDmP4ILIdSJetay79up4Qd1rNoYumdZBHK7TYW8uqsWEPj+eh/g25jJNEtnxenr7U7PgIGiphZ4Tk8dVzyzMsL9WYgYqcOgl97KkklxzskLC69JYep3IvwkZojjkPBErta+6HIyl34l4kvhcAw47O0UEdiPGvxnCAXaaKZHdcLu4QyFc32BOtNVxEcAhnH0ttbgoGgNzTxKlyn4gtt2W1KDouxLuogsoNu8oGvowBXbPAdHfpmvBbtdVI+wFbGwgi0EG4FkCPvqi3VCf8PniqjfNBz6dXUNAUHZ34fxZ0bzH0kHEYn2yjH0Kb6NbMkqzkb386PEsda12PP5YUmFgdtsGXhW 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: qfM+U2aGXErHPLFAe3EdpX/w5K2Vo3NMjZ5eu6pPAMqy8UkcWMyjoWx21DU1yzC+7S0M1ppJjXEO1S666907ooYvAokeiccFk6rU/lf+hCBZNx25TfYvwe0IJIAhgRSQ3JsdSym8hzWlTfLrT1jZ63baa/L8he2XH88JVSfppJKMkUA4LwU7LT8Vi0Ih0fhuhmMMPK9uyh+newFS1vrxuKDdknhk3ytgwWbVi35Bj+CVMJMglrCSGjskRZb/8s0+YcdiFmqtGVZFoViNDjjxY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iuoY/od7h5cRXLhsEjVhyVB0gQznqSsRK3LKEPymLusKHAdgXEhA1E6jbjy8wTAN0VmFKQozvWl5AWMZ3P50+8tqSV2g+AS62NB+fFvmv81OVcd56Jmwn6xRnmmsPLFUKJeFMYXTVZ0Q3SECZ8l2RK8/bUGBHiOwvapqu9AEVO1bxzg/5zuHkqvs4xNa02He+0eoqrMZjbKxND4Y+Cv1ItSjM63439WZSL37mqmxe0uAe4Tqf1Z0Fj7mra7UWNa/ksZMRnAKiNaubqB3Gg8= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bXGkWmjGL4CdBwPr5vFzDSoowbZsY+lkfBVnZflRGfEDKFsd2s9mTyAj9vAE8amAbiNXzQ4Ln9DSAahoVAUcvZq9CJNNfxSQwhhI3wZcpujSgELjkZ//jPyqioqZejkTWFI+B+d8etsSCByM3ajmfXXWNsQdflwh+YQh4SjcBkWiUievapxInhXSRsFnWvTViLxQCAPnDpNA2TY4kUEhCp1jYbN4cjfc4AGfQtqYJRjK/KR8r4jiuZJE8JyJzjSifA5X0RErECbWmPpW1/rVY849PlgUolS0hUepOR62FYT6AMFNZCZgouxqf+Zbj0ht61oMFpCR5jZX6gpnfFRncpy2E7wCkMnt5iu9+NeErbgOExpppMdQywK7M/3cJTME2wJQ66bE+rRcZQierDOfUiys9McICWP17E4k/qVQwV9D6UoaJZmioy4isgBD7XoUfVT9Yzv5i+5B4yTIXKR+IhH/OGJpDrEYgJez+neeTs5PHYdIzZtQlzCeAD1XbTbUZW1rXRojrZwCenPIZsRNT7FlvhxiouLzlziAWuVU7N+U0X/ZiByvUfgkG8k0sv+D1KY9nCSURyf5bihuBSF6ai6dv2DJ7iK+9A2Mc5lVKK4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b37228ae-2b84-443b-dfbc-08dcf9356069 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:22.9304 (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: EHWXtWcQFhKNP7UbJU6Se6zzRDCC55CtrrYk6kgCKQL/DfWlzpQZOHQykkCNCO9/TLZYVfaJsi5wm265OKDuLA== 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: FWOfepvvQPmLquActUD_wYA8ZTd8K9Wx X-Proofpoint-ORIG-GUID: FWOfepvvQPmLquActUD_wYA8ZTd8K9Wx X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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 When _creating_ SFrame information for the linker created .plt.sec, the code correctly checks for presence of .plt.sec. When _writing_ the SFrame section for the corresponding .plt.sec, however, the conditionals were wrongly checking for splt. This was causing an assertion at link time. This issue has been known to affect glibc build with SFrame enabled. No testcase is added just yet. A later commit ensures correct SFrame stack trace information is created for .plt.got. A test case (where only .plt and .plt.got are created) is added then. PR/32297 sframe: bfd assertion with empty main on IBT enabled system ChangeLog: PR/32297 * bfd/elfxx-x86.c (_bfd_x86_elf_late_size_sections): Check for plt_second member not for splt. --- bfd/elfxx-x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index dd951b91f50..0d83ce57d4f 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2680,8 +2680,8 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, _bfd_x86_elf_write_sframe_plt (output_bfd, info, SFRAME_PLT); if (htab->plt_second_sframe != NULL - && htab->elf.splt != NULL - && htab->elf.splt->size != 0 + && htab->plt_second != NULL + && htab->plt_second->size != 0 && htab->plt_second_sframe->contents == NULL) _bfd_x86_elf_write_sframe_plt (output_bfd, info, SFRAME_PLT_SEC); } 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: eVPHweDht6GsTwQY29ySvUbMlyozmFBUlz1sxOMr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8rL4UOYG0TjEgdGD8gONyeMMDAAYeIfMo8FxGFSLc49SljWItrLkQQ7fhfktjxx4AGaJmTZnd+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/dXpTNBU9MbEzf7yT3Cdzw2ZKLiyUvpuJijw40mPZqrS4e9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UZYB5vd7TPU5X2Jfyhc3BIBrF56VTkCLbaymi/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*"] { From patchwork Wed Oct 30 22:51:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 99856 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 7BDE13857707 for ; Wed, 30 Oct 2024 22:53:05 +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 19C1A3857BB6 for ; Wed, 30 Oct 2024 22:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19C1A3857BB6 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 19C1A3857BB6 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=1730328698; cv=pass; b=uH4B7ojSTFOp1IVs+2Na9Ej0H8Bwm6ZWdnydX48S8FsO5zGnjAm0jiLe/RzandMR7xP5K4jXg1TUkXXgQ2ho7wWX4Gt7mM4udwTDopLVreUwtVgwbMIXn/lPoSV2fi5a4NWnMFw1wWONLTv/V6s121pdjArjPhvoCeAiW3hpXqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1730328698; c=relaxed/simple; bh=B4OqJ3t/Tph3c8jOT9wVy2EBTrQPRgGzrP8Kd0C/6u0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=A5FvUg8kLWI7J1sUkouOr8LD963MZIhdN/HiUvxacVyMjzC+NBgfBAI5iecpKrxa7m9UDgt04NoDNdPD/pkC08YGB52dbeX1bXxVCPVTI2H+PtmrQgiVoRAOc76ETp4bA446nHkd3LH8n5Vk6Lu2okHKTyTUSHIHYltrPKeUkEg= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UJBbw3004937 for ; Wed, 30 Oct 2024 22:51:35 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=PPALuDGJNM9y8Ug1H6CaIOEuYePdXKcN2UxGaHcWmjI=; b= iIeaZv5exJu7YhsszZRDdhUXGML2GLeCzAK4itvc3096T6Zs26Wsu/OF6/1oGLRB gpeo9RfHyA+yQFpUyFiA9p+gyQgdVs16LKUNBku35A2WUOf1VG1httJezRqjkuZ4 7UqGyLrl6tbR6JjF+vw5abqnn9eVpT5QdXt4ilteXpK9btVxU7ehGzhdOAkXLp21 wZ5h4lGAa2wmN0Qc6hEz9nkU+/IWMKTMtCC0qM7Wrvjk8pvTul7NQPa7xL45/z4d AYJ4qvH+z/G9YDI/X8sjoq+j5imRmCtj8ZtbV/3MbnJ9BvUG4QKmzp23/uqDZDuw y/FWlQacDMmbLUahugtNSg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc2156s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Oct 2024 22:51:35 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49ULDdtc004792 for ; Wed, 30 Oct 2024 22:51:34 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42jb2wbe5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Oct 2024 22:51:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d+gX6uEJesNpwDfrRZhzJiZKTiYNSk6JUxhnsadIlhnpSnQ087Y1S5MzEFp2PYwOISzfKTsj5PPhoi6itxhibVLy4I5wF9oPmek9LjVqkG8+u6IhWzt7+wub8JgL/mWd2BXnyt/gJIRWDqf14edwhacILm3GmyJQRu/1QweGpDb52e1jfGl4lQ5OuamNp5zXYR8v4diA5p4Zl8RDmvgo4Ibk3IXKS9GrMCmnWsLd7VQbPx5EDMynM73PYp0gfhhAFGLM4l9Jj0vI76VRB+7kFflLU3QLaA3fvNyloafZ8XN2pL643W5n9OS3YonGdXZgZXxpEdcvWQRqBIQmBuPu8w== 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=PPALuDGJNM9y8Ug1H6CaIOEuYePdXKcN2UxGaHcWmjI=; b=TFM7wF1LnMwXJ9BARSp2eTzJD5ntF9uAQZKdMx1gBFPC7GnGWOEvzGbzxgB93pv/ZdCs+s86yzqKqd3DEUdEEwFJYVJ1MGn+y0Min/XfKA7gTNoUGrJHcThU8oz59b0/l4QceWq9pgn9D3melD4CSCVfsb6PgwLzrvZUBUMcZ5nZY4BmzECHnLSJTC7A+OyoJHbnVc5ozCYRZRrXXb0xn1LQPGK5xz6CblvzTIRdrZ5q2O3PyQhm99NlLT5AWAH9K4aBbKc8DBse7g0yD9nBw/OqDiA4rowYq3NPkAC7efAHte3B5CBhpqxu/b8trmsj/add6INtpylSAc4VYs5uzA== 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=PPALuDGJNM9y8Ug1H6CaIOEuYePdXKcN2UxGaHcWmjI=; b=qmseRgodvda6nl+7G6LJIgEC4elTegqyY+JAzDIvRmCLY3BUMWHjgHPelgizxhPUA4HBXjF8tI0KObcXDLai4QnQQh8/sqH+/02RkotK2mf4+7sxoO2L6UfI4qAB6G4bN6TpxinKJM3CpYL3WH13hRwOrltvu0locPh4H+6GYU8= 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:31 +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:31 +0000 From: Indu Bhagat To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH 3/3] ld: generate SFrame stack trace info for .plt.got Date: Wed, 30 Oct 2024 15:51:08 -0700 Message-ID: <20241030225108.3377357-4-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: MW4P222CA0017.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::22) 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: 37d2d73c-7055-4db1-d072-08dcf9356530 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: OmOhZ4AGEjbS60kvAHtnk8yaJDWIMShm0C5r2QJ+ZUJRDy/zlgHNE0SD03+fosrCIhjrkSGneZF6TIJIS12qSM0funmGCE8zH8Axfcr7FsR/VRaa3HqFYz+RAZ4cyYDAeDTKw8OuwJBtNHcTSz9HaUyJnb09c7590W3hjwEkUFXuCwu9s4yb7r9qzf4HuGLzudXzqkEaUWAhSFkNqushvmpT0nXJT7FBpvzc2BGjneY1GsjDhRgt3EoZtmsWpJCK/paEN7THxfe+Vufh4BvgIs6ybwM5IPpQlob6npneHZK9+ds9SQcugXNW03X0T3cqZWw0Fp5TW+vOZ7NnCQgGIU555a7WnLXOPXgvgTnTmuU8/ok8323xfB+S/pL45H8Rw+HRoKGZNSgvJMx2ovt7UjUFAY6IPsA5rPFMnj3glKK7Z7vjaWiQEBQ8rf1Ic3JMoOKrEQ4ytlgS0zuOMsuFMAKZHxw8NePhCqWU/HFYYCOG5RbJESwemZQpTUx4wPvELNBkZUU/I8CWjNDGvtEw8srgTyqj5rDibjSp/e5ZpawYygyk3mdhc5QY92G/N1pAJy/7kpkSWXF3WxtJxnWowTYA/k8GakP0DSl08SutGIvGRqAEfZD44qWQj94AsAbhdW7psF6+x0Nz8wxeNSGgY/B0SgoYweqJT2VOPNYJmmp8Fi25Yk3oIrE0Qu4Zx4VYtncRDHEfdONf+E6PZqOWhyJDND+3eACezF0zj33xE3CWLkE92I55nOFongpAvtCFg2T3yKKrM+ElmWxk64ReKVAS2Mhtxnm3adL7wMD951BxmAiwjkprGsKqs4RshVe+LTxQ99jUIiUVr4RBEJlfX/qWIbZ2R/TOV7U5kj3WAeIc+0LFEbBX5D5IVhLP8BSHpBgXbrf0nmVWfbzmoNf+gxrQc4P2WAEd7CfnqUvsvjW1TNeY8smRTJlttqTHS9cmfgHxX6EY7a+dymFIZhPd2OJeZIB3EBo1/+g2ozPFunB7rIMS5buNQU1tzIUgq5wqLWvu7g7EWw5L1+P4ZYa3KsUlfJwcxf/y4xGxLFeQCVKP9/GWYUI6Uj0Nl3JSw0fFTIBrqA4roA6Cf0/3f0JaoaUDZlze8VGZL0Tq7AOa2qgh4GhU6CVmaJBHafZFKuGqnfjAdRF7go5gF0B3eljdYN6n3rUTN5TycoOOOneczkLkbWPmUDQCsRLorvZaMzXJUX9pmkZC19TZx6bQVeQ36mYcFKDF//z25HXhDRF8Z3dBP7UWlK/Us3+8kMfiI488+YTevyEIvJsqAxO81ymMH12xMYnD8KxH+jqJXzBNmuvpaZ4EYhhspatV/X8d02TO 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-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dRVBOCblHZpzyMqQjYaPxdCo5zdQQHn9N0mQMAZ11FqfWv8cmuVfoJzA8z9pLnLe1tP+Di261ARhBzy+fUrq9QZZ2+EL+HWORwXr9OjYxLLrCAAE2IGLp7oXTueUvQqX9oNO8MjNJCpvg3Tu1zRHQIvFBEaf9fVsneHiC1urVljkXCoBWVFzRlE0BFwm2rtV8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37d2d73c-7055-4db1-d072-08dcf9356530 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:31.5466 (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: Pmp2KMwue6nBAjedceeI3eTkxJb8GaH5qSkUIdX+bVERH0AVbEUKk/fjRBczDCna3odwkt0STYL6lrVgrHpRFQ== 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 spamscore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300177 X-Proofpoint-GUID: 26cMusCVhWjiREAZ-Kf1tnmwM3dyjTwc X-Proofpoint-ORIG-GUID: 26cMusCVhWjiREAZ-Kf1tnmwM3dyjTwc 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 PR/32298 sframe: no SFrame stack trace info generated for .plt.got Add support to generate SFrame stack trace info for .plt.got section. Enhance the current definition of struct elf_x86_sframe_plt to include initialized SFrame FDE/FREs applicable for .plt.got section. There are two variants of .plt.got entries: 16 byte and 8 byte. 8 byte: ff 25 00 00 00 00 jmpq *name@GOTPCREL(%rip) 66 90 xchg %ax,%ax 16 byte: f3 0f 1e fa endbr64 ff 25 66 2f 00 00 jmpq *name@GOTPCREL(%rip) 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) For the testcase, define some application symbols such that their PLT entry is placed in .plt.got and ensure SFrame information is generated with and without -z ibtplt. ChangeLog: PR/32298 * bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): PLT GOT entry size is different for IBT vs non IBT PLTs. * bfd/elfxx-x86.c (enum dynobj_sframe_plt_type): New enum for SFRAME_PLT_GOT. (_bfd_x86_elf_create_sframe_plt): Handle SFRAME_PLT_GOT. (_bfd_x86_elf_write_sframe_plt): Likewise. (_bfd_x86_elf_late_size_sections): Likewise. (_bfd_x86_elf_finish_dynamic_sections): Likewise. * bfd/elfxx-x86.h (struct elf_x86_sframe_plt): Add new members to keep information about PLT GOT entries. (struct elf_x86_link_hash_table): Add support for creating SFrame section for .plt.got. * ld/testsuite/ld-x86-64/x86-64.exp: Add new tests. * ld/testsuite/ld-x86-64/sframe-pltgot-1.d: New test. * ld/testsuite/ld-x86-64/sframe-pltgot-1.s: New test. * ld/testsuite/ld-x86-64/sframe-pltgot-2.d: New test. --- bfd/elf64-x86-64.c | 42 ++++++++++-- bfd/elfxx-x86.c | 86 ++++++++++++++++++++++-- bfd/elfxx-x86.h | 6 ++ ld/testsuite/ld-x86-64/sframe-pltgot-1.d | 28 ++++++++ ld/testsuite/ld-x86-64/sframe-pltgot-1.s | 15 +++++ ld/testsuite/ld-x86-64/sframe-pltgot-2.d | 28 ++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 2 + 7 files changed, 198 insertions(+), 9 deletions(-) create mode 100644 ld/testsuite/ld-x86-64/sframe-pltgot-1.d create mode 100644 ld/testsuite/ld-x86-64/sframe-pltgot-1.s create mode 100644 ld/testsuite/ld-x86-64/sframe-pltgot-2.d diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index abbebbe92b4..a62fa621f99 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -922,7 +922,7 @@ static const sframe_frame_row_entry elf_x86_64_sframe_sec_pltn_fre1 = SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info. */ }; -/* SFrame helper object for non-lazy PLT. Also used for IBT enabled PLT. */ +/* SFrame helper object for non-lazy PLT. */ static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_plt = { LAZY_PLT_ENTRY_SIZE, @@ -935,7 +935,31 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_plt = { &elf_x86_64_sframe_sec_pltn_fre1, &elf_x86_64_sframe_null_fre }, 0, 0, /* There is no second PLT necessary. */ - { &elf_x86_64_sframe_null_fre } + { &elf_x86_64_sframe_null_fre }, + NON_LAZY_PLT_ENTRY_SIZE, + 1, /* Number of FREs for PLT GOT. */ + /* Array of SFrame FREs for PLT GOT. */ + { &elf_x86_64_sframe_null_fre }, +}; + +/* SFrame helper object for non-lazy IBT enabled PLT. */ +static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_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, + 1, /* Number of FREs for PLTn. */ + /* Array of SFrame FREs for plt. */ + { &elf_x86_64_sframe_sec_pltn_fre1, &elf_x86_64_sframe_null_fre }, + 0, + 0, /* There is no second PLT necessary. */ + { &elf_x86_64_sframe_null_fre }, + LAZY_PLT_ENTRY_SIZE, + 1, /* Number of FREs for PLT GOT. */ + /* Array of SFrame FREs for PLT GOT. */ + { &elf_x86_64_sframe_null_fre }, }; /* SFrame helper object for lazy PLT. */ @@ -952,7 +976,11 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_plt = NON_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 } + { &elf_x86_64_sframe_sec_pltn_fre1 }, + NON_LAZY_PLT_ENTRY_SIZE, + 1, /* Number of FREs for PLT GOT. */ + /* Array of SFrame FREs for PLT GOT. */ + { &elf_x86_64_sframe_null_fre }, }; /* SFrame helper object for lazy PLT with IBT. */ @@ -969,7 +997,11 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_ibt_plt = 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 } + { &elf_x86_64_sframe_sec_pltn_fre1 }, + LAZY_PLT_ENTRY_SIZE, + 1, /* Number of FREs for PLT GOT. */ + /* Array of SFrame FREs for PLT GOT. */ + { &elf_x86_64_sframe_null_fre }, }; /* These are the standard parameters. */ @@ -5703,7 +5735,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_ibt_plt; - init_table.sframe_non_lazy_ibt_plt = &elf_x86_64_sframe_non_lazy_plt; + init_table.sframe_non_lazy_ibt_plt = &elf_x86_64_sframe_non_lazy_ibt_plt; } else { diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index cb90f688b6f..0843803171b 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -1817,7 +1817,8 @@ elf_x86_relative_reloc_compare (const void *pa, const void *pb) enum dynobj_sframe_plt_type { SFRAME_PLT = 1, - SFRAME_PLT_SEC = 2 + SFRAME_PLT_SEC = 2, + SFRAME_PLT_GOT = 3, }; /* Create SFrame stack trace info for the plt entries in the .plt section @@ -1880,6 +1881,21 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd, break; } + case SFRAME_PLT_GOT: + { + ectx = &htab->plt_got_cfe_ctx; + dpltsec = htab->plt_got; + + plt0_entry_size = 0; + + plt_entry_size = htab->sframe_plt->plt_got_entry_size; + pltn_fres = htab->sframe_plt->plt_got_fres; + num_pltn_fres = htab->sframe_plt->plt_got_num_fres; + num_pltn_entries = dpltsec->size / plt_entry_size; + + break; + } + default: /* No other value is possible. */ return false; @@ -1984,6 +2000,10 @@ _bfd_x86_elf_write_sframe_plt (bfd *output_bfd, ectx = htab->plt_second_cfe_ctx; sec = htab->plt_second_sframe; break; + case SFRAME_PLT_GOT: + ectx = htab->plt_got_cfe_ctx; + sec = htab->plt_got_sframe; + break; default: /* No other value is possible. */ return false; @@ -2511,7 +2531,18 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, htab->plt_sframe->size = sizeof (sframe_header) + 1; } - /* FIXME - generate for .plt.got ? */ + if (htab->plt_got_sframe != NULL + && htab->plt_got != NULL + && htab->plt_got->size != 0 + && !bfd_is_abs_section (htab->plt_got->output_section)) + { + _bfd_x86_elf_create_sframe_plt (output_bfd, info, SFRAME_PLT_GOT); + /* FIXME - Dirty Hack. Set the size to something non-zero for now, + so that the section does not get stripped out below. The precise + size of this section is known only when the contents are + serialized in _bfd_x86_elf_write_sframe_plt. */ + htab->plt_got_sframe->size = sizeof (sframe_header) + 1; + } if (htab->plt_second_sframe != NULL && htab->plt_second != NULL @@ -2578,6 +2609,7 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, || s == htab->plt_second_eh_frame || s == htab->plt_sframe || s == htab->plt_second_sframe + || s == htab->plt_got_sframe || s == htab->elf.sdynbss || s == htab->elf.sdynrelro) { @@ -2622,7 +2654,8 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, /* Skip allocating contents for .sframe section as it is written out differently. See below. */ - if ((s == htab->plt_sframe) || (s == htab->plt_second_sframe)) + if ((s == htab->plt_sframe) || (s == htab->plt_second_sframe) + || (s == htab->plt_got_sframe)) continue; /* NB: Initially, the iplt section has minimal alignment to @@ -2687,6 +2720,12 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, && htab->plt_second->size != 0 && htab->plt_second_sframe->contents == NULL) _bfd_x86_elf_write_sframe_plt (output_bfd, info, SFRAME_PLT_SEC); + + if (htab->plt_got_sframe != NULL + && htab->plt_got != NULL + && htab->plt_got->size != 0 + && htab->plt_got_sframe->contents == NULL) + _bfd_x86_elf_write_sframe_plt (output_bfd, info, SFRAME_PLT_GOT); } if (resolved_plt != NULL @@ -2997,6 +3036,34 @@ _bfd_x86_elf_finish_dynamic_sections (bfd *output_bfd, return NULL; } } + + if (htab->plt_got_sframe != NULL + && htab->plt_got_sframe->contents != NULL) + { + if (htab->plt_got != NULL + && htab->plt_got->size != 0 + && (htab->plt_got->flags & SEC_EXCLUDE) == 0 + && htab->plt_got->output_section != NULL + && htab->plt_got_sframe->output_section != NULL) + { + bfd_vma plt_start = htab->plt_got->output_section->vma; + bfd_vma sframe_start + = (htab->plt_got_sframe->output_section->vma + + htab->plt_got_sframe->output_offset + + PLT_SFRAME_FDE_START_OFFSET); + bfd_put_signed_32 (dynobj, plt_start - sframe_start, + htab->plt_got_sframe->contents + + PLT_SFRAME_FDE_START_OFFSET); + } + if (htab->plt_got_sframe->sec_info_type == SEC_INFO_TYPE_SFRAME) + { + if (! _bfd_elf_merge_section_sframe (output_bfd, info, + htab->plt_got_sframe, + htab->plt_got_sframe->contents)) + return NULL; + } + } + if (htab->elf.sgot && htab->elf.sgot->size > 0) elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = htab->got_entry_size; @@ -4764,7 +4831,18 @@ _bfd_x86_elf_link_setup_gnu_properties htab->plt_second_sframe = sec; } - /* FIXME - add later for plt_got. */ + + /* .plt.got. */ + if (htab->plt_got != NULL) + { + sec = bfd_make_section_anyway_with_flags (dynobj, + ".sframe", + flags); + if (sec == NULL) + info->callbacks->einfo (_("%F%P: failed to create PLT GOT .sframe section\n")); + + htab->plt_got_sframe = sec; + } } } diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index b042d45c282..cd26e8fc6f2 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -401,6 +401,10 @@ struct elf_x86_sframe_plt unsigned int sec_pltn_entry_size; unsigned int sec_pltn_num_fres; const sframe_frame_row_entry *sec_pltn_fres[SFRAME_PLTN_MAX_NUM_FRES]; + + unsigned int plt_got_entry_size; + unsigned int plt_got_num_fres; + const sframe_frame_row_entry *plt_got_fres[SFRAME_PLTN_MAX_NUM_FRES]; }; struct elf_x86_lazy_plt_layout @@ -606,6 +610,8 @@ struct elf_x86_link_hash_table asection *plt_sframe; sframe_encoder_ctx *plt_second_cfe_ctx; asection *plt_second_sframe; + sframe_encoder_ctx *plt_got_cfe_ctx; + asection *plt_got_sframe; /* Parameters describing PLT generation, lazy or non-lazy. */ struct elf_x86_plt_layout plt; diff --git a/ld/testsuite/ld-x86-64/sframe-pltgot-1.d b/ld/testsuite/ld-x86-64/sframe-pltgot-1.d new file mode 100644 index 00000000000..23ff5d52fec --- /dev/null +++ b/ld/testsuite/ld-x86-64/sframe-pltgot-1.d @@ -0,0 +1,28 @@ +#as: --gsframe +#source: sframe-pltgot-1.s +#objdump: --sframe=.sframe +#ld: -shared -z ibtplt --no-rosegment +#name: SFrame for IBT .plt.got + +.*: +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 = 64 bytes + STARTPC\[m\] +CFA +FP +RA + + 0+0000 +sp\+16 +u +f + + +#... diff --git a/ld/testsuite/ld-x86-64/sframe-pltgot-1.s b/ld/testsuite/ld-x86-64/sframe-pltgot-1.s new file mode 100644 index 00000000000..e596e846439 --- /dev/null +++ b/ld/testsuite/ld-x86-64/sframe-pltgot-1.s @@ -0,0 +1,15 @@ + .text + .globl foo + .type foo, @function +foo: + .cfi_startproc + call func1@plt + movq func1@GOTPCREL(%rip), %rax + call func2@plt + movq func2@GOTPCREL(%rip), %rax + call func3@plt + movq func3@GOTPCREL(%rip), %rax + call func4@plt + movq func4@GOTPCREL(%rip), %rax + .cfi_endproc + .section .note.GNU-stack,"",@progbits diff --git a/ld/testsuite/ld-x86-64/sframe-pltgot-2.d b/ld/testsuite/ld-x86-64/sframe-pltgot-2.d new file mode 100644 index 00000000000..7a99d12faa8 --- /dev/null +++ b/ld/testsuite/ld-x86-64/sframe-pltgot-2.d @@ -0,0 +1,28 @@ +#as: --gsframe +#source: sframe-pltgot-1.s +#objdump: --sframe=.sframe +#ld: -shared --no-rosegment +#name: SFrame for .plt.got + +.*: +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\+16 +u +f + + +#... diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 0632397bccc..a66d28eb0d1 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -548,6 +548,8 @@ if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" run_dump_test "sframe-plt-1" run_dump_test "sframe-ibt-plt-1" + run_dump_test "sframe-pltgot-1" + run_dump_test "sframe-pltgot-2" } if ![istarget "x86_64-*-linux*"] {