From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id DFB503858D20 for ; Thu, 25 Apr 2024 19:46:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFB503858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 DFB503858D20 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=1714074393; cv=pass; b=VJNpSYZWC1m3G18TEjNqtpyLYPJZCqF0JQFZo4n96hmH0xTDqOFY1bjx70PSFcp6sxberEXPDu20pfU828GjqgBOFSIOWqBbv6JfKekpeIW0xf2VUkhdM98EFy7DwcO4WXmBwB5rWUNgwEUd+g82U0eD6P82HLN9Qy4FKB/YLGA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1714074393; c=relaxed/simple; bh=3JVYIgHyj0dVJr4VUBv1QWtCbTAa6IMPvYv6FO6DWiQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=IT1u5+jUcf4iPDllg2CnGs9mIpdeSQmlY0SQzk1m6dxkCVkLYHZRpuxk24+91Lfs7127uAR+kkkYpZj/l/npE8R4FJuWgZUIsusf2obYdQubdcMFjR+mZD0xiySahTIhM0f/rLBDXiNICPTzLSljDLAPSeznzeDjWn+k5j+ivLs= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43PHNxLi023622 for ; Thu, 25 Apr 2024 19:46:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : content-type : mime-version; s=corp-2023-11-20; bh=pwb97Otfkqmg+X8wfhgwAItQYLlGKlGUiFGyITIIzJQ=; b=UuCxciPvaDa8EeG23OwmwJRcyx25oOSiYVhGlvzX6qm+E1OZkdLv1IXv1EItfr6UB8T5 +JZb4lp5u0+uou7M/5Vsi2SZO5E2vi6z3PdqM8gHSP0zPAz7dUcDFfMWbv4YyNiNe9B4 979cpvvHpEk0U/VPM96ZYM/8EfR1SOw8QuSBLhM8YZLGS4ldSuL21S4o8IRpTGrLXwZe 5onDcOoEm2+DoWEjK0h8jr0rn9Pv/hspO33DvKJMLrF8chDNrcQ+CF+56cv6ClKRmT2S c3MoPBW0Od9US167KgmtCKPJ2ytQ/aRgXxo/t2kPRd0lg/Yf9QeZfaZggLUamlKmT7Rr xQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xm44f3yk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Apr 2024 19:46:30 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43PIXAp9006157 for ; Thu, 25 Apr 2024 19:46:29 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xm45awnab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Apr 2024 19:46:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L1778Iqn8m1dNMYeZ5U7dLr1bWjmNeeQYNVx1aprvD9ic8hbbLG969jdc2t7hKS71/kRW8k2YuPs/pgytOQvR5YkIwyplIetUyDMTRTtZJM7MzMt3j+18+DUWyJrQQpWO0G9cb96mPp8YTCuEn1/znDrecvV+IjO2IGaz9IqWPNBnjcCEito2YCq3TRnMYHznN/VK/VHiIFAhbn3CU9TP8MDtliovqLvAio1OABHh8HY7I6wfPHiXZ+cYdwzMIsqxCpFelSH9566dRiQa+JG+wGsb0o3k07hFOyXJ/LmMBBOuuHdak/Leus/WBp4bc7yj5yIYJmW36jaKM0cFA6xOA== 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=pwb97Otfkqmg+X8wfhgwAItQYLlGKlGUiFGyITIIzJQ=; b=Y2CJJdhikLdsn99vfAvNxHq6k6nBbpGHsD7bH0pQK5ncL6vXnQEdTTNGlAnStl6K86lIFgErYc37NNsTgZJMXx+F5nrxgyogjy4FjQ2v0DtSBuyxSBzCkRCVOV0jFJrF4wnVUv5DKqJlrW46BreB0+t1al3KaWISG96h5T5v1LeEYQsjPDmWmO1mWsSB/e7D07m/YckV7qbi29yxbO1S+JE43FChsrEU7rRv8J974j7ClgrCNt9oMKqnnvyW7Wft4D6wCh7OuGjDeUlU3tJmvsbWFCIpMQ8C3+ZITk+/KX7ww0S0oMtu/ZFXCGn4VvQ2G8S3HD60K5XaPRKDlPUTjQ== 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=pwb97Otfkqmg+X8wfhgwAItQYLlGKlGUiFGyITIIzJQ=; b=Xq/1h9pXoVMQmcpRCURfadSo2SwUk7hhKdDTIqmEdHe9YYLOWarTUFbpAUaE+xTdbkPDz4MOKolyuf/2d2M7f2RL+TZ1ekkIblPAzKp0KP+pmMKUf1Xrh+ok4m75nZDsHFXMrQSbGGUd4nyQ75MX4k4UjjjxYBrgayDjuBL3Kcw= Received: from DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) by SA2PR10MB4571.namprd10.prod.outlook.com (2603:10b6:806:11d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.46; Thu, 25 Apr 2024 19:46:26 +0000 Received: from DM6PR10MB3113.namprd10.prod.outlook.com ([fe80::e0b9:12d5:badd:6fe0]) by DM6PR10MB3113.namprd10.prod.outlook.com ([fe80::e0b9:12d5:badd:6fe0%6]) with mapi id 15.20.7519.021; Thu, 25 Apr 2024 19:46:26 +0000 From: "Jose E. Marchesi" To: David Faust Cc: binutils@sourceware.org, cupertino.miranda@oracle.com, indu.bhagat@oracle.com Subject: Re: [PATCH] bpf: fix calculation when deciding to relax branch In-Reply-To: <20240425192223.8892-1-david.faust@oracle.com> (David Faust's message of "Thu, 25 Apr 2024 12:22:23 -0700") References: <20240425192223.8892-1-david.faust@oracle.com> Date: Thu, 25 Apr 2024 21:46:21 +0200 Message-ID: <87le515ipe.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-ClientProxiedBy: LO4P123CA0683.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:351::13) To DM6PR10MB3113.namprd10.prod.outlook.com (2603:10b6:5:1a7::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB3113:EE_|SA2PR10MB4571:EE_ X-MS-Office365-Filtering-Correlation-Id: 11081318-8492-4c9f-eca7-08dc656064bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?thSWA6+okmPgJThJrwPPizcUEjPtW6Vgf5p/BsMjuMN3J6kcvp5v4R+XE/9y?= =?us-ascii?Q?T+OwF0rfD5aqf14dB7RVIjrHgcWL61N0L0M4+98on976XxKcyogOgpnTaF3n?= =?us-ascii?Q?B6BdXHL0xwPgNiABMQvFE/a886aRBIl/zCfLpSRe6f9u1DffpKSNMVV1qbc2?= =?us-ascii?Q?7tH8OAjgDocerOtxr+Mr3gy2E2FpiebSa1qrhnaMxjJUcndcSjPKt6ojyO7C?= =?us-ascii?Q?Qh+kJJEfgOF3p9an854aAK4ZVVU65pN3byPxZxOerb3jBXXyEUv+BZXXpuyH?= =?us-ascii?Q?MRs27cnzv2GYq/cnF7dyNMAq/phyvPkMr66y2bqt2dSSEkDOTcu3zGOqnjfn?= =?us-ascii?Q?XxugcuDEv7KqJgLGQU/c+aUdGe26VcVvBcoH7lQOQsxmvEbAyXK0rskE1iUp?= =?us-ascii?Q?oNxcc9ZgkSs3c9LCZ6Wllsgvr7y4Pcd7m0uCDh9vbiOBXhum9dqOC/EHwS+N?= =?us-ascii?Q?PZbta0T2SXdx5qMzLlk0+FPPCwiYtYvfTquvBL6SmufVm8PrG8FzUekGbrX6?= =?us-ascii?Q?C+DjWevzBgK9i4mfSSVhWx+o39Ss0nXDzovcv9l9eDDCZ2WNENWpLJTtz+uG?= =?us-ascii?Q?mhttmj7E5h49+/4fuHqQkJMZgt8vhDxFtiBCq8xhyBGTFpxv45du1fHrxHUd?= =?us-ascii?Q?3ag2/Ff1Q8c9hEVZ1Co2v6w6l3PMD5gCLPfV8weNkBwnvi2byC7ehR+rqEdy?= =?us-ascii?Q?/yQfCYo5EO26DFeR6ZfsiZxP0hkGWs0v97G2u4UulyxFAyLgQamoCgfy76xn?= =?us-ascii?Q?7YN4SM9eQjuaJtP1kJEtDUz+XlcKZqyT5avap3kot0vsEg4JE6IH0S81tljk?= =?us-ascii?Q?V6fwxHHXhqUjT/rmiXMyQJ/hpphsYYhkw1z0FcZGBZbZHszItJH/uO3r+4m8?= =?us-ascii?Q?PcWiMzfKvp165k8qWBRcYKU6IaFTZoW/sE7GMh6Jym3T7jQ7oCNMRlg7sAM/?= =?us-ascii?Q?Lo7l0/Sjf0QGZG57xOfSp/rRljq3kz1Sq6UCxYMmXWol9Zk5zItUfcDf4lBB?= =?us-ascii?Q?swa6JOcYE6dHtFzf3YoDfRJU42TTily0SYCVJv6pYssZ/oSnvdcKc8Ttiyt2?= =?us-ascii?Q?UXGA6EPnT2GDk0avdhIraWsSE/qM33U/AGApMqd3lXuG1pQ3iwtXxs+fwUKc?= =?us-ascii?Q?tgQ04HJq+UWcxGf42fejKXSgRauCp5j0ZVcJ1SzwUin7mYx5UeoVrf15qnck?= =?us-ascii?Q?pWC8YwTa6bLwWrtjAP7cV3a4M7UijdapeK3N0QBgmyQzIqefm1cIsi6Fd8rZ?= =?us-ascii?Q?rK1wabCWYci+xqf4sc+ZtAxNgltEbG+lU8EZuZBaPA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB3113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?NL+jSuMYXHke9UmiiuFdOdW5CeNJT+LQpywQLYL7SQHvx3qkWEmdOst8mzcC?= =?us-ascii?Q?NE08jb9DIuhYja80kSTTcyhENfJfsjzSwLdW124AN4Tn45tJTuh2m8gDLDli?= =?us-ascii?Q?WZk7AVudmjjwzvRqDX+HEOPdGTxyWgkoxH4Rn3loFQ0fsqO1c5PxicUjwNBe?= =?us-ascii?Q?cNFDRQG03/0nyUyO6f+Vuqr998iIV+MCw+vz4xX55j/TDDJasXMpcmYJDLKP?= =?us-ascii?Q?ZGfh2pPDyPorWH63B0/sXPw6daLQ1x1YcevdG3iUL2x3iCdjLZKMQUY6u4YV?= =?us-ascii?Q?Bl3CHSwvvGtdFTyUxmKuW+JqDGWeQnBSbC8NibNy9uPjUZPEyBDcp7d77kST?= =?us-ascii?Q?XdYxOIx9PZMZCpYEUxTtbatt4G+5dfth7OrrkmpqbxkqNQvpLRX9gmuaum/B?= =?us-ascii?Q?coez0Q8hhmU7KlB2GrnPC+UGLNDNpf8aH4LqaAdgeNczQ0KN7r7D6kHU82X5?= =?us-ascii?Q?gfFqUDK9BX0ldhurBnr3G1zCWwnZKxzmwxYbJMpiQW1NyU3fl1Q4XEz5XBLW?= =?us-ascii?Q?CWjr34/XbISDytOmPWWEpW9DxRl2CW4JPWrF/BpPaeMfeaP+MsVi/kkNKilQ?= =?us-ascii?Q?V3HdkcluxfivA65qEBkKA15MRW76BibD+BxacBg5xLzI4P1OCQ1xiPyFP/Yp?= =?us-ascii?Q?Kbv/cLUxJNfyJ7TLykFBkteUfPgl1Te+eAk9gCSu2EqXgzXls3fRRnSny6Gv?= =?us-ascii?Q?j1kkaijkhc58QtTgeHnUU6Xlyqg6cpK+TYYDJAxGztmcA2VuuYt+6tMhMbrK?= =?us-ascii?Q?kRguB07kZjP9dXid2r1ooV7TFJiQYba+9SNMrHbIANSNHiXYAXny4xYAskUJ?= =?us-ascii?Q?6cqAU14MoIenJD27NuLqJVom7eWGY+a5n0v6fCp8Asx//HsRlLK5I1v8Bu67?= =?us-ascii?Q?waQoJgtrfGNz8o0i4/OJ8oukH2c92p3bvf4Ge2Uz0gfraxWXoQoqGXYbV5ea?= =?us-ascii?Q?7RuZHMJH7qgpCitGHMSZKYR05l9KPfznhc+XpxIJI6vDbSAmcgn6vl0s3lYv?= =?us-ascii?Q?NuhrFREUDt5zc1In8YEr4Hh4SIxzT3VbKjr+Ix7nAUspcnNeIisi2nr+flKK?= =?us-ascii?Q?ycE7+SIhu8GHgj/TZELiuf3+W4aIGUOjRoMbLa4dvqauNN90wqLWI/9RsLh2?= =?us-ascii?Q?+q58JiYsNIaSS8Dc+AuGY+RBsovOowvxogVJJtDKQnOMbLwgr5U0y8/spAzg?= =?us-ascii?Q?BaTtO+U7VuOrtdWtnpFjIq9Yd+gsQLzpb2htb4Fbl8OF6WohlTsL4m9pKu3z?= =?us-ascii?Q?FZvMGXxSZVuNdSVvPnXde4SbLe7ZlOwGDJr409Td2unNc4S4sx2+qNaV0JoA?= =?us-ascii?Q?NFX5SNiMkamFOwxEitYzX20/BS8T5ZPUWEOOg+pnaWO6ZHuFpLk6uHouNA/6?= =?us-ascii?Q?Z8i24jGS0NzKMHGBtPb1AgiyNmS+QtYu2BlrxddvyNlJ4VX0Avg60+ZNQCT6?= =?us-ascii?Q?9pymom1E+5UxXzh7qdbjkJd382knVPNFslOyW8mFLZ5j11MXCu5f717oAVAy?= =?us-ascii?Q?qn/Sl8YIPnl9zDUGv2M2jGRbIB+/8TjkyKrRgjCUMUzamasb5ZSEdL/6Py/P?= =?us-ascii?Q?x+okVf2EBjsyqfPQLs7ZTxIrbtZQ/IduUz8xHZn/YxpuwKbZCfWDSxPEtTuH?= =?us-ascii?Q?nQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2KVIQ4pQj/HLEXTz6AleHeTu9WSrPEqijLe7vB7PeTKqavy6idEEsX4WocKvsbnrhBKsqSlF/nFghk28Q+s/QFI94LJzU69T05k+wroJxikznZvoboi3MrPvgE/PzqNtzETdh3wEpqdO3Y+igqn5VYOEvTDarK1cLIkqe3VqfmhsUFM0jGU0LXYYNIl9TNwhsVpoZYK3GEsxbnEFR3nBWbDdAsWrLuaxWty3maoLTh6aPPF6sZFWhV3zxIpDoVdpShKwiqmUFZ9uQ2noDJ2jCaxDrzoM60YLjmW582XHzLKJmVLfl/cMq/th+3VHUB6x8PUMzqjuRZXpVxPSyYXjr64nDClpSdafHEM8kHamAAzzmX25bozgh0m1Ishy0zbB6qjUXWZlyMt+qj29exE0RdiwrlAlom41UzB205ZfXbCRN2ogSRO00c6QOOkT6hA+19/8ir2est2u0/xLHAoJwxEtMadOTA0WkcYlHmfm5EN2SPOz6CmrhLe/P+hJvhPP6g2SBDD+pT9qKfTOH9NTuFRi/4kfFYDzfYPTChAoxQRjZRBsEB4xK5T90VZV4BCrzQAdWOwX5HQ1W/9EJSV/KxxR6uFf+F6KmBbldFEZ4dk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11081318-8492-4c9f-eca7-08dc656064bc X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB3113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2024 19:46:26.3502 (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: 37+6RDrqb2fQc0sBGa3XV9Vl/wX6GjqLzETb9ihZt2ZLrW+eqtv/xXDWPOk3REaUrxd6tGfkIklat7JIAmjeNU+5H4Ix4sZxj3UflxoQB+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4571 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-25_19,2024-04-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404250142 X-Proofpoint-ORIG-GUID: Q-Bx1Uf04vVm6i6ugRKXW9cguzP8PvyC X-Proofpoint-GUID: Q-Bx1Uf04vVm6i6ugRKXW9cguzP8PvyC X-Spam-Status: No, score=-13.0 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_H4,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 List-Id: Hi David. OK. Thanks for the patch! > In certain cases we were calculating the jump displacement incorrectly > when deciding whether to relax a branch. This meant for some branches, > such as a very long backwards conditional branch, relaxation was not > done when it should have been. The result was to error later, because > the actual jump displacement was too large to fit in the original > instruction. > > This patch fixes up the displacement calculation so that those branches > are correctly relaxed and no longer result in an error. In addition, it > changes md_convert_frag to install fixups for the JAL instructions in > the resulting relaxations rather than encoding the displacement value > directly. > > Tested on x86_64-linux-gnu host for bpf-unknown-none target. > Sanity checked building Linux kernel BPF selftests. > > gas/ > * config/tc-bpf.c (relaxed_branch_length): Correct displacement > calculation when relaxing. > (md_convert_frag): Likewise. Install fixups for JAL > instructions resulting from relaxation. > * testsuite/gas/bpf/jump-relax-ja-be.d: Correct and expand test. > * testsuite/gas/bpf/jump-relax-ja.d: Likewise. > * testsuite/gas/bpf/jump-relax-ja.s: Likewise. > * testsuite/gas/bpf/jump-relax-jump-be.d: Likewise. > * testsuite/gas/bpf/jump-relax-jump.d: Likewise. > * testsuite/gas/bpf/jump-relax-jump.s: Likewise. > --- > gas/config/tc-bpf.c | 38 +++++++++++++++++++--- > gas/testsuite/gas/bpf/jump-relax-ja-be.d | 16 +++++---- > gas/testsuite/gas/bpf/jump-relax-ja.d | 16 +++++---- > gas/testsuite/gas/bpf/jump-relax-ja.s | 13 +++++--- > gas/testsuite/gas/bpf/jump-relax-jump-be.d | 22 ++++++++----- > gas/testsuite/gas/bpf/jump-relax-jump.d | 22 ++++++++----- > gas/testsuite/gas/bpf/jump-relax-jump.s | 12 ++++--- > 7 files changed, 96 insertions(+), 43 deletions(-) > > diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c > index dfa44ea194c..377ac6a7a4c 100644 > --- a/gas/config/tc-bpf.c > +++ b/gas/config/tc-bpf.c > @@ -434,6 +434,7 @@ relaxed_branch_length (fragS *fragp, asection *sec, int update) > && sec == S_GET_SEGMENT (fragp->fr_symbol)) > { > offsetT val = S_GET_VALUE (fragp->fr_symbol) + fragp->fr_offset; > + val -= fragp->fr_address + fragp->fr_fix; > > /* Convert to 64-bit words, minus one. */ > val = (val - 8) / 8; > @@ -578,6 +579,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, > && sec == S_GET_SEGMENT (fragp->fr_symbol)) > { > offsetT val = S_GET_VALUE (fragp->fr_symbol) + fragp->fr_offset; > + val -= fragp->fr_address + fragp->fr_fix; > /* Convert to 64-bit blocks minus one. */ > disp_to_target = (val - 8) / 8; > disp_is_known = 1; > @@ -626,15 +628,27 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, > { > /* 16-bit disp is known and not in range. Turn the JA > into a JAL with a 32-bit displacement. */ > - char bytes[8]; > + char bytes[8] = {0}; > > bytes[0] = ((BPF_CLASS_JMP32|BPF_CODE_JA|BPF_SRC_K) >> 56) & 0xff; > bytes[1] = (word >> 48) & 0xff; > bytes[2] = 0; /* disp16 high */ > bytes[3] = 0; /* disp16 lo */ > - encode_int32 ((int32_t) disp_to_target, bytes + 4); > - > write_insn_bytes (buf, bytes); > + > + /* Install fixup for the JAL. */ > + reloc_howto_type *reloc_howto > + = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_BPF_DISP32); > + if (!reloc_howto) > + abort(); > + > + fixp = fix_new_exp (fragp, buf - (bfd_byte *) fragp->fr_literal, > + bfd_get_reloc_size (reloc_howto), > + &exp, > + reloc_howto->pc_relative, > + BFD_RELOC_BPF_DISP32); > + fixp->fx_file = fragp->fr_file; > + fixp->fx_line = fragp->fr_line; > } > } > else > @@ -731,8 +745,24 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, > bytes[1] = 0; > bytes[2] = 0; > bytes[3] = 0; > - encode_int32 ((int32_t) disp_to_target, bytes + 4); > + encode_int32 ((int32_t) 0, bytes + 4); > write_insn_bytes (buf, bytes); > + > + /* Install fixup for the JAL. */ > + reloc_howto_type *reloc_howto > + = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_BPF_DISP32); > + if (!reloc_howto) > + abort(); > + > + fixp = fix_new_exp (fragp, > + buf - (bfd_byte *) fragp->fr_literal, > + 4 /* size */, > + &exp, > + true /* pc-relative */, > + BFD_RELOC_BPF_DISP32); > + fixp->fx_file = fragp->fr_file; > + fixp->fx_line = fragp->fr_line; > + > buf += 8; > } > } > diff --git a/gas/testsuite/gas/bpf/jump-relax-ja-be.d b/gas/testsuite/gas/bpf/jump-relax-ja-be.d > index 5f07847e90c..e5ad30da807 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-ja-be.d > +++ b/gas/testsuite/gas/bpf/jump-relax-ja-be.d > @@ -8,10 +8,14 @@ > Disassembly of section .text: > > 0+ <.*>: > - 0: 05 00 80 00 00 00 00 00 ja -32768 > - 8: 05 00 7f ff 00 00 00 00 ja 32767 > - 10: 05 00 ff fd 00 00 00 00 ja -3 > - 18: 05 00 00 00 00 00 00 00 ja 0 > + 0: 05 00 80 00 00 00 00 00 ja -32768 > + 8: 05 00 7f ff 00 00 00 00 ja 32767 > + 10: 05 00 ff fd 00 00 00 00 ja -3 > + 18: 05 00 00 00 00 00 00 00 ja 0 > 18: R_BPF_GNU_64_16 undefined > - 20: 06 00 00 00 00 00 80 01 jal 32769 > - 28: 06 00 00 00 00 00 80 01 jal 32769 > + 20: 06 00 00 00 00 00 80 00 jal 32768 > + 28: 05 00 7f ff 00 00 00 00 ja 32767 > + ... > + > +0+40028 : > + 40028: 06 00 00 00 ff ff 7f fa jal -32774 > diff --git a/gas/testsuite/gas/bpf/jump-relax-ja.d b/gas/testsuite/gas/bpf/jump-relax-ja.d > index ed3aa6bad4e..1ac33f5d2f5 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-ja.d > +++ b/gas/testsuite/gas/bpf/jump-relax-ja.d > @@ -8,10 +8,14 @@ > Disassembly of section .text: > > 0+ <.*>: > - 0: 05 00 00 80 00 00 00 00 ja -32768 > - 8: 05 00 ff 7f 00 00 00 00 ja 32767 > - 10: 05 00 fd ff 00 00 00 00 ja -3 > - 18: 05 00 00 00 00 00 00 00 ja 0 > + 0: 05 00 00 80 00 00 00 00 ja -32768 > + 8: 05 00 ff 7f 00 00 00 00 ja 32767 > + 10: 05 00 fd ff 00 00 00 00 ja -3 > + 18: 05 00 00 00 00 00 00 00 ja 0 > 18: R_BPF_GNU_64_16 undefined > - 20: 06 00 00 00 01 80 00 00 jal 32769 > - 28: 06 00 00 00 01 80 00 00 jal 32769 > + 20: 06 00 00 00 00 80 00 00 jal 32768 > + 28: 05 00 ff 7f 00 00 00 00 ja 32767 > + ... > + > +0+40028 : > + 40028: 06 00 00 00 fa 7f ff ff jal -32774 > diff --git a/gas/testsuite/gas/bpf/jump-relax-ja.s b/gas/testsuite/gas/bpf/jump-relax-ja.s > index f164176bbd5..61f2e61cb3c 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-ja.s > +++ b/gas/testsuite/gas/bpf/jump-relax-ja.s > @@ -4,13 +4,18 @@ > 1: ja -32768 > ja 32767 > /* The following instruction refers to a defined symbol that > - is on reach, so it should not be relaxed. */ > + is in reach, so it should not be relaxed. */ > ja 1b > /* The following instruction has an undefined symbol as a > target. It is not to be relaxed. */ > ja undefined + 10 > - /* The following instructions refer to a defined symbol that > - is not on reach. They shall be relaxed to a JAL. */ > + /* The following instruction refers to a defined symbol that > + is not in reach, so it shall be relaxed to JAL. */ > ja tail > - tail = .text + 262160 > + /* Now the symbol is in reach, and the following instruction > + shall not be relaxed. */ > ja tail > + .space 262136 > + tail = . > + /* The jump back is too large and shall be relaxed. */ > + ja 1b > diff --git a/gas/testsuite/gas/bpf/jump-relax-jump-be.d b/gas/testsuite/gas/bpf/jump-relax-jump-be.d > index 0cacdb38fc9..5cf3bce2a2b 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-jump-be.d > +++ b/gas/testsuite/gas/bpf/jump-relax-jump-be.d > @@ -8,12 +8,16 @@ > Disassembly of section .text: > > 0+ <.*>: > - 0: 1d 12 80 00 00 00 00 00 jeq %r1,%r2,-32768 > - 8: ad 12 7f ff 00 00 00 00 jlt %r1,%r2,32767 > - 10: bd 12 ff fd 00 00 00 00 jle %r1,%r2,-3 > - 18: 1d 12 00 01 00 00 00 00 jeq %r1,%r2,1 > - 20: 05 00 00 01 00 00 00 00 ja 1 > - 28: 06 00 00 00 00 00 80 01 jal 32769 > - 30: 2d 12 00 01 00 00 00 00 jgt %r1,%r2,1 > - 38: 05 00 00 01 00 00 00 00 ja 1 > - 40: 06 00 00 00 00 00 80 01 jal 32769 > + 0: 1d 12 80 00 00 00 00 00 jeq %r1,%r2,-32768 > + 8: ad 12 7f ff 00 00 00 00 jlt %r1,%r2,32767 > + 10: bd 12 ff fd 00 00 00 00 jle %r1,%r2,-3 > + 18: 1d 12 00 01 00 00 00 00 jeq %r1,%r2,1 > + 20: 05 00 00 01 00 00 00 00 ja 1 > + 28: 06 00 00 00 00 00 80 00 jal 32768 > + 30: 2d 12 7f ff 00 00 00 00 jgt %r1,%r2,32767 > + ... > + > +0+40030 : > + 40030: 55 10 00 01 00 00 00 00 jne %r1,0,1 > + 40038: 05 00 00 01 00 00 00 00 ja 1 > + 40040: 06 00 00 00 ff ff 7f f7 jal -32777 > diff --git a/gas/testsuite/gas/bpf/jump-relax-jump.d b/gas/testsuite/gas/bpf/jump-relax-jump.d > index dd31ba5f4e4..4300bf3f59f 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-jump.d > +++ b/gas/testsuite/gas/bpf/jump-relax-jump.d > @@ -8,12 +8,16 @@ > Disassembly of section .text: > > 0+ <.*>: > - 0: 1d 21 00 80 00 00 00 00 jeq %r1,%r2,-32768 > - 8: ad 21 ff 7f 00 00 00 00 jlt %r1,%r2,32767 > - 10: bd 21 fd ff 00 00 00 00 jle %r1,%r2,-3 > - 18: 1d 21 01 00 00 00 00 00 jeq %r1,%r2,1 > - 20: 05 00 01 00 00 00 00 00 ja 1 > - 28: 06 00 00 00 01 80 00 00 jal 32769 > - 30: 2d 21 01 00 00 00 00 00 jgt %r1,%r2,1 > - 38: 05 00 01 00 00 00 00 00 ja 1 > - 40: 06 00 00 00 01 80 00 00 jal 32769 > + 0: 1d 21 00 80 00 00 00 00 jeq %r1,%r2,-32768 > + 8: ad 21 ff 7f 00 00 00 00 jlt %r1,%r2,32767 > + 10: bd 21 fd ff 00 00 00 00 jle %r1,%r2,-3 > + 18: 1d 21 01 00 00 00 00 00 jeq %r1,%r2,1 > + 20: 05 00 01 00 00 00 00 00 ja 1 > + 28: 06 00 00 00 00 80 00 00 jal 32768 > + 30: 2d 21 ff 7f 00 00 00 00 jgt %r1,%r2,32767 > + ... > + > +0+40030 : > + 40030: 55 01 01 00 00 00 00 00 jne %r1,0,1 > + 40038: 05 00 01 00 00 00 00 00 ja 1 > + 40040: 06 00 00 00 f7 7f ff ff jal -32777 > diff --git a/gas/testsuite/gas/bpf/jump-relax-jump.s b/gas/testsuite/gas/bpf/jump-relax-jump.s > index 5ea61109bca..6b23c56514a 100644 > --- a/gas/testsuite/gas/bpf/jump-relax-jump.s > +++ b/gas/testsuite/gas/bpf/jump-relax-jump.s > @@ -2,11 +2,13 @@ > fix in the jump 16-bit signed displacement operand. */ > 1: jeq %r1, %r2, -32768 > jlt %r1, %r2, 32767 > - /* The following instruction refers to a defined symbol that > - is on reach, so it should not be relaxed. */ > + /* The following instructions refer to defined symbols that > + are in reach, so they should not be relaxed. */ > jle %r1, %r2, 1b > - /* The following instructions refer to a defined symbol that > - is not on reach. They shall be relaxed. */ > jeq %r1, %r2, tail > - tail = .text + 262160 > jgt %r1, %r2, tail > + /* The following instructions refers to defined symbols that > + are not in reach, so they shall be relaxied. */ > + .space 262136 > + tail = . > + jne %r1, 0, 1b