From patchwork Thu Aug 22 18:19:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13774071 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CD851CF2BC; Thu, 22 Aug 2024 18:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350866; cv=fail; b=AFEcTmrnCNRmbCmm+au7xXdRnnSIZXXQJa5/vHBMiBDWSfHNYdF5XYn01RiBKkcULYwFGsWkgBaYwiHjsBsQd9/2ofj8Rjbg1d/4knTiYjPm3SJmVDe3HUsBo0SmEXC1/N+SzsCj0Kf92gCj94MoZ0xNufyhfO/D/weOECI5Tjc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350866; c=relaxed/simple; bh=cEONTywy9PC2pn0ZQd0GmZMKSqurVf+mxXj7SbHYHng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=DSSM8SjN0TZBpU5+S6j6I/sGXLrhKIkQny8FAQ5LBq8eMvxKya3xqD6Tkkl6qucajTR95+5aOghXFzABfpp8nrUdYFXU6m2Hlewn0C7mAel9g4nbIiu1RfhHL44aznkocXjLcyXMrkw/YxspqI0QG5rdKbzuBZHbIRRxL/SbCWE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=TiUcjDAM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=fgA7wIdW; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="TiUcjDAM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="fgA7wIdW" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MEQb5x008194; Thu, 22 Aug 2024 18:20:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b= TiUcjDAMSFs5ShJ++MhEIca0Fn+/LCsmJCxO/4B6s5c/JmTEsgWJ0B5ZO5AFtsWO F//6+bC8QtABfRZVgR/sMJb0SQqKDSYJe9nULIbEbFCtBhAd+88Kb1YZdZNmy+bq efsmzUJd3MA3KizHKz+dU+PvD8S4GxU1LsPLflZg/8iFfH6Nb4dE5uWCbSbeh05t LQQ15ageEWYaU2Sq+GHa7X8Nu/7QsD/kHab85tsi100qa/aVqHEsMkhK5TrJX9XD bJk9zcxKfsBIphymI6HSCdtmLYF3GHe+/CyWI2UCq2yHmPv+Opt3GLy5OWyE5BuP iVHNjG8gLrJzi0OlXm6zQw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdt2rn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:54 +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 47MIBfgq027517; Thu, 22 Aug 2024 18:20:54 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416947mbg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Jm+U2Mes60UzyD4t6d46BcpFYWTdda2rqn/MjGxjKgZNKnQfdVrFtqSkGomxJF3XM0Tl/EvLoSGk655eqy+tijIKx4fWB/yZnCEy4DujcLf/Ti8ox2pmEz6o2GOlK6e9Bscbvt8Nv2jsa2oF1qxtrjWJEl5xww2hIxqeeUkBzmNkZ5vKP2MSJYaTuKIBKSSmfVmH0O3cV17Y61ZiYeCRA0FwqbpDxuxCsoV42BEnyPKRY/W+Lvh+DfNz6RxykhdIBiShFjuY+ojSzYhGAhlJjd5AQQdZk8Ov7uI22A4O5q9uXHmbgkb7EZTBqlpKOGJ2pIembDQ5zl1M4/SFAnLr9g== 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=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b=Cg+lY2NgpcbFiVK8Iw32LBl4pa9SJ1W5Vfh6d13gaGcDTIm4Z0EfaGf1Go89oRCZD4Fiijmo7ZWRlviYhNah9n/RLms1biN5SDsUDuxAkyTqwl5R3Nwc9UJ4WZlEqAVDrbpEPgWOyWTdsovj3/59HtpiLsRrUS4q+DzdRwrbHp3PP1mjAk3rECOoIlga86VU3Cs2oXfEumIxLrl3FpmYncupmrBBmZIB9Mn34M+R/sys2dWp75x47c5U/8btJJu59Hbxdcd9qWk5XDkpbmtDYpSReACN1IyZt3M8KPK/428+VCSl8IKsRAdqCPLw998LMdfRWimJbj+M6zwTvSV8MQ== 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=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b=fgA7wIdWMVhnK9PqE6qbD9ZCadWuFsXU4Ltrz8z6cIzZKGoeeGSRU7oiIE3gPFdxZcyhIQ/p9T7FVM891LNsuDxXYC/00h1xZwFg+/E4sHWddfoq/OHN3FBIgsU6qeW5cxW+5iEkw2oubV4h1PhNiULKRvwLqe8t29ypWLWD9E8= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB5004.namprd10.prod.outlook.com (2603:10b6:610:de::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 18:19:51 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 22 Aug 2024 18:19:50 +0000 From: Kris Van Hees To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Kris Van Hees , Steven Rostedt , Masahiro Yamada , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v8 1/4] kbuild: add mod(name,file)_flags to assembler flags for module objects Date: Thu, 22 Aug 2024 14:19:38 -0400 Message-ID: <20240822181942.2626536-2-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240822181942.2626536-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> <20240822181942.2626536-1-kris.van.hees@oracle.com> X-ClientProxiedBy: SJ0PR05CA0098.namprd05.prod.outlook.com (2603:10b6:a03:334::13) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 2af56128-1bae-4aa5-dc4c-08dcc2d70189 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: SQ6IdGemHiMM7fmY6NjTI0tbsmYyMpfHYMSpRfJRYNQ9ih4XaJmU9nKwUWLp28oj0PbBLsp5engZ3u8y3vx6OzjIqJzpWmRyGgEjoZNaH9hXkmYshzYrqLn9jVv2bnIaUGzCG9GZdD38Vprr77eZ7g9PZafCrGF5tKM7nggzFe6Py9mtT5URDYC2pPkHU7Hfgtcb1lARHwnr4J2e0mTVX1JVh6fZeNGd5Yq2kvrl/8UtJYGXVEO+ooC88l/GtN0GDAsMXROZHmdfZiAOyTbyj51lQ1Q2d6g0LuCCkfpgL74Gl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255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dyJYNW/ibhynA0JT/SJ9cg6cPva+cPmL3un2QwFFSgQpeTDH7LSJC7qPLhFOlhRkuoSCnzDHBP2YMwU0mpIuBqxDu9AJTPGuk3fNGiAKRoRUiZaDDhrRlTYohT7AITASlgzA6oj/ixX5XXiypwAANmUl8BpIQrnmbK1s+xnk4+BhLn1Mg8mlolV6rFCN3F6bxevf6ygtKHyucF54HWRylTX+UcwMEKlOVWJUzZLb2viDTCPqUipfncLrzx0uPYqZEqXpgEZuxW3U25csBUpl5Jm5YMi+VTbgfPUioeD9sNt7W/V+cyyW+pD98MS/s0ZZP9mbalRe2L2bBgKUN8/5UcaJUYTBKg12cdey7A5qcIQVEWzpD8sEcarS4oBBeyoTUmbu9IPojY22k+oO/i9GDLOJ3BCDfPJrWhvH6qx6NuCcf6C9tkIRzhql+l5mTgkNGoyqt56iDNNft6r1KaJRKvj3zc/mwuBtQsOAEN1qh22eR5qU6o1kovFHBrfRMK6GL1K+A4xnj06kiyZlQE+Sq8XgQeXB7aeWa16ULKKFKPm6N0mbiRsZaoW9JQwVpTEvz4AgMR0cz4fQ+GhD9z5OPio3pFj2+g82wsE4bNTNj+xinnb6pMpdp3lF+MdWXN0OeKApWGA6DWn/FSv0RFJxd+7k+KDSy/XU9ZT/uZaiefH6qQnnQYRfz7dXL6oc/yJbZLv0HvcGeHMVwnm6l05r/kT9hW/6M/9oVkmvuM0z5PX8ozoYUd/ljyZePhI6Hnm1F0v6+d4OaePXhmd3jDrsaX0Q1PkBBsgghNenBqHP2EvXFoMcGaKGtcFFkAHlYkDutM80srW2Q39LSZTNo8banPzQLL2CeQTOJ1FRrPEp1dcQ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qI7yxuJNPB0lS8grDLPIf25+wvjEvAU9kSIM9DaClnkI2Dz8HgY+l/DlhPGVN/0YRdw+U1UGQpCQYdV/qqY8T8QrtuIRnKD08fS2kdvvkJ0EDJNtV7LRFdN9T53ww0S0iKp7x3zCL+4Efgf9RfNrxO7qK5Sb6xjIzms/t+ISr9+VkCNlSQhRttM1pZsJZh4g8cbQ3GYWCntOneNnRhW7Nry/tvLy3HrBunGixLmxb3FEdvojKtTg7fgYEedbPGz+73c9g4coc4vkt/e/WamQQhHK56rYjy32xRE9JhkjgIfSR0likSwiGq/tfnwb1SsdHBqaoLGJF+9dw8cW7p2NQMOZqfHthZqXxaG7WhgXRJlnid9ElgGHbWg41thi+Xj4eUo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2af56128-1bae-4aa5-dc4c-08dcc2d70189 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 18:19:48.0223 (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: W/tPuF8z/8lxSUNrsZxxjIhC7QLFxVQUbXAecYsqRoWSV5rBhziIAkAT+8Kfmmhp3flopVDj+A55pPIKyq99h1YOpUJHJtZWzixA+FlScwM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5004 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=908 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220137 X-Proofpoint-ORIG-GUID: pqDio7yPn2YW08FGxIoeI7f4CTnADzye X-Proofpoint-GUID: pqDio7yPn2YW08FGxIoeI7f4CTnADzye In order to create the file at build time, modules.builtin.ranges, that contains the range of addresses for all built-in modules, there needs to be a way to identify what code is compiled into modules. To identify what code is compiled into modules during a kernel build, one can look for the presence of the -DKBUILD_MODFILE and -DKBUILD_MODNAME options in the compile command lines. A simple grep in .*.cmd files for those options is sufficient for this. Unfortunately, these options are only passed when compiling C source files. Various modules also include objects built from assembler source, and these options are not passed in that case. Adding $(modfile_flags) to modkern_aflags (similar to modkern_cflahs), and adding $(modname_flags) to a_flags (similar to c_flags) makes it possible to identify which objects are compiled into modules for both C and assembler soure files. Signed-off-by: Kris Van Hees Reviewed-by: Steven Rostedt (Google) --- scripts/Makefile.lib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index fe3668dc4954..170f462537a8 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -238,7 +238,7 @@ modkern_rustflags = \ modkern_aflags = $(if $(part-of-module), \ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ - $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) + $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(modfile_flags)) c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ -include $(srctree)/include/linux/compiler_types.h \ @@ -248,7 +248,7 @@ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ rust_flags = $(_rust_flags) $(modkern_rustflags) @$(objtree)/include/generated/rustc_cfg a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(_a_flags) $(modkern_aflags) + $(_a_flags) $(modkern_aflags) $(modname_flags) cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ $(_cpp_flags) From patchwork Thu Aug 22 18:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13774070 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C156F1D04B0; Thu, 22 Aug 2024 18:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350839; cv=fail; b=bGc+gNDefLtUIYnmIU0qcnXHGVg5CL0dJwF3Ar6c7kbGeZ9UR6Za1gsGzGqzJLrX6a49u6g2NbvSeL1OhMWQQNGO/WTrNTTXfupFIMCyLy7rjYAAjZmBdtHpFnFs5A5OPb6aUgq7UTWQqIo1L7PCi0lPsazzd8tosWrg8TRFmKM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350839; c=relaxed/simple; bh=6L7BuguLaJmQdbJfo4zl/HDeuONHqdVXaWunc96KN6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=iqLbGj+1J4tUWuII5WknDGQW5hpdBAVjdk/EpZ4mmydyOw8D0LO8SmhqcZK8+OqUN6CETRA+nQZz5kjUROjbL9Pl6SBO2PfnSQrQAHQhqH2mP5g9FBpm+kvVRXPtcPLKXRyoJjBxvfzZR2QhGWEPJT4vDC7ZKcy+xVwnyepITp0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=YGRWfgFt; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=orEof+vO; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YGRWfgFt"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="orEof+vO" 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 47MEQTwY015889; Thu, 22 Aug 2024 18:20:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=0eESh84zAxo9nnhjHjmEZpccQPf1SAR7eI7W3PsYhrk=; b= YGRWfgFtcVvLeon6kPIABvJDd8b8ulCPx72jCdjGWzIvBmCxaMK8/ruMDi5g57y7 LClFiscYMa1Nt4QbFyep39UAuTG4F5pAq8yLl/tvvGGVl6ghwxWJeZuMUptYAKEb 2Z8k7EJ3ysLKFWv1BmxdUcA7CgSToakpp8THx8rCHV+DES/5aw1QWhJbWvTC7/UN pZ7d5Dyr4W/n+z2eB5/OlNYKrxL9LJxaxANQoEkTsY/tTQEe5jhyUezh8Yn+NbP7 WoeY8m1bym6L4nHYBjqk/eBm0qzC1TfzM8cMjGo4SzgXw/1QNWde4olvRwPaxmvH vMaE9gkTk471UDCaFrmOWw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m3du0np-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:27 +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 47MIDfRG027865; Thu, 22 Aug 2024 18:20:26 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416947mahm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zAcVh06Sgxa//7wE9cxDdn/8KOX7qsZq7dfTnKG4QxXfxSa0y130Jm4kehMO6n3/p3o4onssNB+eYuL0NCIwYTiRifDaZUGwxAzdHvKQfCvMiXusDOD1QOieq7F/x5VzlbKsb7vpLE+xCqyDYfxF8gx9J81bzWBKjWr5blc5sJnI6gvzeJBVBVM+cqmvECu0ZM0XEn6awnY9k5PKNAdQmMEvLCdwN9vKys+PqAEKBn4udfowePlQ/k07fY8+yiFTO3xiM71HN9/+pEveOnrcuAV6YSeaI3SAGaQ8VQSB8jhyPMckIo+Xr+srNG9yzupmLmFiq6KveEjiQvLpCg137A== 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=0eESh84zAxo9nnhjHjmEZpccQPf1SAR7eI7W3PsYhrk=; b=KCNx88GwbeqljCjkvJulSv/3UFG1UvbJiElBBrBC3WBsKyztKVf2QQi3dCWl31bmKEvBH3EcKb2Tqs96mMBAArF2tfiWLM4B7nwD9H4c1EAuyER3T930o0dq2eACZqwpdCpXbr+CJYUV1IeOfFwEKqCM5y5I4hcnM7BtNA1yZ+Z4fYxgv6gOkINzO0OR+viPyylopQp0vxnYz0Hn/+leEb3gD8RtDkW9eOfAePCMaFZx9PB42BBjb6ldg9qAUkHItrPgV3aVnpNFR4dAB4X+MIPFuZwLOWghmBn5D9MHNQGr5bbkW4wtHAgf8Ym7vfzgZvN/GBMwVdHmb4HVBnFxpQ== 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=0eESh84zAxo9nnhjHjmEZpccQPf1SAR7eI7W3PsYhrk=; b=orEof+vOiBVpYNrR2dF7ldU5ActLQ3kvLdonOiqu9WhCpQV4fZFbtEJ6kAwmKun0cnd/W9sN+DEy0hA3VepPMgyBTJK0gtU3mLtBvwpxQcOphb9tPsp3XZJpCoMC0NNkC0K1fab00RPKrjPQ/VvU1uxRmhU4C6vB5vfrQWM0RpE= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB5004.namprd10.prod.outlook.com (2603:10b6:610:de::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 18:19:51 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 22 Aug 2024 18:19:51 +0000 From: Kris Van Hees To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Kris Van Hees , Nick Alcock , Alan Maguire , Steven Rostedt , Masahiro Yamada , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v8 2/4] kbuild: generate offset range data for builtin modules Date: Thu, 22 Aug 2024 14:19:39 -0400 Message-ID: <20240822181942.2626536-3-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240822181942.2626536-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> <20240822181942.2626536-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BY5PR20CA0005.namprd20.prod.outlook.com (2603:10b6:a03:1f4::18) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 96537146-28f4-45ce-e9e5-08dcc2d7026c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: aE3cHE8utSMW8YtdgMz3M9GoXS06qWgJxdmyNSnMSi8syG5/PWO1wz1TfyBCsVyMYR8imVfkx3/VV2j8ozr4Tjn/rHJzNq1zvJxiknTuesNO9McUTUo6EzkbC0S/4sK50JE1SLAiLJXpy0eb8RNP8YC41z7CeyjNM5n3UENVLvl7LXzhkqJt35glEsftH/nIvSVtVaRDUJ+Hx7GFdOJ/62vHpsU3XmKYkuflOv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BhJxOygZcaIBAqtYsG7R/4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UNiaYF/l0ZygsGeo2gY7N3gN2kZYr+FP52SGvD3vAYWA4yaBnUy/ObR3s7RVVWmzrBx8hFhEPS3Pd4FpHDCjWTWhYX4rTm3w49qm2apdLrZ5fARNuBS9n4Tmq66KLkrIfY6Uwz86osxdkU3gaFjliJ9ePylKfoa0SvJtihE1rmeZJdcr6uqo/TXoMiNpqGZI+vm7GDjXtBbjm5GZqOugRHAasfsNUrq6R5dS64U+nIlolIg9rDa9AzfK5x+LQrnTflBmhy2wdtr3ketSJZ+6LcfY3+8+45mDQRz91rEnlHFZLCfewAm/4skE1PWoy+3jLDmVeGlUYlRc7+/Y0PX9NXSV7inm609SiFHgJZQiHCb19jEYSQx0g1R9RwyOPh+ezekElcq16LKXDL157aFQvwOPu0kfMb+9JyntH4A7WLwYzMZhidqNwFk63N3LFfGC2aWfO5qz2pqgma6Roklmk3TJX/pjGLEROoV3/zqF5S7o+nXFN2L5OeQ7YOC+88J91lr7CjpWaG2lSBM+jvuEHGuEZqyazrT0ve2usqS02ddvNfjZ9QUgCMVmcxYBRcxnK66tb3df9o9XXznO70azyrU8N5Up0DNqKMdFPDA8SoprEt2pN1XQjeEupxMNWsmxtXdvS9Iuo8E87aGn1LgNupFjAHVyTlA6iex/uLS3W9DodljgFQ6AHdG11uwmTjKXjT/aCGBbw7R1KxI1nsxjqaXw0twrJXQ5W41ChP25OycdNuIO+4f/1YmjQnct7SXnkPcc4LXKnOc3SMc4KfldzUPhWn5v1JfNOIWwz9EPYIblZALYoNi8WyMvrL+vvKz4RUboRkYhcRb3ec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EwrJJmuBZqxcMW2xdYhTi85bn2BKhuwkl3Pd9VgNTpRNGYbrKFfyb5hlrswE7Ra7bbjpDaLRZMPK9WMRzWKc2tL/JpBY2EW0d4T+ubD1LZjFVKY56bpr0oK5bM0/QTIyK4qT4D9qbJ13nmMpsnKy9awPct6bPT06zPRATNF2LmyysqOLHhi3EKPpb61QGBuAK+Zwea/NPnjsG9WN9KnEvL0Mm+gPHONmoWyzInB9nLerJKnjNIOvPrIfYsUz9l4fCftZ1n9EPBIgV5VcNpKZrpkwTI/XuNg0z8euUfqDvDA33qxWs5ADmUIywcSTpnqNFrD1UfT+snJjYlEaohdmO3pY31+mQhKf+q8jwncIjg56KODNX8sjgFnwNHyo7mKbQpDiOL6HGfDo3AJdu/hIc51CnQE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96537146-28f4-45ce-e9e5-08dcc2d7026c X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 18:19:49.5463 (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: Q4Hr2bj7gZ1md30apMEtdB7PjZIvEx2/WkPo4N8Wkp+VNE2rYnVpub2jrRMKow3dOFzXbb79/6nlozubOejbQzvMmKtvTZcILCAhP01Q0XM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5004 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220137 X-Proofpoint-ORIG-GUID: XkXKBjbo6GuJ79AXPOIleGRahCdWILjq X-Proofpoint-GUID: XkXKBjbo6GuJ79AXPOIleGRahCdWILjq Create file module.builtin.ranges that can be used to find where built-in modules are located by their addresses. This will be useful for tracing tools to find what functions are for various built-in modules. The offset range data for builtin modules is generated using: - modules.builtin: associates object files with module names - vmlinux.map: provides load order of sections and offset of first member per section - vmlinux.o.map: provides offset of object file content per section - .*.cmd: build cmd file with KBUILD_MODFILE The generated data will look like: .text 00000000-00000000 = _text .text 0000baf0-0000cb10 amd_uncore .text 0009bd10-0009c8e0 iosf_mbi ... .text 00b9f080-00ba011a intel_skl_int3472_discrete .text 00ba0120-00ba03c0 intel_skl_int3472_discrete intel_skl_int3472_tps68470 .text 00ba03c0-00ba08d6 intel_skl_int3472_tps68470 ... .data 00000000-00000000 = _sdata .data 0000f020-0000f680 amd_uncore For each ELF section, it lists the offset of the first symbol. This can be used to determine the base address of the section at runtime. Next, it lists (in strict ascending order) offset ranges in that section that cover the symbols of one or more builtin modules. Multiple ranges can apply to a single module, and ranges can be shared between modules. The CONFIG_BUILTIN_MODULE_RANGES option controls whether offset range data is generated for kernel modules that are built into the kernel image. How it works: 1. The modules.builtin file is parsed to obtain a list of built-in module names and their associated object names (the .ko file that the module would be in if it were a loadable module, hereafter referred to as ). This object name can be used to identify objects in the kernel compile because any C or assembler code that ends up into a built-in module will have the option -DKBUILD_MODFILE= present in its build command, and those can be found in the ..cmd file in the kernel build tree. If an object is part of multiple modules, they will all be listed in the KBUILD_MODFILE option argument. This allows us to conclusively determine whether an object in the kernel build belong to any modules, and which. 2. The vmlinux.map is parsed next to determine the base address of each top level section so that all addresses into the section can be turned into offsets. This makes it possible to handle sections getting loaded at different addresses at system boot. We also determine an 'anchor' symbol at the beginning of each section to make it possible to calculate the true base address of a section at runtime (i.e. symbol address - symbol offset). We collect start addresses of sections that are included in the top level section. This is used when vmlinux is linked using vmlinux.o, because in that case, we need to look at the vmlinux.o linker map to know what object a symbol is found in. And finally, we process each symbol that is listed in vmlinux.map (or vmlinux.o.map) based on the following structure: vmlinux linked from vmlinux.a: vmlinux.map: -- might be same as top level section) -- built-in association known -- belongs to module(s) object belongs to ... vmlinux linked from vmlinux.o: vmlinux.map: -- might be same as top level section) vmlinux.o -- need to use vmlinux.o.map -- ignored ... vmlinux.o.map:
-- built-in association known -- belongs to module(s) object belongs to ... 3. As sections, objects, and symbols are processed, offset ranges are constructed in a striaght-forward way: - If the symbol belongs to one or more built-in modules: - If we were working on the same module(s), extend the range to include this object - If we were working on another module(s), close that range, and start the new one - If the symbol does not belong to any built-in modules: - If we were working on a module(s) range, close that range Signed-off-by: Kris Van Hees Reviewed-by: Nick Alcock Reviewed-by: Alan Maguire Reviewed-by: Steven Rostedt (Google) --- Changes since v7: - Removed extra close(fn). - Make CONFIG_BUILTIN_MODULE_RANGES depend on !lTO. Changes since v6: - Applied Masahiro Yamada's suggestions (Kconfig, makefile, script). Changes since v5: - Removed unnecessary compatibility info from option description. Changes since v4: - Improved commit description to explain the why and how. - Documented dependency on GNU AWK for CONFIG_BUILTIN_MODULE_RANGES. - Improved comments in generate_builtin_ranges.awk - Improved logic in generate_builtin_ranges.awk to handle incorrect object size information in linker maps Changes since v3: - Consolidated patches 2 through 5 into a single patch - Move CONFIG_BUILTIN_MODULE_RANGES to Kconfig.debug - Make CONFIG_BUILTIN_MODULE_RANGES select CONFIG_VMLINUX_MAP - Disable CONFIG_BUILTIN_MODULE_RANGES if CONFIG_LTO_CLANG_(FULL|THIN)=y - Support LLVM (lld) compiles in generate_builtin_ranges.awk - Support CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y Changes since v2: - Add explicit dependency on FTRACE for CONFIG_BUILTIN_MODULE_RANGES - 1st arg to generate_builtin_ranges.awk is now modules.builtin.modinfo - Switched from using modules.builtin.objs to parsing .*.cmd files - Parse data from .*.cmd in generate_builtin_ranges.awk - Use $(real-prereqs) rather than $(filter-out ...) --- Documentation/process/changes.rst | 7 + lib/Kconfig.debug | 15 + scripts/Makefile.vmlinux | 18 + scripts/Makefile.vmlinux_o | 3 + scripts/generate_builtin_ranges.awk | 505 ++++++++++++++++++++++++++++ 5 files changed, 548 insertions(+) create mode 100755 scripts/generate_builtin_ranges.awk diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 3fc63f27c226..00f1ed7c59c3 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -64,6 +64,7 @@ GNU tar 1.28 tar --version gtags (optional) 6.6.5 gtags --version mkimage (optional) 2017.01 mkimage --version Python (optional) 3.5.x python3 --version +GNU AWK (optional) 5.1.0 gawk --version ====================== =============== ======================================== .. [#f1] Sphinx is needed only to build the Kernel documentation @@ -192,6 +193,12 @@ platforms. The tool is available via the ``u-boot-tools`` package or can be built from the U-Boot source code. See the instructions at https://docs.u-boot.org/en/latest/build/tools.html#building-tools-for-linux +GNU AWK +------- + +GNU AWK is needed if you want kernel builds to generate address range data for +builtin modules (CONFIG_BUILTIN_MODULE_RANGES). + System utilities **************** diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a30c03a66172..5e2f30921cb2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -571,6 +571,21 @@ config VMLINUX_MAP pieces of code get eliminated with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. +config BUILTIN_MODULE_RANGES + bool "Generate address range information for builtin modules" + depends on !LTO + depends on VMLINUX_MAP + help + When modules are built into the kernel, there will be no module name + associated with its symbols in /proc/kallsyms. Tracers may want to + identify symbols by module name and symbol name regardless of whether + the module is configured as loadable or not. + + This option generates modules.builtin.ranges in the build tree with + offset ranges (per ELF section) for the module(s) they belong to. + It also records an anchor symbol to determine the load address of the + section. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNEL diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 49946cb96844..7e8b703799c8 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -33,6 +33,24 @@ targets += vmlinux vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) +# module.builtin.ranges +# --------------------------------------------------------------------------- +ifdef CONFIG_BUILTIN_MODULE_RANGES +__default: modules.builtin.ranges + +quiet_cmd_modules_builtin_ranges = GEN $@ + cmd_modules_builtin_ranges = $(real-prereqs) > $@ + +targets += modules.builtin.ranges +modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ + modules.builtin vmlinux.map vmlinux.o.map FORCE + $(call if_changed,modules_builtin_ranges) + +vmlinux.map: vmlinux + @: + +endif + # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 6de297916ce6..252505505e0e 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -45,9 +45,12 @@ objtool-args = $(vmlinux-objtool-args-y) --link # Link of vmlinux.o used for section mismatch analysis # --------------------------------------------------------------------------- +vmlinux-o-ld-args-$(CONFIG_BUILTIN_MODULE_RANGES) += -Map=$@.map + quiet_cmd_ld_vmlinux.o = LD $@ cmd_ld_vmlinux.o = \ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \ + $(vmlinux-o-ld-args-y) \ $(addprefix -T , $(initcalls-lds)) \ --whole-archive vmlinux.a --no-whole-archive \ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ diff --git a/scripts/generate_builtin_ranges.awk b/scripts/generate_builtin_ranges.awk new file mode 100755 index 000000000000..68df05fd3036 --- /dev/null +++ b/scripts/generate_builtin_ranges.awk @@ -0,0 +1,505 @@ +#!/usr/bin/gawk -f +# SPDX-License-Identifier: GPL-2.0 +# generate_builtin_ranges.awk: Generate address range data for builtin modules +# Written by Kris Van Hees +# +# Usage: generate_builtin_ranges.awk modules.builtin vmlinux.map \ +# vmlinux.o.map > modules.builtin.ranges +# + +# Return the module name(s) (if any) associated with the given object. +# +# If we have seen this object before, return information from the cache. +# Otherwise, retrieve it from the corresponding .cmd file. +# +function get_module_info(fn, mod, obj, s) { + if (fn in omod) + return omod[fn]; + + if (match(fn, /\/[^/]+$/) == 0) + return ""; + + obj = fn; + mod = ""; + fn = substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; + if (getline s 0) { + mod = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mod); + } + } + close(fn); + + # A single module (common case) also reflects objects that are not part + # of a module. Some of those objects have names that are also a module + # name (e.g. core). We check the associated module file name, and if + # they do not match, the object is not part of a module. + if (mod !~ / /) { + if (!(mod in mods)) + mod = ""; + } + + gsub(/([^/ ]*\/)+/, "", mod); + gsub(/-/, "_", mod); + + # At this point, mod is a single (valid) module name, or a list of + # module names (that do not need validation). + omod[obj] = mod; + + return mod; +} + +# Update the ranges entry for the given module 'mod' in section 'osect'. +# +# We use a modified absolute start address (soff + base) as index because we +# may need to insert an anchor record later that must be at the start of the +# section data, and the first module may very well start at the same address. +# So, we use (addr << 1) + 1 to allow a possible anchor record to be placed at +# (addr << 1). This is safe because the index is only used to sort the entries +# before writing them out. +# +function update_entry(osect, mod, soff, eoff, sect, idx) { + sect = sect_in[osect]; + idx = (soff + sect_base[osect]) * 2 + 1; + entries[idx] = sprintf("%s %08x-%08x %s", sect, soff, eoff, mod); + count[sect]++; +} + +# (1) Build a lookup map of built-in module names. +# +# The first file argument is used as input (modules.builtin). +# +# Lines will be like: +# kernel/crypto/lzo-rle.ko +# and we record the object name "crypto/lzo-rle". +# +ARGIND == 1 { + sub(/kernel\//, ""); # strip off "kernel/" prefix + sub(/\.ko$/, ""); # strip off .ko suffix + + mods[$1] = 1; + next; +} + +# (2) Collect address information for each section. +# +# The second file argument is used as input (vmlinux.map). +# +# We collect the base address of the section in order to convert all addresses +# in the section into offset values. +# +# We collect the address of the anchor (or first symbol in the section if there +# is no explicit anchor) to allow users of the range data to calculate address +# ranges based on the actual load address of the section in the running kernel. +# +# We collect the start address of any sub-section (section included in the top +# level section being processed). This is needed when the final linking was +# done using vmlinux.a because then the list of objects contained in each +# section is to be obtained from vmlinux.o.map. The offset of the sub-section +# is recorded here, to be used as an addend when processing vmlinux.o.map +# later. +# + +# Both GNU ld and LLVM lld linker map format are supported by converting LLVM +# lld linker map records into equivalent GNU ld linker map records. +# +# The first record of the vmlinux.map file provides enough information to know +# which format we are dealing with. +# +ARGIND == 2 && FNR == 1 && NF == 7 && $1 == "VMA" && $7 == "Symbol" { + map_is_lld = 1; + if (dbg) + printf "NOTE: %s uses LLVM lld linker map format\n", FILENAME >"/dev/stderr"; + next; +} + +# (LLD) Convert a section record fronm lld format to ld format. +# +# lld: ffffffff82c00000 2c00000 2493c0 8192 .data +# -> +# ld: .data 0xffffffff82c00000 0x2493c0 load address 0x0000000002c00000 +# +ARGIND == 2 && map_is_lld && NF == 5 && /[0-9] [^ ]+$/ { + $0 = $5 " 0x"$1 " 0x"$3 " load address 0x"$2; +} + +# (LLD) Convert an anchor record from lld format to ld format. +# +# lld: ffffffff81000000 1000000 0 1 _text = . +# -> +# ld: 0xffffffff81000000 _text = . +# +ARGIND == 2 && map_is_lld && !anchor && NF == 7 && raw_addr == "0x"$1 && $6 == "=" && $7 == "." { + $0 = " 0x"$1 " " $5 " = ."; +} + +# (LLD) Convert an object record from lld format to ld format. +# +# lld: 11480 11480 1f07 16 vmlinux.a(arch/x86/events/amd/uncore.o):(.text) +# -> +# ld: .text 0x0000000000011480 0x1f07 arch/x86/events/amd/uncore.o +# +ARGIND == 2 && map_is_lld && NF == 5 && $5 ~ /:\(/ { + gsub(/\)/, ""); + sub(/ vmlinux\.a\(/, " "); + sub(/:\(/, " "); + $0 = " "$6 " 0x"$1 " 0x"$3 " " $5; +} + +# (LLD) Convert a symbol record from lld format to ld format. +# +# We only care about these while processing a section for which no anchor has +# been determined yet. +# +# lld: ffffffff82a859a4 2a859a4 0 1 btf_ksym_iter_id +# -> +# ld: 0xffffffff82a859a4 btf_ksym_iter_id +# +ARGIND == 2 && map_is_lld && sect && !anchor && NF == 5 && $5 ~ /^[_A-Za-z][_A-Za-z0-9]*$/ { + $0 = " 0x"$1 " " $5; +} + +# (LLD) We do not need any other ldd linker map records. +# +ARGIND == 2 && map_is_lld && /^[0-9a-f]{16} / { + next; +} + +# (LD) Section records with just the section name at the start of the line +# need to have the next line pulled in to determine whether it is a +# loadable section. If it is, the next line will contains a hex value +# as first and second items. +# +ARGIND == 2 && !map_is_lld && NF == 1 && /^[^ ]/ { + s = $0; + getline; + if ($1 !~ /^0x/ || $2 !~ /^0x/) + next; + + $0 = s " " $0; +} + +# (LD) Object records with just the section name denote records with a long +# section name for which the remainder of the record can be found on the +# next line. +# +# (This is also needed for vmlinux.o.map, when used.) +# +ARGIND >= 2 && !map_is_lld && NF == 1 && /^ [^ \*]/ { + s = $0; + getline; + $0 = s " " $0; +} + +# Beginning a new section - done with the previous one (if any). +# +ARGIND == 2 && /^[^ ]/ { + sect = 0; +} + +# Process a loadable section (we only care about .-sections). +# +# Record the section name and its base address. +# We also record the raw (non-stripped) address of the section because it can +# be used to identify an anchor record. +# +# Note: +# Since some AWK implementations cannot handle large integers, we strip off the +# first 4 hex digits from the address. This is safe because the kernel space +# is not large enough for addresses to extend into those digits. The portion +# to strip off is stored in addr_prefix as a regexp, so further clauses can +# perform a simple substitution to do the address stripping. +# +ARGIND == 2 && /^\./ { + # Explicitly ignore a few sections that are not relevant here. + if ($1 ~ /^\.orc_/ || $1 ~ /_sites$/ || $1 ~ /\.percpu/) + next; + + # Sections with a 0-address can be ignored as well. + if ($2 ~ /^0x0+$/) + next; + + raw_addr = $2; + addr_prefix = "^" substr($2, 1, 6); + base = $2; + sub(addr_prefix, "0x", base); + base = strtonum(base); + sect = $1; + anchor = 0; + sect_base[sect] = base; + sect_size[sect] = strtonum($3); + + if (dbg) + printf "[%s] BASE %016x\n", sect, base >"/dev/stderr"; + + next; +} + +# If we are not in a section we care about, we ignore the record. +# +ARGIND == 2 && !sect { + next; +} + +# Record the first anchor symbol for the current section. +# +# An anchor record for the section bears the same raw address as the section +# record. +# +ARGIND == 2 && !anchor && NF == 4 && raw_addr == $1 && $3 == "=" && $4 == "." { + anchor = sprintf("%s %08x-%08x = %s", sect, 0, 0, $2); + sect_anchor[sect] = anchor; + + if (dbg) + printf "[%s] ANCHOR %016x = %s (.)\n", sect, 0, $2 >"/dev/stderr"; + + next; +} + +# If no anchor record was found for the current section, use the first symbol +# in the section as anchor. +# +ARGIND == 2 && !anchor && NF == 2 && $1 ~ /^0x/ && $2 !~ /^0x/ { + addr = $1; + sub(addr_prefix, "0x", addr); + addr = strtonum(addr) - base; + anchor = sprintf("%s %08x-%08x = %s", sect, addr, addr, $2); + sect_anchor[sect] = anchor; + + if (dbg) + printf "[%s] ANCHOR %016x = %s\n", sect, addr, $2 >"/dev/stderr"; + + next; +} + +# The first occurence of a section name in an object record establishes the +# addend (often 0) for that section. This information is needed to handle +# sections that get combined in the final linking of vmlinux (e.g. .head.text +# getting included at the start of .text). +# +# If the section does not have a base yet, use the base of the encapsulating +# section. +# +ARGIND == 2 && sect && NF == 4 && /^ [^ \*]/ && !($1 in sect_addend) { + if (!($1 in sect_base)) { + sect_base[$1] = base; + + if (dbg) + printf "[%s] BASE %016x\n", $1, base >"/dev/stderr"; + } + + addr = $2; + sub(addr_prefix, "0x", addr); + addr = strtonum(addr); + sect_addend[$1] = addr - sect_base[$1]; + sect_in[$1] = sect; + + if (dbg) + printf "[%s] ADDEND %016x - %016x = %016x\n", $1, addr, base, sect_addend[$1] >"/dev/stderr"; + + # If the object is vmlinux.o then we will need vmlinux.o.map to get the + # actual offsets of objects. + if ($4 == "vmlinux.o") + need_o_map = 1; +} + +# (3) Collect offset ranges (relative to the section base address) for built-in +# modules. +# +# If the final link was done using the actual objects, vmlinux.map contains all +# the information we need (see section (3a)). +# If linking was done using vmlinux.a as intermediary, we will need to process +# vmlinux.o.map (see section (3b)). + +# (3a) Determine offset range info using vmlinux.map. +# +# Since we are already processing vmlinux.map, the top level section that is +# being processed is already known. If we do not have a base address for it, +# we do not need to process records for it. +# +# Given the object name, we determine the module(s) (if any) that the current +# object is associated with. +# +# If we were already processing objects for a (list of) module(s): +# - If the current object belongs to the same module(s), update the range data +# to include the current object. +# - Otherwise, ensure that the end offset of the range is valid. +# +# If the current object does not belong to a built-in module, ignore it. +# +# If it does, we add a new built-in module offset range record. +# +ARGIND == 2 && !need_o_map && /^ [^ ]/ && NF == 4 && $3 != "0x0" { + if (!(sect in sect_base)) + next; + + # Turn the address into an offset from the section base. + soff = $2; + sub(addr_prefix, "0x", soff); + soff = strtonum(soff) - sect_base[sect]; + eoff = soff + strtonum($3); + + # Determine which (if any) built-in modules the object belongs to. + mod = get_module_info($4); + + # If we are processing a built-in module: + # - If the current object is within the same module, we update its + # entry by extending the range and move on + # - Otherwise: + # + If we are still processing within the same main section, we + # validate the end offset against the start offset of the + # current object (e.g. .rodata.str1.[18] objects are often + # listed with an incorrect size in the linker map) + # + Otherwise, we validate the end offset against the section + # size + if (mod_name) { + if (mod == mod_name) { + mod_eoff = eoff; + update_entry(mod_sect, mod_name, mod_soff, eoff); + + next; + } else if (sect == sect_in[mod_sect]) { + if (mod_eoff > soff) + update_entry(mod_sect, mod_name, mod_soff, soff); + } else { + v = sect_size[sect_in[mod_sect]]; + if (mod_eoff > v) + update_entry(mod_sect, mod_name, mod_soff, v); + } + } + + mod_name = mod; + + # If we encountered an object that is not part of a built-in module, we + # do not need to record any data. + if (!mod) + next; + + # At this point, we encountered the start of a new built-in module. + mod_name = mod; + mod_soff = soff; + mod_eoff = eoff; + mod_sect = $1; + update_entry($1, mod, soff, mod_eoff); + + next; +} + +# If we do not need to parse the vmlinux.o.map file, we are done. +# +ARGIND == 3 && !need_o_map { + if (dbg) + printf "Note: %s is not needed.\n", FILENAME >"/dev/stderr"; + exit; +} + +# (3) Collect offset ranges (relative to the section base address) for built-in +# modules. +# + +# (LLD) Convert an object record from lld format to ld format. +# +ARGIND == 3 && map_is_lld && NF == 5 && $5 ~ /:\(/ { + gsub(/\)/, ""); + sub(/:\(/, " "); + + sect = $6; + if (!(sect in sect_addend)) + next; + + sub(/ vmlinux\.a\(/, " "); + $0 = " "sect " 0x"$1 " 0x"$3 " " $5; +} + +# (3b) Determine offset range info using vmlinux.o.map. +# +# If we do not know an addend for the object's section, we are interested in +# anything within that section. +# +# Determine the top-level section that the object's section was included in +# during the final link. This is the section name offset range data will be +# associated with for this object. +# +# The remainder of the processing of the current object record follows the +# procedure outlined in (3a). +# +ARGIND == 3 && /^ [^ ]/ && NF == 4 && $3 != "0x0" { + osect = $1; + if (!(osect in sect_addend)) + next; + + # We need to work with the main section. + sect = sect_in[osect]; + + # Turn the address into an offset from the section base. + soff = $2; + sub(addr_prefix, "0x", soff); + soff = strtonum(soff) + sect_addend[osect]; + eoff = soff + strtonum($3); + + # Determine which (if any) built-in modules the object belongs to. + mod = get_module_info($4); + + # If we are processing a built-in module: + # - If the current object is within the same module, we update its + # entry by extending the range and move on + # - Otherwise: + # + If we are still processing within the same main section, we + # validate the end offset against the start offset of the + # current object (e.g. .rodata.str1.[18] objects are often + # listed with an incorrect size in the linker map) + # + Otherwise, we validate the end offset against the section + # size + if (mod_name) { + if (mod == mod_name) { + mod_eoff = eoff; + update_entry(mod_sect, mod_name, mod_soff, eoff); + + next; + } else if (sect == sect_in[mod_sect]) { + if (mod_eoff > soff) + update_entry(mod_sect, mod_name, mod_soff, soff); + } else { + v = sect_size[sect_in[mod_sect]]; + if (mod_eoff > v) + update_entry(mod_sect, mod_name, mod_soff, v); + } + } + + mod_name = mod; + + # If we encountered an object that is not part of a built-in module, we + # do not need to record any data. + if (!mod) + next; + + # At this point, we encountered the start of a new built-in module. + mod_name = mod; + mod_soff = soff; + mod_eoff = eoff; + mod_sect = osect; + update_entry(osect, mod, soff, mod_eoff); + + next; +} + +# (4) Generate the output. +# +# Anchor records are added for each section that contains offset range data +# records. They are added at an adjusted section base address (base << 1) to +# ensure they come first in the second records (see update_entry() above for +# more informtion). +# +# All entries are sorted by (adjusted) address to ensure that the output can be +# parsed in strict ascending address order. +# +END { + for (sect in count) { + if (sect in sect_anchor) + entries[sect_base[sect] * 2] = sect_anchor[sect]; + } + + n = asorti(entries, indices); + for (i = 1; i <= n; i++) + print entries[indices[i]]; +} From patchwork Thu Aug 22 18:19:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13774068 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62D181D04A5; Thu, 22 Aug 2024 18:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350837; cv=fail; b=dx/lgMjwunfqNOGf04TyTGt/1Cy5V49IvbfcYBVrfNQvAKhe9ZhEHMyRyswSW+MnOyh9a2l8ugGCZpA1S/H9Fa6o1v3BarmRAjFh2BgyMZGVFxDDjbpzK+QBI4qlMU1RkWQOVvJyfigidCmY3nDgeHxjskkJ0VLpuHbJxI/SUuk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350837; c=relaxed/simple; bh=h5mF20ACqptj34Qr8bwLtsYxU159KJhwDZP0Vincmmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=aN7PTPgWFbEhNfY3XwfEAPD1OzrKL/lNT2ktGzlbOEckDfwFYMPE2SUYsnmeKwW2fP0jWyvVETTTpmlcZ1KWaIYhohZulg45lr4sUZrBMvw8ppHbxw3qqE2lFYgpND2R0bETQivy1h/nWAzJW2iXhABYmeYbK+3bL5aB8NrHuuo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=b+dEat+y; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BFJBMyoe; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="b+dEat+y"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BFJBMyoe" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MEQVnP013872; Thu, 22 Aug 2024 18:20:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ciwn49YsPsMBN7wKW8hbq2JMdqQgIdGqrakZQHG+pWI=; b= b+dEat+yiB9+gPOu8QnaOnI4iJMl1ZpcbJOHUSHhYBtUoh44c/hTHL+POgjxonSc 8+zJnvkIKsKktciVDEmmMsOVfuNWAjubD95kO9SvvMI+eSIFXpecIWT6nlmyG4xd SiWLbLz3Q2ppaV8u8nCEd2HtGuiO2v+CIEjkxHGN93DqwLvER67pSBt8c+zYg1A/ JGs6JIQpoGo8wYnH0cHcgFYbUtMYKe54cXoOxuxxdhAb2xkDdeBuDLFtIj829uIl VMuOyuYre0dH0w3MWmQjRthW6ejgMGRoPtHVD5HnJhFg4hGoGG6FqlezYs2QSIwf Pxv83h+U3Xvv4wdQgYegVA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m67jmgh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:28 +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 47MIDfRH027865; Thu, 22 Aug 2024 18:20:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416947mahm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RJx/PxlZwii5nday0WA77cQH55jkW4y6+NF/WMwjOd8ET9zaDvVh8X4opZMJgT9gCVsTFCkZEzTuEIG8IRFbyGcOItQ3TpxhLaKa3EvT+U9r/U1HPf8BU5WGN36PE0YUxfn2qHME2y8SUYYhHZQKb+6U4AUUgp6AHjs761PM7uxxjcOQqjFCxGrcLXSMWdTpjI1wu0e/+O8H2FT9z1UNRtZ/n7lyWKG8u/8IzJemmSp4udbLRbONo1IVqtcZhZqiBA/Qfqb6lqp3g6N3O7azsFQUohCB5HwynYuxBIwjjc6NAjD4UR7GbE3idHxuZSZUTHcu3PaHhOE2xOTDoxRd2w== 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=ciwn49YsPsMBN7wKW8hbq2JMdqQgIdGqrakZQHG+pWI=; b=JKZB7ptYcl254oKxlQg0K+aCxNIPiTxlzT4EBMYHq6tn//v/hHRxWpltqG0486B1gaxu2eAKhlgeaxzgLUxtlUHR6wgrwB9n1hO39cMQmtoqyTaoQ/6MhBUzbXdJGuuGwr/vdJyBgZ5x4J7giUd2f8WFo8LM49Ix808vPSzsjhDrGnuWJWm1+qwudzmT0/eosbDKVj6ghCwvuB5kmZzqk+jH1LDf7dihx4DXW3xhe1oadGML3qKQI1ZcN4Tdyr4mMHVDDnEj0L/KyILgTHVlfwNQ47CIeu1nFjVx8i+H3Ta5Y89GY/QVNovL2RTD/9Zcn0n4A4uZqej5orpsSzpBfA== 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=ciwn49YsPsMBN7wKW8hbq2JMdqQgIdGqrakZQHG+pWI=; b=BFJBMyoeHQth0l/AURNQ/KFCS7XNgaEt7NbHPnANayjG3EPRQYkP8qvZ2WyrjXZ53CjCwHG3QQivhVH7YI6dQp0uQ16Aw6CV+xEU0dOYHoZb58H5C/+GMIIHQi8nOBpEQDt26uOLgN5tS743BIZt6umuc6eVzr1dc1YQ8ghxZ6g= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB5004.namprd10.prod.outlook.com (2603:10b6:610:de::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 18:19:51 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 22 Aug 2024 18:19:51 +0000 From: Kris Van Hees To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Kris Van Hees , Nick Alcock , Alan Maguire , Masahiro Yamada , Steven Rostedt , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v8 3/4] scripts: add verifier script for builtin module range data Date: Thu, 22 Aug 2024 14:19:40 -0400 Message-ID: <20240822181942.2626536-4-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240822181942.2626536-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> <20240822181942.2626536-1-kris.van.hees@oracle.com> X-ClientProxiedBy: SJ0PR05CA0116.namprd05.prod.outlook.com (2603:10b6:a03:334::31) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 4714f9e6-4517-4152-5919-08dcc2d7033e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: YbjmoEbbVoXv//fugM8WGaQ3pqa5j+cS7MuxbttUfdsw9suGt1Tk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C68BEFFO1urczbT+VJIjFweTMMV+5148S3iwr8TogYTnzE65cIiBjq0ugoxjCIW2CibSmU96rmMKQ36QGURNDhkME9ltgLLI2AJNdH2uZe7gZQ3gUxcAovK6ThWuZyXvn3i8Pok0EUnzjJ/lGvX6K33F733s2GacDIUoza4o1esIO37kO0X7HzmNeG8+tW3o8cSVMeaGD3RRfr9syizUFgu6QyteKg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CUxopK0x1uR7unnNQ8RPn+JE2BNzb1mqLF92UJTJWAaC2UFFGgnY2SPQdeaxIcEEMugn9fUGwUO+KknwalKPxcCFKgS7Ufzah07Xuxtihj8w9wfdYp+XM9iZgW4D69jeAMuABazg2nGTOQ4BpOEC28qW1yvmMpSI8QfoWjs1XrE154ynzJuT8Bzr/eLQGNDZLUgcSpNOn9vDcKA5IGeALgDo571FTb8VrtR8QIp0+JgEMjLm2vs+70ki9iKpG4pwIjONrcddqjVof8cRRaLqrKypc9RCOt+8DrMK/bMmHvOoOmNGjDoqoKy4CcsDbQt9NWcf/grNlVzS4w8SW9FQwzdgZFGxTTrMOU45A56POzaLx56VrHyf+K3Evb6bQp2Oc0LcQTMbctrBi4BnidaW7Cv9bGxb9nv46qcIYXQyUfYciwgkU5T3Unfpe5/uR0WIw6wBsr9yJoHBY71OMcTTu6jw0cnKVEpe50hX5YH/L6cryh53Xtw4wk3J9BEZYBGN4gjHW03Wjqxw5ZaMrV+17BAcj9BOQv22C0maoympESTfYbNiHrgUYvqrs3UJZsSlYajWgqN+Y4KOqdhZZn3/+RgQREJlTMQGcPoGZ4K5WOx4E7O7YnwjCHJI7vU8pqRxid8eP1q1Qk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LMPKqPyYmmyUAFYTeq7scM+4uFfy8L903CkUsVVdgwYXrfk/MRJXKY8JPfcnsEuj3gc8OhEpL6+9vxVvkpIBs8e3sPoU6QyP/+nPHwcxP22yN+eRVKf2XZRQrzb5hV0gXcDfrRevDAjSZd4i1gL0B1a0zxhEgBfEon4REMhl+V+20vcHAFfmPL4lhkxkh58303MaUdmFMHbOAqCk/2oa6m7J/zhZe5OcxKZygqdwLsmaZB1yQ1UfSjhBhhYAFSIaq6mV/LBaTN1N286SIpui5szYn9a31O1dJORspv6B/T1b0z9+5hWsWwUXHcijeX/43sqW+G4g+g++hRAIrC5P9Gnmvz+t80HAqGbNHg6BKmcFBikRUeVSM98DUQblwv9WyA3SDqslekXQS7rsleZsCaVD5Zzrb7R0lH7mQe18y6XIQ47rCdVp0NUAp4LR9HV2oixEYgxKFajcjrkluulwJr3sukkiBoBHWpzVzXt7TIFKY7Sp/Amy3DRFHO2dOpGeVu0vG58o2niRrUTWddLkJlVScaAqxq9AH+GYdT5ioxU0nvTynwSMcA72ndPKZuwRmnCOwryhfbBcMDe+SNC1WgAnEybZYiM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4714f9e6-4517-4152-5919-08dcc2d7033e X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 18:19:50.9148 (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: pTR1Jq6EbpzcMD8c0Bb9wCds2965Z5Ss1E0i4K/mdkF+WeGx6j4OWmH9J1dA05MWMyCU961ypu7n/QSAHCIp+UUMPBSMyRvGnwID7SRRjIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5004 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220137 X-Proofpoint-ORIG-GUID: StMtz5OXgdZkR57g6-EfIWB4dtos3bsU X-Proofpoint-GUID: StMtz5OXgdZkR57g6-EfIWB4dtos3bsU The modules.builtin.ranges offset range data for builtin modules is generated at compile time based on the list of built-in modules and the vmlinux.map and vmlinux.o.map linker maps. This data can be used to determine whether a symbol at a particular address belongs to module code that was configured to be compiled into the kernel proper as a built-in module (rather than as a standalone module). This patch adds a script that uses the generated modules.builtin.ranges data to annotate the symbols in the System.map with module names if their address falls within a range that belongs to one or more built-in modules. It then processes the vmlinux.map (and if needed, vmlinux.o.map) to verify the annotation: - For each top-level section: - For each object in the section: - Determine whether the object is part of a built-in module (using modules.builtin and the .*.cmd file used to compile the object as suggested in [0]) - For each symbol in that object, verify that the built-in module association (or lack thereof) matches the annotation given to the symbol. Signed-off-by: Kris Van Hees Reviewed-by: Nick Alcock Reviewed-by: Alan Maguire --- Changes since v7: - Removed extra close(fn) Changes since v6: - Applied Masahiro Yamada's suggestions to the AWK script. Changes since v5: - Added optional 6th argument to specify kernel build directory. - Report error and exit if .*.o.cmd files cannot be read. Changes since v4: - New patch in the series --- scripts/verify_builtin_ranges.awk | 355 ++++++++++++++++++++++++++++++ 1 file changed, 355 insertions(+) create mode 100755 scripts/verify_builtin_ranges.awk diff --git a/scripts/verify_builtin_ranges.awk b/scripts/verify_builtin_ranges.awk new file mode 100755 index 000000000000..22717a4ab6c8 --- /dev/null +++ b/scripts/verify_builtin_ranges.awk @@ -0,0 +1,355 @@ +#!/usr/bin/gawk -f +# SPDX-License-Identifier: GPL-2.0 +# verify_builtin_ranges.awk: Verify address range data for builtin modules +# Written by Kris Van Hees +# +# Usage: verify_builtin_ranges.awk modules.builtin.ranges System.map \ +# modules.builtin vmlinux.map vmlinux.o.map \ +# [ ] +# + +# Return the module name(s) (if any) associated with the given object. +# +# If we have seen this object before, return information from the cache. +# Otherwise, retrieve it from the corresponding .cmd file. +# +function get_module_info(fn, mod, obj, s) { + if (fn in omod) + return omod[fn]; + + if (match(fn, /\/[^/]+$/) == 0) + return ""; + + obj = fn; + mod = ""; + fn = kdir "/" substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; + if (getline s 0) { + mod = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mod); + } + } else { + print "ERROR: Failed to read: " fn "\n\n" \ + " Invalid kernel build directory (" kdir ")\n" \ + " or its content does not match " ARGV[1] >"/dev/stderr"; + close(fn); + total = 0; + exit(1); + } + close(fn); + + # A single module (common case) also reflects objects that are not part + # of a module. Some of those objects have names that are also a module + # name (e.g. core). We check the associated module file name, and if + # they do not match, the object is not part of a module. + if (mod !~ / /) { + if (!(mod in mods)) + mod = ""; + } + + gsub(/([^/ ]*\/)+/, "", mod); + gsub(/-/, "_", mod); + + # At this point, mod is a single (valid) module name, or a list of + # module names (that do not need validation). + omod[obj] = mod; + + return mod; +} + +# Return a representative integer value for a given hexadecimal address. +# +# Since all kernel addresses fall within the same memory region, we can safely +# strip off the first 6 hex digits before performing the hex-to-dec conversion, +# thereby avoiding integer overflows. +# +function addr2val(val) { + sub(/^0x/, "", val); + if (length(val) == 16) + val = substr(val, 5); + return strtonum("0x" val); +} + +# Determine the kernel build directory to use (default is .). +# +BEGIN { + if (ARGC > 6) { + kdir = ARGV[ARGC - 1]; + ARGV[ARGC - 1] = ""; + } else + kdir = "."; +} + +# (1) Load the built-in module address range data. +# +ARGIND == 1 { + ranges[FNR] = $0; + rcnt++; + next; +} + +# (2) Annotate System.map symbols with module names. +# +ARGIND == 2 { + addr = addr2val($1); + name = $3; + + while (addr >= mod_eaddr) { + if (sect_symb) { + if (sect_symb != name) + next; + + sect_base = addr - sect_off; + if (dbg) + printf "[%s] BASE (%s) %016x - %016x = %016x\n", sect_name, sect_symb, addr, sect_off, sect_base >"/dev/stderr"; + sect_symb = 0; + } + + if (++ridx > rcnt) + break; + + $0 = ranges[ridx]; + sub(/-/, " "); + if ($4 != "=") { + sub(/-/, " "); + mod_saddr = strtonum("0x" $2) + sect_base; + mod_eaddr = strtonum("0x" $3) + sect_base; + $1 = $2 = $3 = ""; + sub(/^ +/, ""); + mod_name = $0; + + if (dbg) + printf "[%s] %s from %016x to %016x\n", sect_name, mod_name, mod_saddr, mod_eaddr >"/dev/stderr"; + } else { + sect_name = $1; + sect_off = strtonum("0x" $2); + sect_symb = $5; + } + } + + idx = addr"-"name; + if (addr >= mod_saddr && addr < mod_eaddr) + sym2mod[idx] = mod_name; + + next; +} + +# Once we are done annotating the System.map, we no longer need the ranges data. +# +FNR == 1 && ARGIND == 3 { + delete ranges; +} + +# (3) Build a lookup map of built-in module names. +# +# Lines from modules.builtin will be like: +# kernel/crypto/lzo-rle.ko +# and we record the object name "crypto/lzo-rle". +# +ARGIND == 3 { + sub(/kernel\//, ""); # strip off "kernel/" prefix + sub(/\.ko$/, ""); # strip off .ko suffix + + mods[$1] = 1; + next; +} + +# (4) Get a list of symbols (per object). +# +# Symbols by object are read from vmlinux.map, with fallback to vmlinux.o.map +# if vmlinux is found to have inked in vmlinux.o. +# + +# If we were able to get the data we need from vmlinux.map, there is no need to +# process vmlinux.o.map. +# +FNR == 1 && ARGIND == 5 && total > 0 { + if (dbg) + printf "Note: %s is not needed.\n", FILENAME >"/dev/stderr"; + exit; +} + +# First determine whether we are dealing with a GNU ld or LLVM lld linker map. +# +ARGIND >= 4 && FNR == 1 && NF == 7 && $1 == "VMA" && $7 == "Symbol" { + map_is_lld = 1; + next; +} + +# (LLD) Convert a section record fronm lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && /[0-9] [^ ]/ { + $0 = $5 " 0x"$1 " 0x"$3 " load address 0x"$2; +} + +# (LLD) Convert an object record from lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && $5 ~ /:\(\./ { + gsub(/\)/, ""); + sub(/:\(/, " "); + sub(/ vmlinux\.a\(/, " "); + $0 = " "$6 " 0x"$1 " 0x"$3 " " $5; +} + +# (LLD) Convert a symbol record from lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && $5 ~ /^[A-Za-z_][A-Za-z0-9_]*$/ { + $0 = " 0x" $1 " " $5; +} + +# (LLD) We do not need any other ldd linker map records. +# +ARGIND >= 4 && map_is_lld && /^[0-9a-f]{16} / { + next; +} + +# Handle section records with long section names (spilling onto a 2nd line). +# +ARGIND >= 4 && !map_is_lld && NF == 1 && /^[^ ]/ { + s = $0; + getline; + $0 = s " " $0; +} + +# Next section - previous one is done. +# +ARGIND >= 4 && /^[^ ]/ { + sect = 0; +} + +# Get the (top level) section name. +# +ARGIND >= 4 && /^[^ ]/ && $2 ~ /^0x/ && $3 ~ /^0x/ { + # Empty section or per-CPU section - ignore. + if (NF < 3 || $1 ~ /\.percpu/) { + sect = 0; + next; + } + + sect = $1; + + next; +} + +# If we are not currently in a section we care about, ignore records. +# +!sect { + next; +} + +# Handle object records with long section names (spilling onto a 2nd line). +# +ARGIND >= 4 && /^ [^ \*]/ && NF == 1 { + # If the section name is long, the remainder of the entry is found on + # the next line. + s = $0; + getline; + $0 = s " " $0; +} + +# If the object is vmlinux.o, we need to consult vmlinux.o.map for per-object +# symbol information +# +ARGIND == 4 && /^ [^ ]/ && NF == 4 { + idx = sect":"$1; + if (!(idx in sect_addend)) { + sect_addend[idx] = addr2val($2); + if (dbg) + printf "ADDEND %s = %016x\n", idx, sect_addend[idx] >"/dev/stderr"; + } + if ($4 == "vmlinux.o") { + need_o_map = 1; + next; + } +} + +# If data from vmlinux.o.map is needed, we only process section and object +# records from vmlinux.map to determine which section we need to pay attention +# to in vmlinux.o.map. So skip everything else from vmlinux.map. +# +ARGIND == 4 && need_o_map { + next; +} + +# Get module information for the current object. +# +ARGIND >= 4 && /^ [^ ]/ && NF == 4 { + msect = $1; + mod_name = get_module_info($4); + mod_eaddr = addr2val($2) + addr2val($3); + + next; +} + +# Process a symbol record. +# +# Evaluate the module information obtained from vmlinux.map (or vmlinux.o.map) +# as follows: +# - For all symbols in a given object: +# - If the symbol is annotated with the same module name(s) that the object +# belongs to, count it as a match. +# - Otherwise: +# - If the symbol is known to have duplicates of which at least one is +# in a built-in module, disregard it. +# - If the symbol us not annotated with any module name(s) AND the +# object belongs to built-in modules, count it as missing. +# - Otherwise, count it as a mismatch. +# +ARGIND >= 4 && /^ / && NF == 2 && $1 ~ /^0x/ { + idx = sect":"msect; + if (!(idx in sect_addend)) + next; + + addr = addr2val($1); + + # Handle the rare but annoying case where a 0-size symbol is placed at + # the byte *after* the module range. Based on vmlinux.map it will be + # considered part of the current object, but it falls just beyond the + # module address range. Unfortunately, its address could be at the + # start of another built-in module, so the only safe thing to do is to + # ignore it. + if (mod_name && addr == mod_eaddr) + next; + + # If we are processing vmlinux.o.map, we need to apply the base address + # of the section to the relative address on the record. + # + if (ARGIND == 5) + addr += sect_addend[idx]; + + idx = addr"-"$2; + mod = ""; + if (idx in sym2mod) { + mod = sym2mod[idx]; + if (sym2mod[idx] == mod_name) { + mod_matches++; + matches++; + } else if (mod_name == "") { + print $2 " in " sym2mod[idx] " (should NOT be)"; + mismatches++; + } else { + print $2 " in " sym2mod[idx] " (should be " mod_name ")"; + mismatches++; + } + } else if (mod_name != "") { + print $2 " should be in " mod_name; + missing++; + } else + matches++; + + total++; + + next; +} + +# Issue the comparison report. +# +END { + if (total) { + printf "Verification of %s:\n", ARGV[1]; + printf " Correct matches: %6d (%d%% of total)\n", matches, 100 * matches / total; + printf " Module matches: %6d (%d%% of matches)\n", mod_matches, 100 * mod_matches / matches; + printf " Mismatches: %6d (%d%% of total)\n", mismatches, 100 * mismatches / total; + printf " Missing: %6d (%d%% of total)\n", missing, 100 * missing / total; + } +} From patchwork Thu Aug 22 18:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13774069 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F45C1CFEC0; Thu, 22 Aug 2024 18:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350838; cv=fail; b=hhdt+e+0Y/AtlPfx3kJJPRqwFrVz2fA3BiMWBrSxwqUgqNYdJs/d5QCDVDJ3Uvszmrt00KqnMcuWLIdwF4dAoVriZh7tAaub1dwnDJn+gFkwoEx4GvWXRrcgzF0t8JYJuSQpPzBxXfaCJ0gqXdpPC3yfQmAlI4LXkyOzd3A86+A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724350838; c=relaxed/simple; bh=YrmsrHdvhN6Bi3OLDiVY61cRYA/t9f/Heq9ACtkmqXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=t0MsUN760xd+e2YLqmxcq9pEEyGKIYKtNkv5YSJxPa7xZi1pMBopOB6OQdKDKHfvbF7bQW4kCUsb/Dctiv10cqJLMmPZ9lQZN79FuU18C8qTrLXTEG7evQAiuOQiBBDElsnJyzQ4oQU/eK79E4Pl5YlwuZHjF4uKnsOjzBbSOQo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=LHk11Jd8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QBsSvi+v; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LHk11Jd8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QBsSvi+v" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47MEQVPM028678; Thu, 22 Aug 2024 18:20:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=q8mEcHIT6tdZ0c01dmwaG/cUG0iTf3Q7Vxz9YBAujs4=; b= LHk11Jd8KYzk5JbF9gnmvN1uHRafBQmo6/ejP1bXPXOODmMQhfKil+vELMh802Qc jBaUy2ELCpoJs1HdL8gRftObFEj65otI363wolX8WIHXd1wBx3duROZwE+IBvoBa Y9ySskYvowDCP3X/TiKZTfLFSdWgY7NTmSr0jOxJ6TNeWcp0PifzFHOKrcosFfDK 6hBXjXAn9SbaS4UNOTw7hzDA8TohinAWEGvZYF3i6wZNHGUpuEyOgWZsU9WDhL+P mjHnGawQxCJa1KWZb1ySRBKVprIPdvjuw7EDsGv0rHcKgd34eRKEosE/Q1SRHRhu +ItcceltwLiT6GHeoIdFPg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2djt2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:29 +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 47MIDfRI027865; Thu, 22 Aug 2024 18:20:28 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 416947mahm-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2024 18:20:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YBJIsIxGV4ZZDZADK2MZJqxhu1HcBOq42dqCjeCzvlJU95F3PW5eZP4FoRxSqYaLPNjoChkBBnMBdbNAHM/iUiDOBuAZ6mAMwfL9jOFyGI/4/JIXtDNAoZQ3OJg3ueCrF0FwPJsJgeTSe/bsAwzqApQ+Z0G06eHjiuPkb+bO3op2zaib4W5W4JKTjAqvr4r2ad8TKgTUbOXZcNnTZcKQEY507t7f4p7mOl7mbfHS4mVUaSMLF7MrAFPNXcBFbXkpRCeviQOs9MDFUIulI8s3gg3JJ5xDtMILXv62t3g5j+ua9qQApcs4pK8lLEKFrYdgGkJTcElALDXWqHGsMYlV1Q== 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=q8mEcHIT6tdZ0c01dmwaG/cUG0iTf3Q7Vxz9YBAujs4=; b=HRsbrsvbL9O31ni6627ctqXPCtfCmhXy15W+dOEPpyCGHDrKTXPgD878Zsf30NFp/rXtmHYvaDpQ2w/taVmaYLnwWYH9j20OvfbCEWd9gNtE3gYy+J3Em/LuULxdKv57RCtfpaJwTTeKPOksJ9nnS2FKdPej9tcO+ABYL/X/wCD23WpX5TgWq9Wheyy6HXu88uoAnnS3wgeJ9oNJU7QZTJY5WN9/Bw5LvE+hfjJIsoCO5dtaLoP1QrWYD1Pnc/F8EGJbdsxJ8FZNr/kMs4d+djxBtYgUD8xNOBI6KHPcDuXEAvEXNApr1DEDTcHQ7wbQuSghxJQ2L/Mki8BtbtxLdQ== 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=q8mEcHIT6tdZ0c01dmwaG/cUG0iTf3Q7Vxz9YBAujs4=; b=QBsSvi+vkjQLeEczVgBzP4QtoJE8cOHLdMN3fy9VQqEamfPYbvzVMcb+S0vYyhc6FkcdYk86qyfd8gPdg3xQ/62XAH36RFkOWvVnGJhkDN9wJBkS7dkrnfZyd4wm/JwcmMScFX0im3aeP6CBCdftLYAdKnYEi+KUOZ4lqJi0ER4= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB5004.namprd10.prod.outlook.com (2603:10b6:610:de::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 18:19:52 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 22 Aug 2024 18:19:52 +0000 From: Kris Van Hees To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Kris Van Hees , Nick Alcock , Masahiro Yamada , Steven Rostedt , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v8 4/4] module: add install target for modules.builtin.ranges Date: Thu, 22 Aug 2024 14:19:41 -0400 Message-ID: <20240822181942.2626536-5-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240822181942.2626536-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> <20240822181942.2626536-1-kris.van.hees@oracle.com> X-ClientProxiedBy: SJ0PR03CA0060.namprd03.prod.outlook.com (2603:10b6:a03:33e::35) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ae82bf2-5a6f-4c11-de05-08dcc2d7040a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: Qwujw4PHRIfZ8zOSevThEcwSFJf/9lqkwzVk77wmpDzdHatWud1kB7UagMMdrE5QTnWXdTZkBK8pG9ENtapKKRUn2BLsVq4aeO53oZmoFeUhWlS6t0IjdulptGDn8uWw8ozaIZWxSPPXyKLsWAnJnSflmrq8kOIvpaXozF91Ps/jbUmpBgyJkmvgwLMtHlQfYbcgZkXORqDaujwyGW/64SU7mfA3YrfqAy4JOtr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Xpnh/K08uQz9lt4AH1VSjIExsJhTNbsJFLC+Nf9x9eaJeri2ZdyUA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: orA4N4aA6oR7E/7T195u91Rc0xgvysPeoMmlMTLfHYnO1pqPCpS1Oa2XLBoyKBZbZD2CdZ/rIN+7xsNMFHC1Y3D0NDlTpGZC9qzowj2NAecvorxIl6YFW4m/PVGMRhYrjpn/On7iNHbsd7MW6pqixrjp9TBNJJOjoFpdgYddFHDJZZmPo7SuQsixf6Rt1s3bFdz5jt4lVI1ipM0sIu7BLGyryAkiCUZM6SZr4E5NYsMCe6tpf0R75ZVKhtt2My/W5ru5/kxDyo05iF/gNI5bFOK4jyR2owd7+XGXGMHrGjXE1H4FOuvQirTB1wUAspGQcq1LFBK12dWoj5ZH0bICFCEf+twfnYJax9rynbXo8EgDmnqej7BB3EBiD0rAk+5UA/y2SO4Hq8fy60gNL00J+o6qYbw4yS0fuqzbRyZqB9DfROH6eX1rSlQqPphHav2Zls4+1STY8ZayR9Virw2TFFlOcPS7xVqfEmPw+rFGuYcWra5IJ2wXr5vilH9sM7CkWO+ZsJln/soHta/KaFfxuFeTWi4mWZO8Gyj67h4DH2PW7IGCuOqqwyPUIkxEvR2tShC0BqhHZW38hnaBwHYKBb3NOCp3/9P7xo5Wj9RiBsYVb1IZYz/4M7QCWINYwI92FvQ2+NmRAacn5y2lvbtELPJ/M3V9D3xlVlOQR8MZc1YV8x82q13Ylg+Xo0D+iLz9LtRpVSfXdozDZ8f8X65uHnlV3r2e8abdXMWBoMKcQjAZnDaBlYYdEhuvN3uVQVQKKVOOtnyC+K42HlqeRjLcZAbFIAgDgF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NdGX4COdSDritsZAQnvLo8Qg45d6kWkxHJnxxy+/gSnUvuZq7ZRryVe4YhSrCsHG7uu7KYnPMpeZTu1Zqy4Yb6NhzxJc4Jm1/rX1gPfwcUVmJbXgokdWaKmSG+g9bLaGyupzJ5i7h+2pSIv4wzkf9xJXa3i/4JGDAllGXeyoFzfJ6OSFQETOb8QfjHUASs0SpSOWNJXneasRFvIr1eC4eFzBzgODgcloJnGXlz/hqVmW8cR8sV9NBfs0He3KaNysRX4OTtsuOnJLiOe+S48wYJFCMG9MYscLjKfH55YgZL4ZeKmSoZFozG9KRs1y6s8rB+RgUxV3kYDabJ+wychZxmeFvfvV5dr6c3Wu8VlqpDkXPXtr0IDq4FXR2EMFdaRwo0tGkZzkKZmEl8JIHTOuL7rMcNXtviLpaRaa2Bys1rsT/LxK7dqyFw0zDDmWIi4lKVmEIrC5/ITlzU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ae82bf2-5a6f-4c11-de05-08dcc2d7040a X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 18:19:52.2286 (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: dSMhwqr5rga2UId/bE5qm57p8c7Ap4vWcSN588LwG3nmw4BfXATjWfkYHgTecVs9SZOYQTHKTFB+AfG9Yw4N2iff+ETQyyd9/Dz3nbuTOV0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5004 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_12,2024-08-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408220137 X-Proofpoint-GUID: fNL-lhFNyrEoq6aNrBDMvNttfBDnSGCz X-Proofpoint-ORIG-GUID: fNL-lhFNyrEoq6aNrBDMvNttfBDnSGCz When CONFIG_BUILTIN_MODULE_RANGES is enabled, the modules.builtin.ranges file should be installed in the module install location. Signed-off-by: Kris Van Hees Reviewed-by: Nick Alcock --- Changes since v3: - Only install modules.builtin.ranges if CONFIG_BUILTIN_MODULE_RANGES=y --- scripts/Makefile.modinst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 0afd75472679..c38bf63a33be 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -30,10 +30,12 @@ $(MODLIB)/modules.order: modules.order FORCE quiet_cmd_install_modorder = INSTALL $@ cmd_install_modorder = sed 's:^\(.*\)\.o$$:kernel/\1.ko:' $< > $@ -# Install modules.builtin(.modinfo) even when CONFIG_MODULES is disabled. +# Install modules.builtin(.modinfo,.ranges) even when CONFIG_MODULES is disabled. install-y += $(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo) -$(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo): $(MODLIB)/%: % FORCE +install-$(CONFIG_BUILTIN_MODULE_RANGES) += $(MODLIB)/modules.builtin.ranges + +$(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo modules.builtin.ranges): $(MODLIB)/%: % FORCE $(call cmd,install) endif