From patchwork Wed Aug 21 04:06:57 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: 13770775 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 3B2D21581FC; Wed, 21 Aug 2024 04:11:19 +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=1724213482; cv=fail; b=hQv+KnEgDAkefB8Db8l4cyAvCDYB/NqaDWOiJ12w+df56lWGt40KvgSHP/V4Wox2w21X+PH8F9iFZuElXgAUCjslCaj7jzOETfQptnFSTmri89dejez5ZbHpPToPMuLJJvOtuliTHQniPbc0iBFu0mG+wAdH4MqRjy6CDYnRsXo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724213482; c=relaxed/simple; bh=cEONTywy9PC2pn0ZQd0GmZMKSqurVf+mxXj7SbHYHng=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=nwIXcW8Uc1jch4uOHG94dyziGvGVLBXZjebJreYKz9araI80RAO1nul4A0NzDz3jzUqrP3rtfMI5ZBd+n4NE+tc880apThdKzzI2IR8JUe4HBkIY4qAFpODcJpvRWyVzCVcQpYFU9y4tC/Zr4wrKFF3H+G67zchoo3rzAW2rPyI= 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=jS04WITR; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Ipxo7M6p; 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="jS04WITR"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Ipxo7M6p" 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 47L0tU1I024216; Wed, 21 Aug 2024 04:07:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:content-transfer-encoding :content-type:mime-version; s=corp-2023-11-20; bh=YixqDMhab5Dwvj OPkCCMuSsunYvDC0NxdMbagT+VLjc=; b=jS04WITRZfO9fKUgdV/acHnhfgDPxL m/GRlgugYsZ+QzZK0gmnPfSFFR5sX4u3enz0xs8xDQ+O8Kdsj8OoXSoghL+Bc7Bc au8A/pVtozDPqLVMcZDb0Djp+xJaDNulr9kIhticSBKVKA8JGHOl2/DLyQLIB90Z QdmTit0w132rmP/RyuCmVJa7UsWVBj9X7MpcJFSIjuHmdsinNXmfVy27pcgWFowE /WxoExiKaayMNJpBFTuLxcVTIKvsiNwPrFH36nTf6H9r+6akiwKX6kgN1oxThBjZ d4sPFRoLuBEEfVP0Vl7QEa/tLEKEs+EDtxcOEjM02TsCPmgpq2e60XrA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m2demwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47L3YCKO015698; Wed, 21 Aug 2024 04:07:19 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2040.outbound.protection.outlook.com [104.47.55.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4158engray-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t32ZQverzVhCBzaLjsl/t2AE4b+4VLLrd+zzUQyo6ogVrh9XqCgj7smwMrgAyrjlwrSMrjUmRa731v1zkR4iy8586A0wS/LXCi1rGs2bNH8IxV/dQirxa+AGNgxtNbZQxltcoSIePD29HrfsWdnDWulcClZksIeRXkAfh13GJutkQkWrFaOy0i7K5iFF6l42n0n5BmNboqdcQXIdtvSdU4EbDQgI1P9eMW19GglVWuGJT2cL2Qss+39HBW9+Ymz3EW+RgOz/aZAl7cHCl7CaxkZH26+Zxr3u0vdw11RPuMM/dyOA2YLByse6zTyk7FzBxtlkait/aLWGvcrFaCBgJg== 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=NDKfShoSeOpg4mTd/Bhpspffse8GL2HevqX1u6YjrDU62HGw+zEjjyV3IMWqNiuEyP5IYTQIiGceDuw/ixcWUpp9xEpO0Zrp89uXugfqQJcSO4UddGvGemyR0WSqK39PKd4wKBqxJpqf9uWSM56sQrhPbJoSemvWaPvckgRiQlCzgyFxV51y8C1/OI8XVDjpY1Hy9l2WtFEQjbw7rcA+woJ4y2KCd4wA5kI/jqF/NC2+3RBUXF9KnVldpYR7TfX3TaBxenDbktcCSJMyrPucN3B027uH4xdiqCPQVHHmS8BJfCyp6yNhMFXHSHmQO+gEEfONby41XwH9t7/ASPQvPg== 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=Ipxo7M6pBoImPFBzale3OIr2HJ5lcqz6i4/PI9NSDvm6t+ekmeGFHDOTdMREJT5GdnptmTHfmWFr9XqjDDdUuaMDNmTsSyr6Z0ucBiWervrufjarqFrA3haq6sKY5tfTIEOY919feWiALeqGktDrhUmzSoEN9FayXAjFi23upbw= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB7481.namprd10.prod.outlook.com (2603:10b6:610:192::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Wed, 21 Aug 2024 04:07:16 +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; Wed, 21 Aug 2024 04:07:16 +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 v7 1/4] kbuild: add mod(name,file)_flags to assembler flags for module objects Date: Wed, 21 Aug 2024 00:06:57 -0400 Message-ID: <20240821040700.1919317-1-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: BN0PR04CA0123.namprd04.prod.outlook.com (2603:10b6:408:ed::8) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB7481:EE_ X-MS-Office365-Filtering-Correlation-Id: a32a9646-a0d0-4067-05c3-08dcc196be55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: mizDV8+hYQ3Lt07zAZkgCX7tCTenOfF2anHn+1/sk4UA0jj1TdlopQ72UfO0UTuJE8vmJQIUR5W2DSkkq7OYGWoDKmtZLIkxM4yllrxs5k5vf2tyGMjrULsnkdQnvcFXHRRekpbz4+hvB8bd7YxVoXn/nJShIfMX+YlVO3YiKqKtULfRqaOnXKBC3tjQMZj5TBwpHE1sGPAD7yuqOOvQHieKoh0bB82g1qgpm5APL8u++b1pXMqAvX05oopN/jU2juFlczJpMLIh+MbaQ8dY3119JISZX1XDoDTlshSxzgKpT9t+Koo66EDPBzwrHKj4xMLFXjqYeFsBVPDSMeqbxCYqReswZFkw4FspFJCNNXxpuFr5QARhDAwQzPIrPoQxe2pw8LcCBRCyITrFByoe6ox4dv1PjHhYtYfcpq1WJ8ajzXrvGe9LmaRYZDKwtpfCxqXLd0Cd9tYxOR04RxC+Bdem+LjHicvFAPodOouwstcrr/tyOVrHk69WUqYGoIiGgGa9dsr1t6lpim54o7fbtIVux6YRpAkH5QEBjxORufGOi/pDhzeVAyTN8UC+jxjyYlzcD0H7dlfpW5jVYY4ZU0DJ6XqpOhNG66s38zRkTbJDmMtE4fVzSVXfMyJ4fdfooxeKP2wO/c8uBBWOHQaoIspsrK08RFm9sxeWxcGFEDnobkRG6sibxtetcwKl8yFBAqsSmosyncwekb7lCXUjSETdk20xI2VSHBKjMLeEaxcB8ZYLwcjgnnhJpJjWy4GPPAmhZvrLz9tI9GZDlLQ9zvgnBSt66WA8oeCv7rQf6LvwjOTQjtDZ8g+IzwNEj1Lj8TwptoivV+SvAaiAxWc4+ZEV+oPvPbMcyGufbd2Wg/0FQRz4vi5WWfy9bCTUIMZAXjd7SIAmI01ICD/hv+3N02CWNmQeXisC1Cv8hSbu1OKSssAAZ5AvSXp76RKaBL0ix+toe5vaRXsjnUv7fTdwFK6ZRFJGVQ/lLHg5lPmf0Sxxg4yS5g+XL6ziAVbvu/mvXha92ZEUd8IzGFdFMLjEf5P7hBk8e1NG3pDMQ/aXmmX/d8D5YFy9ESlBbkZpUHPSTZQkKRe/TlyM69KCoxK4MuxIJCBEPUIsSQgtmcVTBCmIt1iR+87nkssV3jRiJfjN4oFBOaextdtM0+KmkiwZlAcSnGRKJVsyTL/uRJHu+5a8LDX8/bE1wOeDJtCrDZ7DoM1avAG+G1FBvozeILrCWVAGl5mXurEyzxFPSoNxr+bdqZvA+0b7aIZ9cnNJvL8paanURH7S01VAIV/OcxEvtudyWguRMRtCeZ4XnzEk0c7d0CC0BiAwr4C7vMJu55XT3zyM6Skeld3ggTCs19ZyPg== 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)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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4n+Pqq3mRGWIVoW3Am0doyF59hG04sGTKIJuqaAAyUTQKehkJ3eysx7qEo1eTsZKNLNmpjHRhUG9l6HySWTwv5yOQr7r05r76zreHLX9yrOybogu8c5G4mYKQG1wwD6UQ77lY1m9R5Z+gg+WfyKnldeJRLfyfXwbKby7D7YAJ6W6p06o7P05AjqgppVivXiYbxjdDu+lxCu0jdw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a32a9646-a0d0-4067-05c3-08dcc196be55 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 04:07:16.3226 (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: jZdqdzY83k+4kZEuxLUNRRrap2l+bqTra3hX2mnWAPVc/V87Bjqb23Vek9t4DbZpEraaU+Cxic6tQXsMCcWpJOqzpKLowmwukukdyCWdXzI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7481 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-21_04,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=877 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408210028 X-Proofpoint-GUID: iHjsggHdtIoT3S35dJz4uEKmvBlAlEVt X-Proofpoint-ORIG-GUID: iHjsggHdtIoT3S35dJz4uEKmvBlAlEVt 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 Wed Aug 21 04:06:58 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: 13770777 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 B15E815C139; Wed, 21 Aug 2024 04:11:21 +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=1724213484; cv=fail; b=D27b0wrhjf9GYVCT1FzX43PXGTbtLqfozKH5w94PHP8IVx2QetXsm4Y09gxfaE/BhlZ9zvHzjKF0/pipy9gU9d/7KCtJ3ex/NyrXIpsyVxiY+0wAaeoZK1hOabYNGd7wD28CmI0kRUSvVcxSKHU3XczjltFEMyXFxgoFkCE6vmw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724213484; c=relaxed/simple; bh=jSQBB2zlz6pxqmcqbjt0ds7E9Vf3J225NnXKirbsUoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JeGo4ULfZLY/mFkR77xOUpHANwJOBDgBBSxe0zSrjF4/2EQMr496GvDyyL5xn3YQxnP6PbImbQahPpVYcQL6A7N5lPLXw5AzKO0aQaMiGwICvXt7R62Df63jaUv22QTJX3UPtQvB8N/hJoxOdwsaWWfKnL/q8sYomIvxeyY+MoY= 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=EtyTXHsC; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UA+/XyCJ; 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="EtyTXHsC"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UA+/XyCJ" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47L0ta2l012438; Wed, 21 Aug 2024 04:07:23 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=+tUK+XUy1tJZn6HAYg76Zpga/j/eSpm5REgQDHLRhoo=; b= EtyTXHsCentGy4eWbemATLTHLxKdtClZnr8lw1AV+kTadlcNzfnFhA9qsqeeMivY p2FhRY3AoalrptEGDgCjFypBZ0XdmVsoCm7DfF10fKz9QqJWw81dOr/YvjKYUCgS IKvdkNtZVAQyuGR5cXq5V9V55PQTyo653obK3EHWPnTHNtV5u5wfADWBma+qyMFX oNnnCEpzLY756ZcxIRGk28n88Ag6v+AYNY0JZD0ZdvLoyNGAwrNrYw7fY/WMWXAK D4fYCB3suzttZClYCV1yfqa1veBzsgi8zBfXXTrKamn7hvN6UNEGhK3bn47UgIL4 h38ne7ALc5uVZt7zMOdXmg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4uxjj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:22 +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 47L45BFL000900; Wed, 21 Aug 2024 04:07:21 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4158wa81ax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sb9bfaKn/HKd5ERp8cfDWw2k2gM14lwv+EXdPUOA3QjLRJi4dNKevkmXjIxKBttHqa/cRRE5eDKxFmiTGkAJYyn+xdlisxpxo1J4Xr2eRGME0bMVRLbZwgkkfz9TgrLlabUgU1TlZ/wku5+ck1MB6wYMHFJZyG+SzLwI7S7ca4VbkzxNn36XH8HLT9tEqm/isvKadD2AjtGyPfZFwoQqjlSpWzKsIvi8yeZuP+19s9H74QgIWfi/mkaxOz7tg9cU938zJURYuVjdffJnuwoji0Lgutoal9GIcpETPfC3FMTYd7O5Xd7vEehRXVy7wlspaUUbkUxKszLD3e2z3UxvKQ== 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=+tUK+XUy1tJZn6HAYg76Zpga/j/eSpm5REgQDHLRhoo=; b=bsLxhvHOav+Ir8omZ2jGCD+KPZQ5NI/Qd9o46nYtABmGFa6zFS0KKG+dPq8blFPWwqtzysBZUVbtZiMF+51yWYKZAhOkv2MlS8Vcb8aeLmRpuAT5PL7ivU3+kqDTkTJaVV7c9YOHxb9cXt4oypepivXYh5Fvh//E5tswgRtSfDQipkOCv5O+bQtEYONHgbgR1ml1Y859s+LODFNtKbYJUpqi7kQR4ymABsCwmC5yheNe9pOjIUujWL3DkDUd9JXmTwsUuA9nSUNWoe6pWU+l+QoN5g1VlZPISWJ212OLrOqhkwUA0oWVrVvK3rpvaoqyE9dCQqvL+5IQHuilgQiJzQ== 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=+tUK+XUy1tJZn6HAYg76Zpga/j/eSpm5REgQDHLRhoo=; b=UA+/XyCJTJDxtAcaVqug2ZdZD/Yv5W69u30oa0XeLUAk0BzEI3P5flbjfPqxGh9+kNRdKwzSEJZFRRUQGye9EyRPtfUR/1skiZrudR3oiSM5Q7l6PvfEnlZf0JHPON6W7g5aA+0Ja9jbEcfOKDsMKH36Hd0nJZxI2lN2VIYqwTY= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB7481.namprd10.prod.outlook.com (2603:10b6:610:192::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Wed, 21 Aug 2024 04:07:19 +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; Wed, 21 Aug 2024 04:07:18 +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 v7 2/4] kbuild: generate offset range data for builtin modules Date: Wed, 21 Aug 2024 00:06:58 -0400 Message-ID: <20240821040700.1919317-2-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821040700.1919317-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BN9P221CA0003.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::25) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB7481:EE_ X-MS-Office365-Filtering-Correlation-Id: e20cdec5-b6b5-46b5-1726-08dcc196bfd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: b6wHjnbVGUUOCJEZgcW3nOBc1nRwHYkcnlzjznuQPC2hlkphJlO90kY+WFstui6hMbJXBTc0AFKLr+eo/ZjGXYpnZ7637d1AjXxaIDZ2BRoPVXxJl6R0YoymvGrMh0OflMKVwcDLKM9/KY5oaKmSeH0d2SaVt8VAiUZoPgyl0/qG8EP6xkSw15SQ4OJQHWJz5TWteyckOw7pGKH5lS68VX5fi2o8FSZeg+T/sqX5vF8jfw2lAWdopKxT96rJ+ck8JWdcQi55zl0F5eP6qiezoqi5Gffi/MJ7Ksuep0FMyb0sxWXMc/7rgbNBjE2V+TSnteIO5o4EpNmKowPwZwJ+1433VM4epX/es+r2NhUO7dLtWM9e4HV6Qj89mindbaChJKeuS09SAAmfxjZeGgByG9W0kHGl3BemJxTvE7Rbo/YwG8w7VjBe6UWSBt3TeD8RjoTBhpIl3cIsxv8aq7Mk18enBHdweWmIBFHYfGKx1VB6g9lpFTCq2ZGut6QQ3w2GJ5S9TkT3e3JFYp703TtmljkW0V3ew8cNzfjpecJFmMPEXc1HRZK1qYXPKC6y4PraHN/mK9YO+7JEtRC6eeeBkAFXaA4Pg07aL5E0pJ5zB6bX7owxoTdNKHkWrtWc2n/B3o0mlyKtG77b/aPWJFt6VdTRtaZHKp6KSPfIvlreLFWzTHSi2OZpryXKFLHGhNNaPigLh9c4MqfkM/r/zLNLwkH/sH1sWiKPMwuVUlkwAi+WzfaPxkOpSGjkRYtT6nROBz/3guOATl6ArWpVNmnr3Uz20Dv3rUAQUGpzMTy6+JsuHzoIKEoPfyNzCX6MnYVl174OPTF8XRhP602QvjN0BuDmUQzh4yl661Ph9CAYFz9FzAzi/SdkEBUk/j96IJfmuBaWAevNgA4bLjJx/Kdl6qEmXiimnVSOIOXRKFaHjjjZY7gblIsJm5YlZW+olNyE5Ep/IfDFyvVOz8D6c6DldaRiAJzyJXrxtXlOe0LhsEmi21B5A4/9ovZmXH5tjTfaW2JCWfaYY3jUy+WjOD/7aVIwMiK+w3O8I7qI5bUQRMepNAaaTDCKctGLUkC3j26h9o1jt1XBr0A8gBoZUMigoylwEVNTC/4igFwETMOPL0ETpkoBpRSqxY154yWVfNvvKaDBpNPpWgbCFp2jJmDz+EPEMvFqOANDg523s8ciOz7cuZrnltOdTDAbywvyxlB1TVZFQwy1lYCsW5HPsr87J+EStHhxZMVHLBfPT8XSR9Z/xdtc/SFq3aAF3jLI2NWTaKyQ98/7N2f1AT4gA1Ar1ov47LpwOZe+mjgF+HnyaZI= 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)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: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yrW9EuhAl66Enqfp0v1fNgPNCkPrDYxAJ161kJK50ibz/VQ11gdboIBqM2MdR2+5BcVHng2b8e1sYeaFBk+dkrVDEjqyZmVOfpUlsQ/L+yIym5+tex/aiVwV3xnPQAtvTAnVMR6xM4qQh5gf6CrC9x/Na+amkpYNq+/pQdtViApHOGQHdLpJBTPn6L6yGsv+ej5MOehjbN5JL1KGvJARujQ11GVIQTCU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e20cdec5-b6b5-46b5-1726-08dcc196bfd2 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 04:07:18.9119 (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: cGWnOARKrjbs6agWRRYdotQCivcCXb7YD4plHHBsIFyLSV28Iftjw5MMsAiSqhzqmNitw/zfuNV2Ze47QiAEzUsl66WB51eDB3uiA3SygVM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7481 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-21_04,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408210028 X-Proofpoint-ORIG-GUID: 6YzAhN8mWgEEKB2DYg-9FI4_xh8E3An3 X-Proofpoint-GUID: 6YzAhN8mWgEEKB2DYg-9FI4_xh8E3An3 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 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 | 16 + scripts/Makefile.vmlinux | 18 + scripts/Makefile.vmlinux_o | 3 + scripts/generate_builtin_ranges.awk | 506 ++++++++++++++++++++++++++++ 5 files changed, 550 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..f087dc3da321 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -571,6 +571,22 @@ 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_CLANG_FULL + depends on !LTO_CLANG_THIN + 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..865cb7ac4970 --- /dev/null +++ b/scripts/generate_builtin_ranges.awk @@ -0,0 +1,506 @@ +#!/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; + close(fn); + + 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 Wed Aug 21 04:06:59 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: 13770776 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 9612515855F; Wed, 21 Aug 2024 04:11:20 +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=1724213482; cv=fail; b=N1R66l+sh2b7pVMj+1nja4kaetp149DQhlsyRDs5CPJzLDn9L/lrJIxKganSP/+QEauU8QSpuc5ACwVpe3lzuWXwvrdECXTsfw2dIC6H2ohWYy/9vL975o8iWzy7HGq3rtODPP0MazOjfJttnPLaloV480GnOk76QwfZa5zh7T8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724213482; c=relaxed/simple; bh=WZC33waV8GmM4WK1y5US4SmCkOL1VtCUiHQAw9pVayw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IqD83/y4AnDE+1e8nYpQ7ovXu1HcmLFmJixh5VcQjMbMYmWoICtyBOQPpjQimNK8QG2mOn82FTSijrU/m6zwsnXg1wEhwcZ/0TZba9zE8vY4nDnwO7zFzHLzDOXHusSwpPQ7G1ClgLmqqGDtt7sPUpCrpkjnV7AnSeDHQkYgcXU= 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=blGgOnvY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Jwvt7Tdo; 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="blGgOnvY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Jwvt7Tdo" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47L0ta2m012438; Wed, 21 Aug 2024 04:07:25 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=WYJ01sVjQB9+3I3VVt4RhjcZCBjuDxoEILd7ZM9sMoo=; b= blGgOnvYXYOEUanWCC/hvleRQ0/BxyCxN0Q4TNWzW1I95Lm39SjcHSJlqBYgtVMh LnguzBBxVS9QmjMqrUfiIEEmmreRwx1w3qS3q4nIsoQInF1js1a5y4WqIrbhOUID uaLkeVukAzggaSFN1VTk8PuM6VsGZQ/Bslw6yOKIMIH2NgaKFBbeSVJZ2CW9cvAe okCplUxXu4OZRzoDocHTgwF57yOSn9bf3cWLHGVxaBBKxVc46WhWtikGJtSYv0fw V1KZfmzks41YxtnBcaomqfjr7L32PsIs/8bLSFPcThpIXaz2cu8Wm5hU7iC8QZUe jXTQJhhaELhX0h0lYg3qSQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412m4uxjj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:24 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47L42LM0015912; Wed, 21 Aug 2024 04:07:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2045.outbound.protection.outlook.com [104.47.70.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4158v0836b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rBClMi9A8eKjnjEkJGUVweI8AkdRfa3JWtXMFwQSThfT+Wfyx5qV5xuxxO/g8tJYMgTqlf9bJOo/Q6M8DHOg1Kf99FVucO0b3JPqxvgVjklTAdf+8PAq520ufTONAl4X9vv6Yhr1OogZWD9TQa8pqCOOMKYZOIjYFhQxLEA2GR/jjSSuIe5y5epotqzHQsyVTnUN6CypNpEnFycS3keppx1GOTUAxkMLSGpw+uT1RnxbZjLKAut7vZA5J/VFceYhdF4pWXpjyPmlJAs1t/doIPu47T6q6h0Vdf/2MecXfVzT4o8gKM5tUOnlvqs0DfovSWNAnx8sB+DT+fxI6B0EEw== 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=WYJ01sVjQB9+3I3VVt4RhjcZCBjuDxoEILd7ZM9sMoo=; b=zSX41qBmvDkn/L0tJ8/4FWBMI3JaDO4xTn3kCWHjlIOuYKmrnjxa23CsanhCHFNhfmprmE0/w3siVfsPwqyfhirmK+BzAdoX+lTJcars1ZewCbP2CPVqFjsQew9TkF2I0DqJ8p0ldohvI3m3EzrSWZK2XRruxJ33GloC5pe/g5WXDKzYRwBFZfuRBBR/+AiKooSYVjZAfZoOpG8NaV0DmpGnzEWVHDEysL2KVcONyxIUk4C5YqJcttsivNP9DtXRLYa6iQVtzDp8eIJg7zhLuYHu60BdRtoHvjClztea+k1VV/HZsAaBMgwGxnywV1JDesRsrBaP1V5ny0kBP3l8lw== 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=WYJ01sVjQB9+3I3VVt4RhjcZCBjuDxoEILd7ZM9sMoo=; b=Jwvt7Tdo2Qw85mfcKjTPleY+YJWkYT+201YdFtU45G5VqGVLl6A9EJUH6VSlhf2mtLs+huUuzx5m3Z3n+E+Br0DT6LyeFxrBl2MowwUu44mmhAEoie9sk0IrI2ZfmnN4TTAM6T77Xoe12W7dlgkgEhuORF4eYMeiyVZUOPZL7UY= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB7481.namprd10.prod.outlook.com (2603:10b6:610:192::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Wed, 21 Aug 2024 04:07:21 +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; Wed, 21 Aug 2024 04:07:21 +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 v7 3/4] scripts: add verifier script for builtin module range data Date: Wed, 21 Aug 2024 00:06:59 -0400 Message-ID: <20240821040700.1919317-3-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821040700.1919317-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BN0PR03CA0021.namprd03.prod.outlook.com (2603:10b6:408:e6::26) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB7481:EE_ X-MS-Office365-Filtering-Correlation-Id: 57894707-2bee-4755-8c21-08dcc196c132 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: Its9rO/SXmFJ0hqof5LI4M0LMC2H8xcFTu4Ug1IE01Y2TdiUD2xPkf87IieGHV+OqkS5ofPOlJ7tGeGoYUktJpPj8IZ0svqaBAbtgSuerwh0A270KE+hvgnYmj6q9KvQUpvOQ8ekkj0iaQQu38aB6ahaGcENzJicMFARL6nJ05MGfa4EAtqsj1hKbi5/ztq40yosrFyoSjLxhLDZIUNuGqptrgihqZ8rjs5mV5IM8JNygdrsWCjnStQzGpxAgAjyCKsv6D30Q3vDWHinUMDN8uPrL6AM9c3WhcNSa/NutGobPTm85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;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BWCPxYjtWOqpq8O4JwIEsIJzsUZ3co5Pa4hxiGwSDecPfr+1LxMnEXnkB/LQVasWlI5gNLjBV5wicpYeeV0CLxdLQpYo4mDJjqapcaG7ysbaawhBEI/F4vxcCrfMFB+ro9gZtxCBP9hlgNR4lYJmdRjkcCxDvgAr2UDU8fhvoSw8uk706BcTZyuiV7UJZuxZfa5dYGLyLAT4DchhuYImG4e7xEz+GWy5SGflBnKdCLXYCGb1a8qsf4dMyC6fU99xgtHN08mPRdsT0rzwJm9mTwCn2HAhJuUMjeONQQ/CRWTEMKu4WJ47+FKOklySVqr9B8zA5YaM/9fuRp+Q3E6AYbLpNW4fA50q1/RBtLZYttGyXMZFv8tV4aTDj/4fWwZW68xZ2sQy3bXRu4OsxGpBJ3XegnnHB5hzy8xJ1gPFkUNYU8QHH4XhcQYRJxN549UbVsTlEgOUbc0xokl1WUD5VMw9guT5E++XoFw2yDyVbAOwVlu+ta7mhYO0gaUIgS5y17YDgb4cGSOPabwSwC+C/QIfs3Kwi3IZN/R5D926jlUYCoTka99+hwVo6yq9g54lC785Bs/yOMdLm8JpfmeEXpaakmUOXrvsoWzCmhfNV44gnaCAc/uDKiuATKIIBeURHrJyGTSxI0HR+KdLxN5T9J7nq31V/5s+L0AdI3/CYY0xL56w3WJbrSKj0Nj7hKklkxlRIUjHHzsdSwUw3T+qdXr5ryu/HpMbb+jI8LTQYN397LKv6wotcZHHcVh47P9bTmITN8mq8lMVWNv2q5APFL79anTooxU81X8qYaaB8Vs1aQ2LvqFH3Jla0lq5QVW9BPJ5++rH6KKLCPdTeeAp083T9rqB+4d+ArrKUPSod+KafsRr792ELzzB3IbCRr1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1t5s80013OyM4JQ9gdTlBNHmyM37K8K7gsE5KuTo2qTkkUfiIumQpTHDUA2lnxExDEUI01Mt+dyFR3OPlUylktXh+Ap+9d5O2duKymwitOkqcRFeLyx5fMCe9WdTDe9rEElfCunqXKbq7mkQ+1eBGyx75tt7Nwn2YcrzfKMY4pd0iA65bKQ6tebgMQecKIGMi40RXuYziOn7pxUyytgIx2SIu1B/nZQ6D8IF04NQg1hABtqq0xiPMtY4PzGiI6miq5oyv3jgTn/IShnkw0+lxhxI0fjdd8a/6NKwgBLd472PPYzrkjg7L55qqH/yyIUdHek74hA7JWxv/dBqhPrR7KNAvgrZWYp5fWJVufMdUQnqIlzRdyo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57894707-2bee-4755-8c21-08dcc196c132 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 04:07:21.1441 (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: k8VlGlAH59I14WwaNCVonoDj4rceGiXP6sg+MXJLPQ8QOPTO+KkhvGaOgDLwT+UrMxas5D3uEJ/NPaI2FzXWRAiTPLMBrY26eS7cYW8spi8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7481 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-21_04,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408210028 X-Proofpoint-ORIG-GUID: ciZ4jBkbv1PLXSVh445jLQIDsWAEfl_r X-Proofpoint-GUID: ciZ4jBkbv1PLXSVh445jLQIDsWAEfl_r 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 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 | 356 ++++++++++++++++++++++++++++++ 1 file changed, 356 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..93f66e9a8802 --- /dev/null +++ b/scripts/verify_builtin_ranges.awk @@ -0,0 +1,356 @@ +#!/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; + close(fn); + + 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 Wed Aug 21 04:07:00 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: 13770774 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 938413D8E; Wed, 21 Aug 2024 04:11:19 +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=1724213481; cv=fail; b=UllWpCuaj3eBSJzC1MboGmKf3ANqfjfcJseumH4QAo3PxoYVklHGhDo9v1ZChxYEZlYeuUQ6S4Krme47VN5We+63CemgpA5lIOgJOEsR7lOMiEnbLD3I6/WO0o8lVxbe5jvEFeM8ru4dk5nDvulH7/sn/gx/a12+dE+Zy7be7SQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724213481; c=relaxed/simple; bh=YrmsrHdvhN6Bi3OLDiVY61cRYA/t9f/Heq9ACtkmqXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=hbXngDFsYKtAqJ4dgv0IZpb9sQXwOzZ0CWBXOkeAD+tfBbliSQZezUgwqMM3WBOJuefb9nB2SSOF8/AhCOCdpJht9wzoLRDkKQU9TpKsAoai10Vcz7Qf39EB5WtGLl/cP9CnxglEUVXLd7jFyDr0yI4ReqCXcGWxHU8k6n8ToRA= 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=C5uJmcJM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hOVwphAH; 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="C5uJmcJM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hOVwphAH" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47L0tYkx008398; Wed, 21 Aug 2024 04:07:27 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= C5uJmcJMySgzxhP/9TWfBA994Dto8QZhwV0fJ9DaE5gcs0eGa3hCpanieea9qAtd CR0eU+PCkrnlbt6/ahuRJ5YJp1+5yVQrPq2jRou1SRYCZOrJIXPK8USHVJ0tY6Px yiWtlVEnbt+3KoW6grGtASspw8zkYx1H+JyTxBf59EKL3l1BeeY29/X0nwwWEkuy qMjJn4UNIkSGes90XmwVhQaOoNBIZuKCk8X7R+1pNvzsPMT0jl1WL4r3r99usHYd KBRRnSmJLJ8UuamLK51AhreB6ANw/z1pRh/hZYmMARbB4olHwZpffyNgBiUYcLRL 0kf+Hb+oUXnzQvXqxpAPJw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 414yrj0urs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47L2pdia036843; Wed, 21 Aug 2024 04:07:25 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2041.outbound.protection.outlook.com [104.47.70.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4157tv1ke4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Aug 2024 04:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NEwpSbHLTSbZLoWKoN3PFbcLuegaOrciHZzbK+EmZix2QtxBglhofWwE6ZDp9jJzax7Ey5yDX8hjSxkrqncyESi71QariSA9SbL1m1PqMzSWdz2ns9K8J7Ml6o/kFK1Ug/nQX0uon7ZEUdzIXEcUVMwiCIFC34Sf1B/T+FJ1SZVAz/ZpEJpUiFyGxxQ1IQMLGANIbWECBR7rT745siVJf4H0L/EsMeDVVjX3rcA9YCco7qvzn48Jpvlo1bf8j4bMqB4DLCpe5iaalU6OccfDBFgENcyT23SG08LxyJr3ojMVwA2a52iLBBqnyBDHyFQ7h/0eynpc5cOWCTX2+LPppA== 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=S5wA/fzhjLckL71nLJVPNDFjWnHQ1dJnG+pKTkp6Nz82WJy8W96AX8wi0bGYNkQRTTZYAfVf91THC9I68Kx/x25giNvYUua0tzLfM6usDlQtp3eMDxWFOKWi/Jph4BteFDysunTFagfAVYCWkj+TOSjWhtBEEKRfSfPlQe/MZ4EWesM/3fLJcB8XBifN+hQSp/p8s4PrNp3OKcbEm0LmLjWdi3AEI7cY31A+L8GPRKMYKW0U1OL0NwoFa5C2dW8zIej7cx48FqeVY6UjWEA6b8o3oktzH06Jyk/II6QZ3Cn/UOrgK6zyKdAM7b7dKMtZyd2mlBYNDoSxezTo6DOBxQ== 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=hOVwphAHLvXVpwsBayNvW4uicajXV6cdlARfMb3I4nBrmGd1WEOLdXao3W2AnrYCzeV4o14bdhg7jllSbrTRudD+ompOcwlgaBx1TcTVVBc/WGgwPjXs3JtF0ldK1we7JUmMkniwwoFG1Co6YH2N8wvVjisZ/laRdYjWgnmq1UY= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CH0PR10MB7481.namprd10.prod.outlook.com (2603:10b6:610:192::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Wed, 21 Aug 2024 04:07:23 +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; Wed, 21 Aug 2024 04:07:23 +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 v7 4/4] module: add install target for modules.builtin.ranges Date: Wed, 21 Aug 2024 00:07:00 -0400 Message-ID: <20240821040700.1919317-4-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821040700.1919317-1-kris.van.hees@oracle.com> References: <20240821040700.1919317-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BN9P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::7) To SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR10MB6287:EE_|CH0PR10MB7481:EE_ X-MS-Office365-Filtering-Correlation-Id: ee4246da-b049-43d8-1484-08dcc196c29b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: prda0MuP4Y5LrfMB2K+H8acMNhDC+foTaf1Od3Kd6UMpqrD1Af3gtUHJogFf2U4ayvgeFpVRFMqsVBDNe//CWcI3orbuHBCS9H4MzN9Viw0GCo2SXz8xtEOXIvw7Q9iWJfuiRheTriLg8r+oDAPVdcSxzLhOSRHuanD56hb53AZtsxQILtC4bl6nir3+V8lsGxg90xNYeobi4dhafI1xbiwl2vtHGhLoywei6trdQLB2bZAWU0laUH4ke85aHcJ5mMDy/tcJQLBy3vMmBdLy7qxvsmWtc2jGmYjP8ZrEotfDX4Frm1XD75o5MGnjO3aG3ITh8yamijGtkyamegXvUjUuMOEamaiAabiaLgxY5jLPO4x/aiztXQSDdOIX0MlqindefkJcVZmm9/mQ6Ntj769LU4u1+9kqft2MHQVPuj44OvQ5KF+jyxTCtbEKe22rD5Up8MiSBDWAm/v/kCxjm2WStshaO7lZYOa0mD0FHoWmVgGGe+diiGK2TK8Ue+8d5BIVJYJOkduVsP2GkDoP4mXjj8ZUQt0OEY4CyPdYPVv6BI7vgWp6MoNb4pXSnpzWRvmNNIHO99OOoxAZ142/gAD32SpUoaoZuHwVJPvjvXNLxnTFV2MlwUr0XJS9vBUIeRpqttGp9jn+RrtyGw650ZyEro8CtRomCoLYTpU3V+YmGlJzBrcsthO/BYAaX58y4SEBeAy/Gv7svuiATQvsWerL5vh6HCgeKCvvLxoZHANh8ClDd1qncuczDUmlfhje4HO9wayjWNM/IDonoWmc5eQGapnuWhCb+0Lk55rgP1wtPmZA1x9b+tbt1q4zlB3FhwrR8GQHbE8TMHsgGKifYFIzqH8Q9bsnnotC/ZNDEFsoyg3/TY1OYH5qyOy84qd2r019Eo9/M4LFBU/xhrEeBZsjRmJM8yL+Wehj0befG//uSS9oNlC3/wLmIwbO477Js7VV3ss4yfCqHAwHO+ZuBWpk9ttz6VjBsyh+tluLSBcXFWHblGrdeTmhjKhGt8P9UWiHDLxqqCMSQtSI61FVGMmoNkP5YClcwGJKa6ly++L+dLkvDhaYGbqPXxyRqRrr2Kgk0lpVPMuLzseJI9g6ZCnQWqdRMyJ48spTHDE6vTRLN2NOYmSSxa4/13gK58xLO2h1l6gWFb2eTYmOVSrvpC0YpLxmZmkHvTpgMjkjSDkqUYT4qhZwickjUriexTDOLQ2IoRpwXo3R1UQyD69kh/rrBcKAzNSijCB3CssjtP0zmiPABMKXbBtBD6u7JZRcK0N0dVO2YWpL8TXhKGGfN+CZNClbTdMZcoItluQvwK3YlJLK3Z8R7ohR6IssvVEG25APyAy3EARUJIhhp/XWGw== 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)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TifUbLGCyJva8wTxgoMOyi+ulFoVSKEhQWlsRLCv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GaZqCdTSyCKQ4Heff+XLcLY81JaAGaEqxfFN5zZNhtiJxsLASN6Aqf9DlkF99TtEL8efrT2fbQUxaOLKySuwljAXscD+Rj9gi+ClSWlhOnhtkhbnqTmwvGLYcIsgzg6ZMXdSMW8wgIIThFDy9D70YL0h/fzewI3kCvHVO0F3A196Qs9+M= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee4246da-b049-43d8-1484-08dcc196c29b X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 04:07:23.4581 (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: DejU4Yc3BEH4x4h/EgTIQ5+yFuoxDCKSORAb97/QE2dwGo8s8v746HTptFUfTia1ug8RqRe0Fpv2ab3Glga2eroXID+DptWq2Vqi4RFiPbI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7481 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-21_04,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408210028 X-Proofpoint-ORIG-GUID: Of3bIGqZH23vVpz3_edkmeWMQ-etedPm X-Proofpoint-GUID: Of3bIGqZH23vVpz3_edkmeWMQ-etedPm 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