From patchwork Tue Jul 16 03:10:42 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: 13734007 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 EF24411C92; Tue, 16 Jul 2024 03:11:06 +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=1721099468; cv=fail; b=rUwDwXENJaN7Do/9Zz0eMphu3V04yjQ0V5D6PaUaw9VX2I1fTTK7K+1HGqs8Lgyx6A1mUNL4o3jRhLCQSz7FO1sveJejgkNozh033QApQs+v9F1V1Hdfefwm/kB0KPUKn1FECw0rmR8XRPIDOfy9R+DiuDH8Y6FFXO2a8x+FjyI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721099468; c=relaxed/simple; bh=5cR6Ar6juXLyD6tD9cLnA8ueoJ3qKIxyct3iSe7tTEY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=W/RKHJZFHkruvGSaxqe49VmHDDzZFIMgQKoPYEUC3fm5WlbTReySiLjWKZ4nyJyTTKPnpRhJm4DAiUqkQHDfxOT4v+fRpM+3prG2diwo4k/6HU8WmFtrwxSat8ETiztmBTnEKh94/ezRFcfWfNEPHNvQoLwV911ZC2YWrbCFaWE= 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=lQ6hhKdd; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gKWT/Aky; 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="lQ6hhKdd"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gKWT/Aky" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46G2tpHD000305; Tue, 16 Jul 2024 03:10:58 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=YoS1jykx0C2gL5ttwkvX5v1sKfKV5YCz5856KioB+Ns=; b= lQ6hhKddJGnZcuA0kKSOtHEAjm5Xyjfr4EN5a7wI7YftjC8swVoFDNH+v9Q5NoM8 F53cKgPTXvvSuloo4m73MjBWVnojwb4xzIUh61F+m+K7AX9QhtOzMH9tYJCtmNVc HPjXKncJu91QaHybQkYIX5TbL1fxd0abZDL1QbJtPj9IjlVtLolTY0Ib37hMMpwV nIfMIKCxsbhVPA6o/sKHclARw6DUeO320ls4EmJasfsogMAhq0BBUZteG7+jLGOZ DTkdAg1B9dZTlsR0uR/P6um09ZXpII/yAI3ZKi8R2JcZQmu3Y1IoepmRFn7Uyq8Y 3+0B9iZGuNgKlzJAlwap5Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40bh6svppx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:10:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46G0c1t2010556; Tue, 16 Jul 2024 03:10:57 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40bg18y3ux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:10:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YevPq4hWBv+EgyS1uEtbUQBDKacitB83yH0OlpauNfQ5Luc7Z+9KhZ0LeRfwMzwUXDyxOk8JrgzYAJ5enjX5EIaslNLyPmpMkse3Dh1/lJU0pZuMdcXM0KF2Elg7DjLT65JOctEU27ZE7rkQImpmu73qxbeZGfLi2Xpp1htrVaau11kJ9xgx4j4HVVFp4tJV5qYOJPAckgng47pV54tFVpEKm1Xpo7VndvMOlTirpDdklGfKK7OadzFZfLwRNCqpYULmE5VfwggPGdQedAXbuDufHLIDWX0epQUrcM6AIBYpWCywLKKY/VY9HaSwgv7JQSf3XI1JbRILgKESu+3N1A== 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=YoS1jykx0C2gL5ttwkvX5v1sKfKV5YCz5856KioB+Ns=; b=iuG1BSywhqCFfJlGMhSxVLzT5BxPckh7NCzskWUkHPYK8OOQsyxXIbvjggPn8ZM8TtxgBDcZsbW3DkWPLnKgpfMn2XJvQCtaX8YqrQHLddTOuMNC5SmNu1Bm6doimn6SU74aNLa2LnpSaJ77FoXig7sN7i41lU9f5XqPqPmN299fy6CLMbvg3CrEPq/7tQD+5Me2HyWRPIE8OIsr9t/LU02LVyd0GLz+cMky34yJCuVrG3OcmYXi6GD0fiRNumqecNAWD+TEc8RlB3jJBLnoKG5H+PLcLI+qLtmOHkIEc575funnb33vxTKN7xcStm35ec/1H86DMbQcu2IL2/S4Sw== 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=YoS1jykx0C2gL5ttwkvX5v1sKfKV5YCz5856KioB+Ns=; b=gKWT/AkyFiIxnfep5iM3sSiw+ROP6GCaKEFNj7vLiKWx5mZBbgKQmc5o51q/XcIaMv2eXB4wLsUA5i6ZWXIrGM3M/Dgpqwze3uBc7lLxnCP5VTEI6KuIhbIHo3sozIuOHn+foiUZBeRkYhZzDEG8BT+28b2V1QYXchn/523OGSc= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by PH7PR10MB6380.namprd10.prod.outlook.com (2603:10b6:510:1aa::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 03:10:55 +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.7762.027; Tue, 16 Jul 2024 03:10:55 +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 , Masahiro Yamada , Steven Rostedt , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v5 1/4] kbuild: add mod(name,file)_flags to assembler flags for module objects Date: Mon, 15 Jul 2024 23:10:42 -0400 Message-ID: <20240716031045.1781332-2-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716031045.1781332-1-kris.van.hees@oracle.com> References: <20240716031045.1781332-1-kris.van.hees@oracle.com> X-ClientProxiedBy: MN2PR17CA0008.namprd17.prod.outlook.com (2603:10b6:208:15e::21) 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_|PH7PR10MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: cf543b48-1a96-4002-621b-08dca544e823 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: /JZoVclC3bQ8+BEX0UQpgmvVkTmQ1tXy/a4VSkupJjSEH7VW+wUNzESRmO6dq5ziDKja6SDw2ksbHR7eE9ywuuqcPCvBt3fbACGNHc6E9mQLtPeNxiJ3DK4xUwJaV7NeHzKXl8uNlxTNfuKYiVNtCBSm2g83+jcrzaiiIE9JVJ5Y6gnZuX11tPpapyk6fPMJZZ71qT/xfXTM/W7lZW8Ep/+Kx4dqTWbQb6sP/Sek1wCRYAB24qUK1zlDGAwhCroFC7Jo2FEOHrvSQrr0/CrG7fXA09ApKnjRZLCnPqcVZc1EjSO+BKFHMtKYfZnK9b5iNwFRIiWypC11n8IQpHb6JMUn8bf92CJ55v64bct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287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gqiVXcFNRF3WWon3HTTImpk0X/2Z2kv8rBMdZGHaxMOcFgTQqcP5Za+TJI3zB6sI02cMkxaONb/hrznVeBPheBEsUeEvU0axaNE5SZHuKYK5WD3Vd/T/qpbf388nf8ks9AbwJj/CimdzMNxXFkV/eRQQ/PLexV1QeSQbfG/WVY16dA6A0Jviw0eAEGSEhPD/T+mf0xpmDA1o/RFXm/022UVyJfXJzsUbeMozQyH16s9N7P6rQDMSavra01goGLZxRU9hZfDtYXZ3QksxPy5jQyY+cbujFE/g7tri6GYUojwi+McAetgAhDN5KFt10fu/hYBVOOKzmgQyn6jxyRLMTJThs2P3ZtR+JNTKYwf1Gk5/ZeUIc7JSUh/JFjnA9Q8coQI4adcLXSo4hPyV1sGBHMrSju7NHUvhdUi4OBWTS5UFG+hIuf+Vvpd0LLSgFAoYNiTaqrbS7UGUT+Ql7SjSzmcd6vCAFAeCx7Q2sUSyLIEghswpnOG7xp2IaqtR4PspYtMFAUOYGA5h0roIM1GvnpS7bRIsjo2wjGSHTAv81HefWwbHiemS9PVQc+k9R7a2GW0CElwlXe/gT/4V7nYjwjOKlDeCwO197WNzUajikM2ncscYQCE6HigTRHp4cFwzhJ4agjXfJMws4SwUjUHPjQQditi34sd9kDUvZNUsqiUfC7tthSOFjkpWjHPBma0gP3vHkhxRBZ75rVIZHCbmHrUH+hJ21gVBZaxhBP2FNLyA2+84GPhxHm9n1MY6mPTYl14ui8nLb/PbGH68ZmqyZ+X9md4IXviLTgHc6x7kEBIArXfGQXS0GmSjnYaF2zwRsn/jYfmfc/Nw71pBkyFyLmC4bLmoKrJI3mbbE9NW4xO2Th4DXb/sHmQoLwlG8rd0QnCilvuV78cdE9IJgK3egr3E5Rl/jiROxwQHJ6cKxfIRX+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WSQGSPHpbnS+2tbvD51Y2Y6nDQoaWP7LIfSku6o05A1qjm2algmKMLeUtkDf63GH31lJewwARzu7ZFkUA71OsSv9Hg2UQ7g+hBj95dKtH7rht56ob5IGa4kIiPBUziz/G80JP6nKk5D9PqLtY5s1cy1wNBQFfteH/BVan3CXHoidnNrV5WcZNeCVM6QaKy/18hyxMegmm2Qp8eIMbCu120wXOgn37MAs0BsMG2cDv+TkD+GMa+Jea4VbBwW/KGiJe7rcWU8thXDNXsQbTCcvPg7usiq8D3i8xRfGXqIYB3eT6T84H93HExw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf543b48-1a96-4002-621b-08dca544e823 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 03:10:55.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: h3UPlERlQlBwYWc7za+dhwTxjOIasVHFFznJ6Aj/u/QLiL4ysK0eLpMKIh7s5yVnUkHHYRQgtX2zxvXXHV/8SE5hjejPGcBwJpkiCCGMSoo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6380 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-07-15_19,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=838 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407160023 X-Proofpoint-GUID: Z3S_5OLcWPVse6fjq0DEgrx5g30sq7Gk X-Proofpoint-ORIG-GUID: Z3S_5OLcWPVse6fjq0DEgrx5g30sq7Gk In order to be able to identify what code is compiled into modules (even built-in 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 9f06f6aaf7fc..f4aec3553ff2 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 Tue Jul 16 03:10:43 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: 13734009 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 864BB15E9B; Tue, 16 Jul 2024 03:11:09 +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=1721099473; cv=fail; b=h9hXCF0aHeZTQSz6oYPqhGtM3Vnxfrxg8DBAhwfJaspnsBFMHdW1g1mw0UxQ7rZiJmCBy5bcg4iD3XMQeAWcFc8a4YwLF2qgfroAVEzmD0kmO/paYEsH+Prw8hjsEFtADvANdKFPAYYQkzKz07q+YilZSI8QeX1fYoN/qHYNdCg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721099473; c=relaxed/simple; bh=MsFphNNzIrm665GZs44FV83fIgDjHbgKAL8za6iw04Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=LRh3SY4e1OJk48SeWUp3GimPw9+W6dYDKTFJZLcakoTuc8oEC+x364bzEuAKyxzzEi3GfldqvXanTuUNOVCfJVZO02N/0X5NIXlodepvwI7lGKrTcAUJVfcyzhiRxAlfBm0J5tRe4rhtUaZF0wVKXb+HeJ3+IaNrNnpI1IMKPNw= 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=Rrs02kTT; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=oY+QRDbs; 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="Rrs02kTT"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="oY+QRDbs" 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 46G2tVw7018675; Tue, 16 Jul 2024 03:11:02 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=m4c3ucOqmDr97syXOU7V70SqxL89q4TiuShyDeknilc=; b= Rrs02kTTM4XEi/53ikchud3sAOm3QQmS+aJ0/g7B9ZQ8qHlmOpv0JI3M0vb2Rvz+ b69emcZ0O+i3eHVXWIay+SQPBPAzeM7cZ7tBfML8ZHVSTN36ZgfBP2Bma4WrNCoi hwg7fFQp27YGEXANyOMyAXXE9NH3jCKDjW1uqBFPgXCvF/Ny9lIKJSHBrsDFK3Od oRCDZE+vVcZ7JP4EazqXX6CZwNEbO1Dn+sWVEFFRlDnFSYO8sJ6Y2AWNZyNfV1EP HkZmEPaMeNpk69WIes/VcOqY/hhgN4guyOQBA+hK0xSlj/7xpQD5yYlPIuo6LZ0U gp9m9AwwDc/EPt3t31tnwA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40bg0cmtfb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46G1YjQa005860; Tue, 16 Jul 2024 03:11:01 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2046.outbound.protection.outlook.com [104.47.55.46]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40bg18pnem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EMVO1faA6ByhNsdkejYw8TRgNq6euH+BskZyHltS2rDVCAzpmnT+gopLRIAjsQVuERN9yCwMmO6B2FOOwF0WnirtEvi16YuRDCVeXS4oymUUixW4wsCbIyX07zM5byJKHswrPb5EljOpKVfLGYui4WZk1r6BwmCKFjHkAaQh2rbPSUi5qi2X0HaQ/tNEWj4vT9BLVuVeM7h3xj5A8qliYlu0fqzirOY/s0aO0SyJcNJ+RUfb3bC7yheMLeh0nB1yeya2Z9xd6x0hu4TUChOI+tqVubZ0VOozQ1GWw43uyqSBcQhIsnwOQmI7gqR5rcJ5Uup1eftSOOGlbUM7L2/R+A== 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=m4c3ucOqmDr97syXOU7V70SqxL89q4TiuShyDeknilc=; b=TCi8zZ6q4eYNJalEEr0rQFeZmMr1KDj7xrhnXn4XxlK7RgFiqfT9p15NKjJPM+UtlNaezUPNZgj7JRQOyGC3s7Onm70q+ezC9g3mh1KSNF5PJTIsnhh5aRfLFI1DiA3gG2i8AeUGsJyxpHutR/wKAdVtPbiLNmcF+sOTexV2PYl8rQY1wV07ZsaPgmqGxBsELSuMAThj2yXRJLJQWgOZGent4rXOiMSkLlW7s2xN3akBEGOw5J2VV49l020SAhAedL0XaRJVmy8kq2L2l6KYM03tdcMF7N8AS8aN/7OUWssjaF/Fix5PuOzfMWU2rjorAaTv2vWIojGSM75/X4LD3Q== 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=m4c3ucOqmDr97syXOU7V70SqxL89q4TiuShyDeknilc=; b=oY+QRDbsEXZdf7z+821yDiji66vKBMT6B9ldAjh6rrmjZsfU8RQE8B7v9B61TUBwiwFsx1+er7mTCmqS+gMVuWg315VpdhCyc9bjwgm06uK+0POscZwE7ToN/n2BWP1askIL6Clzb26v9CD+fF6T7ZaXDcjM+TPwrgW1+hb3Goc= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by PH7PR10MB6380.namprd10.prod.outlook.com (2603:10b6:510:1aa::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 03:10:58 +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.7762.027; Tue, 16 Jul 2024 03:10:58 +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 v5 2/4] kbuild, kconfig: generate offset range data for builtin modules Date: Mon, 15 Jul 2024 23:10:43 -0400 Message-ID: <20240716031045.1781332-3-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716031045.1781332-1-kris.van.hees@oracle.com> References: <20240716031045.1781332-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BLAPR05CA0016.namprd05.prod.outlook.com (2603:10b6:208:36e::22) 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_|PH7PR10MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: 945fb540-1d9a-4497-eb28-08dca544e9d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: ngxtiY9/PaPSRpv2ikC+A+Oqkp0Sx7CHhQJDusb6/ttP70pA6UYA0WMeEfrrdkOZvox+UfdhkizALbVpLDYGEsdVkoOsu6QeJvYmdUejooIOebOzNq9jJ2mqF4XhCAcOv8TiQ5/nIsJI67UJzntNBRBsiWgQpJtNyS625yuOa/MtycASxf5sXwZpZAupYNiy5hr3UJH0nN6IKsECfFtJz2FDshk7eOuCYcJY9BjSctubJ58FMnQon7H0cwHGoq8BEkMIM29lPieumGjW+Ip1gxUKD8tlNvarE14RmoR1cXsXudnF990G3Mq+iKyOeJ5iSn3KhMK5xsR/zB10iPZmnk9y8o4VTk6Gl+ae+JIEmfFO7OSGngfE4VVJmFQ/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KA9UU5oCeC32iPbWB6auxbeaUL6DgTUx+8mr6cFo4ATU9qzsGg43Jar0Bjs6FXgcfOsDsTXq1Sl5xtacG9QXKZFGUJ+BzoFKJYb6CU4uagAwQd8G6sIeilCZi0fWCA158w/tCOpYrCLmU13STsjHDaUmWgk3g8KUVvk+UjtE9XlAdq/LjhePWXK3U4elkf97RRuG+J1ogQqbGuLgxHheiPg8oP46dyRfULmU+eT+QERCbXGgCx1nzVSRs9BIQ5AXsmBjla1lrbmFa8SuUbZWMNjOK8OntXPys= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 945fb540-1d9a-4497-eb28-08dca544e9d4 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 03:10:58.0944 (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: 2WeqMYbW10h1S/bknYIf7T8ksp8J6Oh6tSwWPSWbQwhUiKWItKYjJje7GkCILN/Xn9Ein5giUmMRGyyCQHLdt6E7/c/625+VnNuB1A3+MH0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6380 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-07-15_19,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407160023 X-Proofpoint-GUID: fGL6fVAzpbiga0O9Sc79MzO98oevqo1S X-Proofpoint-ORIG-GUID: fGL6fVAzpbiga0O9Sc79MzO98oevqo1S 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 and KBUILD_MODNAME The generated data will look like: .text 00000000-00000000 = _text .text 0000baf0-0000cb10 amd_uncore .text 0009bd10-0009c8e0 iosf_mbi ... .text 008e6660-008e9630 snd_soc_wcd_mbhc .text 008e9630-008ea610 snd_soc_wcd9335 snd_soc_wcd934x snd_soc_wcd938x .text 008ea610-008ea780 snd_soc_wcd9335 ... .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: - It 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: - It 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) --- Notes: 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 | 19 + scripts/Makefile.vmlinux | 16 + scripts/Makefile.vmlinux_o | 3 + scripts/generate_builtin_ranges.awk | 515 ++++++++++++++++++++++++++++ 5 files changed, 560 insertions(+) create mode 100755 scripts/generate_builtin_ranges.awk diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 5685d7bfe4d0..a37b9c22241d 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -63,6 +63,7 @@ cpio any cpio --version GNU tar 1.28 tar --version gtags (optional) 6.6.5 gtags --version mkimage (optional) 2017.01 mkimage --version +GNU AWK (optional) 5.1.0 gawk --version ====================== =============== ======================================== .. [#f1] Sphinx is needed only to build the Kernel documentation @@ -198,6 +199,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 59b6765d86b8..ab8428c0e2fd 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -571,6 +571,25 @@ 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 + select 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. + + It is fully compatible with CONFIG_RANDOMIZE_BASE and similar late- + address-modification options. + 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..7e21162e9de1 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -33,6 +33,22 @@ 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 = \ + $(srctree)/scripts/generate_builtin_ranges.awk $(real-prereqs) > $@ + +vmlinux.map: vmlinux + +targets += modules.builtin.ranges +modules.builtin.ranges: modules.builtin vmlinux.map vmlinux.o.map FORCE + $(call if_changed,modules_builtin_ranges) +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..9b647781d5fe --- /dev/null +++ b/scripts/generate_builtin_ranges.awk @@ -0,0 +1,515 @@ +#!/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, mfn, s) { + if (fn in omod) + return omod[fn]; + + if (match(fn, /\/[^/]+$/) == 0) + return ""; + + obj = fn; + mod = ""; + mfn = ""; + fn = substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; + if (getline s 0) { + mfn = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mfn); + + mod = mfn; + gsub(/([^/ ]*\/)+/, "", mod); + 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 = ""; + if (mods[mod] != mfn) + 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 derive the built-in module name from this as "lzo_rle" and associate +# it with object name "crypto/lzo-rle". +# +ARGIND == 1 { + sub(/kernel\//, ""); # strip off "kernel/" prefix + sub(/\.ko$/, ""); # strip off .ko suffix + + mod = $1; + sub(/([^/]*\/)+/, "", mod); # mod = basename($1) + gsub(/-/, "_", mod); # Convert - to _ + + mods[mod] = $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 Tue Jul 16 03:10:44 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: 13734008 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 8646015ACA; Tue, 16 Jul 2024 03:11:10 +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=1721099472; cv=fail; b=eZdqFrmqBpGXaukYPt5B0lznmTInQvEVQBrqeEgCoeKamMflj6TIUfFgtBomMOiiU5fokx/Kb2iRW+bXRdF+tzPhpjck+jPSgw2z4Rg73zwEvSB97XUnB8DvvXzbq/g9RN4xtN56wMPeu9oS8twRyHNciAj6dQGzxk5ik3lPtMY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721099472; c=relaxed/simple; bh=7uhZCFCRFVSd8Ct/tbcyWhPERtOpZgZ2gdRm8BPkR+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ZDICLbWyytyTVig+5OmB1t0zUXfdsAX43g4AqsDN3Zah8dE3p/H8jaOZIQ7d9xlz/BLzEbB9xUzCw7WLne1l3o3SgYDvXeEs/ayriQpNVNmY3EalUjpp/1hUdhrKwCbJbYCpzfotsuqeJmaAtEUHmFG9vCpzt7LbnwEvk0MCeJA= 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=H6s7nTLp; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bHZG77ye; 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="H6s7nTLp"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bHZG77ye" 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 46G2tVfW018715; Tue, 16 Jul 2024 03:11:03 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=AQXtBbKNvdXoSCPnygGjhR9EG9d2twPzg3GIczr3BNw=; b= H6s7nTLpQRajQwrBD6JJwUdpJMckn9XfpEgPm6ABcOsv6UliZGo7UEzH8CxrsvSG zPlxJdUTFQ0z9hTRjhNkqVPcWCCbBi7aNZXySCQkSt9ySRG+PKFrJi4JXh141yue BFl0wXfm3iGTPi5oldGPkz/Q0J7AEPosUWWGnjUF38n/d+isYH0ENiGPUJ4giRuJ O2YrSMFmJUGPqu51QJIUbOgTLdwHZPHDl3TIFctQLoDHIFw2HPyAl0TBFHjXaCpW NImTbTl71XuhBHhfL3TVkv7PyDSrVcCEAujaH0xQpfEbF17QJb+OK7hp9eZfcAMT LSfQDPk7OJo4lhYP437yYg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40bg0cmtfd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:03 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46G10Y7c040662; Tue, 16 Jul 2024 03:11:02 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40bg18qrw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M3LZdG/HxVDL5N5i6h7uAdryIdFvvTCkRxAB4Tv8LQMhN/w5wmhGFRBfzEtR7VlUL/Q0ltAv7s8Bj1M3rTqBBsAUyTea6KywyfeFVdbpV7OEtXrYDWnUuG5sUxUy1O98TqWbCb72cCypI0bfkvbuc1Hhi9XmpdCXprhTtJBlmeKIugSdmsEkIklOdWCTKxmxaMAlsx0KjjB72vIsSksk8UnncmlkuVtiPUs5l4hqLresATsrQRRmmG0BhxPCMomsMqeR8yBvAETc4N27ImdiswqQyrcdP8A7dZqOFgFMie4wi6S3IJhjVFSMQswbo4Kg83e8YrUg9Rfpa7hmvUdQgw== 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=AQXtBbKNvdXoSCPnygGjhR9EG9d2twPzg3GIczr3BNw=; b=VkFpOLRk9qI2znVB+WCfcsJlQIrIePB0AAHkq6ObzjLgXEHlwgen+c/4LLVQRfz52qxWEMNP63HgbdlFrRAKu2SyC65N0XqOQHcE7lJbgff5Zzkkq/xpbbdc9W1OaNld22pUheQwsKXELKvdbb9xNzwEFb6RWSMFoBRVoaBcRZeDLT4Ab5MSB5d06WtuBaLdLotLpbCz568yeA4z/rsewq9aU/Dg29IJsmwiM2Css68M/TxQcBuW9gsEXUGgY1+QgOXijvWsqffxE/iOxPzZIjvzRXyVOAEA5DWuMiypi5flFVqM3RM4evU54NUMi3fErC0XmMkw3zMX1twjnZOlVw== 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=AQXtBbKNvdXoSCPnygGjhR9EG9d2twPzg3GIczr3BNw=; b=bHZG77ye4S/95teeHmdL8tLkkAgaOS+HeBH8MkISe2rB80HWBAMpCQRCc4/s6YwruMD7mqi9fpPn3qWr+hTmPtvBkw0SkGOFWttaxNPnT3a2fDsJQKy3bBiFUUTSQimUZ1MFWzqspb9c+46PCnHnHm1LHjo+aofHhT3hAlo0tsg= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by PH7PR10MB6380.namprd10.prod.outlook.com (2603:10b6:510:1aa::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 03:11:00 +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.7762.027; Tue, 16 Jul 2024 03:11:00 +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 v5 3/4] scripts: add verifier script for builtin module range data Date: Mon, 15 Jul 2024 23:10:44 -0400 Message-ID: <20240716031045.1781332-4-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716031045.1781332-1-kris.van.hees@oracle.com> References: <20240716031045.1781332-1-kris.van.hees@oracle.com> X-ClientProxiedBy: MN2PR01CA0004.prod.exchangelabs.com (2603:10b6:208:10c::17) 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_|PH7PR10MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: 637ff27b-172c-49f2-f2be-08dca544eb42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 88pRiQ2kWFo8sALIpbVY5R1HDzFGub6aLIm4eaIuo49WyG6TRVTxyYYGDQQ0jq6q8DkfIIKu0V7VTt1ixMLdCus/hGeW8sgdg+rNqrhNN7AFXU5GqdrIILMnCugpNyNpMHZfUXQubCcbVtT1yEzM9034PrlYDvQ2LYtDRDMpt7CB/QWqovJy6xJsnohg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4T0WpSpYcWDCqDk5R26MBOK6fUWndJwK3Ed8NjMv8F8OGx71tOqllYT5dB0oREK296/qOyxSuxisfTGpF9unLCUIu2SsHmlmrQXCNSnw== 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)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zpVn8gKXbKWEjyAltqbZ3VsRG71SVdCII5J3FPhv8jQ0LkAONswovBPdRUe60RCite8PtJzPFylUWpRutVDdBS+SHnWFHsYCSV7qGsTmNGmgTWtBRBNu52CVZvdIpEWjbHHwgZcz0RSuKZm/DgaiXimrsEE991Y1vohv3JWJhAMibfytcGzLqLEZGIgzfkm2PJZok2WBXOx6lRHJzXP0jWbmA6jdZ6x8JmNCjH6G3TJp2BJdPmbPLxi+iG1ITf7RTLV/L/gxgsEqGMSxRURdA9BZRaS1SYtqWHGK3EgI5CLHJu6FXPrsLi5mwlQRNn57Dc9JZ+Hf9VH8VQCSlngkBTFu4OD+zHYj9uZWvMznkdG3C9fSY6XmAS4bZtwxPf5f0YkTDd75a9ki8m8o/rcx4PtME8UuTpWioPVldoz82MXIhSf8BHlPXMbYOPM/S9618llkDAgrG5t/ankI2vOyyNYxU4aOHXoFiOpYokBfPn6zu1zxBFJtjAX346bxdxaxZYzOmtpxys+DFvW9bzfxiqt/JdQjpWM2BPUWjTKrLp+xxAa2t5qFqWc0GtAv1GgJd4mzqklIXT0Ud84ipU8Iz2gpG3gr6USI5y8V/CLvR0xR4m9VCgIomLlaKth3MjyoyRkhbD5MXWpzSlsS2DnKnXhW7xD/ynUll0MEeUedjl3oODAxdkiT/CkCnjGnZLcjyn6PjckBppLq+VCvoaihi6m7d3mQ6zKgeVWDScv5lLki6jZ2V5MDfWq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EHsXzb5K942c3IJbbLeZOloNHzOpS6x1SZhAbIM8iGUlNReskKewNXy6XzMjlXJt1rT9BNM+5Bp3Dzc7epuqYJj5kHp4WLY+C4O+/3sYg2ybbIm+82dxN7YacpY6ZdbUfwIA10mfS6LlRx/0xN3YpfwFqxql/+PmbGvs1SiHmjHl7hSx5un0X4tFVCbrUOxJ2jITUpyPGZxpGPVb9z7u/e/Pw0H1JkcthAwB4h1ntM7rKrQemY7l1OyjKSdSpAFUPz/t3zNCBoCZUR2Js/mY9IjAAyFsrM2MNd6PNYYlS8bz/TpH2gMvWCYsNzfVxsbqo4TSHR+qQhHU0gRJkaoGIoXQESZIIwQbMR5CnP6Rrr6QDGaygbkX1QHEAnaVmsgQ0IJXIUIc7LeQ1CDS6kkFVgJ4vqk/iv1gtjuMvJr11wtnoaToGiZz+2PQcvcn3sD7/0iZYq364OZEfkb4AAKOOIhh6KCCDnGTcYDrqUOPnN2xTahJWtjPNOwG1ZvK0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 637ff27b-172c-49f2-f2be-08dca544eb42 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 03:11:00.4053 (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: rZU0HnHPKdzqIs1PP9kcwy+81zorHg/3715CawyKXBfrjJmMSllTYhNGq7dp5DiOSQM9c55x8IPVvYBczawGPMFNy/jeBI+/v2/oJAO1jG8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6380 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-07-15_19,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407160023 X-Proofpoint-GUID: RoFfhIr458m_Rod1YA6yvtoRaAz85h5Z X-Proofpoint-ORIG-GUID: RoFfhIr458m_Rod1YA6yvtoRaAz85h5Z 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 mre 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 --- Notes: Changes since v4: - New patch in the series scripts/verify_builtin_ranges.awk | 348 ++++++++++++++++++++++++++++++ 1 file changed, 348 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..a2475a38ba50 --- /dev/null +++ b/scripts/verify_builtin_ranges.awk @@ -0,0 +1,348 @@ +#!/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, mfn, s) { + if (fn in omod) + return omod[fn]; + + if (match(fn, /\/[^/]+$/) == 0) + return ""; + + obj = fn; + mod = ""; + mfn = ""; + fn = substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; + if (getline s 0) { + mfn = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mfn); + + mod = mfn; + gsub(/([^/ ]*\/)+/, "", mod); + 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)) + return ""; + if (mods[mod] != mfn) + return ""; + } + + # 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); +} + +# (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 derive the built-in module name from this as "lzo_rle" and associate +# it with object name "crypto/lzo-rle". +# +ARGIND == 3 { + sub(/kernel\//, ""); # strip off "kernel/" prefix + sub(/\.ko$/, ""); # strip off .ko suffix + + mod = $1; + sub(/([^/]*\/)+/, "", mod); # mod = basename($1) + gsub(/-/, "_", mod); # Convert - to _ + + mods[mod] = $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 == 0) + total = 1; + + 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 Tue Jul 16 03:10:45 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: 13734010 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 4A5BF18029; Tue, 16 Jul 2024 03:11:12 +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=1721099473; cv=fail; b=FboGStyjSkUuOMK7hP0tjtS+2XAwXiEx29fArfQozo457cqtDBL/0MOCTndW1LDPiJ2+jVJQrOsUBPpt4Dk3BjVAwA4ed5w0ZjtWbm6Iae3tPAHTy2g8NtXHp5VUjrftvkEWEacEhqSMS3STxoCdK3iu1/yQe+mSz6QGVObdwO0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721099473; c=relaxed/simple; bh=IQaX5T07SvvyNwdaagYSFt6/586ofPpfmuoordftns0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ZtxxZOmZLsdYN/EEQcPQh39L/V14SNi6QHm8SQ1yxq7YOb0z8MOxruxyAheR9eq7goFDooRfsIDQyOyGP9FcPAIHoVoPynR5zyqXOei/GgT7CixnYHgKRp5VjGK3c0zgqfzgw3LbbH3QC6fOi+Ffv7rn18EP67ptkMxC6x63vHU= 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=PESAVuZT; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ncgLVspZ; 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="PESAVuZT"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ncgLVspZ" 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 46G2tT3v025514; Tue, 16 Jul 2024 03:11:06 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=3y6c8LRWZWDp6cvaoaQn8VT4VHWNMLAB156joR6nbZI=; b= PESAVuZTHAEuaaDLLMS/cceeu83pGu2FjINX/sbpo9LM1RmD1KaN8wGBERC4G6eo VXH5JooT6yEncJ9Qyv6LJrU+OlCXxi4Arc6yDFdgPktbge8LSBrFlOj15/TWbpez 4qtEXagK64cIA/22R2x7JKqhWtPoxK7RZk5iJHwbanAm9TD0OfWMRCVXNprK+6iy /kSifmoDggZM77oqI1mr1r+1eBvB3tRGnndq5VRrxVDhryDiU+i8+x0a6NDZ/WnW sjxfblp/vDheyqB16d1MJlosz7zOKEc2e9hWlbV9rbKZDUH+jmvnBB69RvUV2UAZ VpHwzWw073lM1rCrA1UkEQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40bhmcmgbu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46G1cK9m023534; Tue, 16 Jul 2024 03:11:05 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2046.outbound.protection.outlook.com [104.47.55.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40bg1eyv3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jul 2024 03:11:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hi8PPxsgEEykPcTV1hnRUyuoJSdd/Y9GAxti4yFvepQxEM2UiYURJcIiC8l7DVu24HyjEHNr0zImwDB5++MLGXEYcIeHQdGp+2NwC0gWt44vo5Wj1YgTRNZjUQVu5T8OogRJhhSHdfRB8OrWaAoxL+ecc9OknKZ3UtbNTuDN95GZrQSgyQl3UdCarA2KemWzN6BfRyfwSD6PLDqk+zpMLinNYX3eNScqTaUEor/qPrLa5usWi549cVYtOQrAORYPb1Aa5SuubP1g29JPUnEfdT6JkYuHI5jDJPG5DcYcvVYIiokaQdR/0LBCcqXtVKS2CdNq19XtWoaK3vc8abjUCQ== 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=3y6c8LRWZWDp6cvaoaQn8VT4VHWNMLAB156joR6nbZI=; b=FdGvCtpdieEpdO+ut/jgPe6WKWapBZV4AFKMrD7OFtlqF2lWtItfpjNDdQTdpe4oGeCKwO6pVK9Uw9bpeQgicLL+BdWrbhxRcqgLfdmkphF4ZQ1DeWjZvCrQfGVU5iDC/Oo6LpfrL1SRUV+0Rl8JUt5n7feifKFXaV8TGQ4SBxZ6XgyBfiPpCwTND/Y4acNkKlrCCGGswfmx+JMPI3xuuzu/ys4dYxQ0+GoFXb2i3NpmOdXhBJ0SkGnDo3RTjV26VgCRwLMNQKJ6CZhd73NG1MsJHAXiTK9EkB7+xsGGVOc2r9EkARpDPrRdbt/iLJtHic1F8bX36UFLXYZsjlQEJg== 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=3y6c8LRWZWDp6cvaoaQn8VT4VHWNMLAB156joR6nbZI=; b=ncgLVspZ8hfeEoKUVdyBZnuzeZt+NwTPxtOCbAlvFMNV3i3ay2/cQV+c+hEEAIycVWy7eAtR+2gV/vJ5KeDI0XvVG2lI7gO4nDqmyFCT8LhvsifUrYRDQGRaduYhhG68ENMrnIYtDZnc7vXDWXPXQRehj6e1+2HZTp6tc7sjQKY= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by PH7PR10MB6380.namprd10.prod.outlook.com (2603:10b6:510:1aa::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 03:11:02 +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.7762.027; Tue, 16 Jul 2024 03:11:02 +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 v5 4/4] module: add install target for modules.builtin.ranges Date: Mon, 15 Jul 2024 23:10:45 -0400 Message-ID: <20240716031045.1781332-5-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240716031045.1781332-1-kris.van.hees@oracle.com> References: <20240716031045.1781332-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BL1PR13CA0158.namprd13.prod.outlook.com (2603:10b6:208:2bd::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_|PH7PR10MB6380:EE_ X-MS-Office365-Filtering-Correlation-Id: b4c7618e-0895-4fee-d100-08dca544eca6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: qZ2CtwgSvRMgcnjLUiWYvgyLKZUm2tVxRVXiA/oxV1yLHp6juiclqsbDbkTQ49RgLdlzCMjWtrWeEOdBpHkix9S037er3Jl+Ch4pKh8m2IsSJO0FBWxx/Pu1sSFeHwp1L5iASURbyazsb7pUGavw4CGypqhXFsYaK/ET35CklOSLvrjWDfFBp1scgOMP+JXh/9ANd4fCxdpncGsXF9vM1cAISn7Cy1jQUNcoAtuTxYDmupyQL5idbjJmDxV2+RQo/fkp/xBPalNfLt42w43TWcSMI9aP380ykuWHVlYAFi5n+zS7Hg8CHTSvglDF627r1P0p/y1itcBILZEePEyZD2rUlerVhLncuK1BRW4tPHFJK+C+7Nqjw5y9+DcXutk241BDtZAKTs74IgOsjvYxRn5NFgm/HNNg5SOGOhu2iCu2QSi+9T6iTS8TseBGOvfYoMxDPopcEsNHMx+4ePEoz6etfOO5HkUMGKlt4m/Xc4sG9LjoIGxVygJLuBu/VnV/g/n2upKH8I+YJ8OQLIUj/x0DTjoeGB/DKvzi0bbejcKrBilECYaCcmYh2SRg5KKcbnu5dN1iEjhGxsnkl3L7dhzPT9iFqVysjghLAUb5Fzs58P2hgA5MMv1/rqcWsKLsykx9l5Lexbi6Jz9UKJKbIQpvmBuZjv7BvVcY0r4EwlXL41zMcT9ecVqmUARTg+39XpYkR3cRp2AGqt7ZHzKPlbl1n/uaUVWyPHCk5nN090USkDctbMA7eAoov4QGYrqc4AC2f4ZLv9wT0ueAvekuVfdDU8MlY0mXUvKn26LyCcsOfnR3no4H2N4Bm2sZAH9D95fEdXM4isR2eFKm75fYVrqlcVLM3Aj/NRFMsT49dL52h4fNnHAA6Ts8OJyKKEnlz/ZbzWrtKhiC50HlvLLABTrwOEgmpoCvDYlwpfCEQXu6k7FxpDbzoGUrADYT5mvE/Bse2yoQieOuJu19Hp+i6WUAxeQKS3U5vp3Z+jPROE1fJDej5dJ/6UcSzcRT4zshOnQfEoPjjm9Hy9kBaJ3OaAo9WYYEuxpsP/0w4gUO33grC2kTCneCZXl8IxNu2mXN42bkAHB1dwhIIr2HCsV2HXfcTutM73vaVRxOXaSK/kr/bTNNLswc4YihnixxtT75clRm9Gc7QHDH8T+MTCU1f0mrsuNx3Edq5gbU0LHnQmi4A/bknDkqzUKIvm+ZWs7a0R5ckt+Dh5xEjkGLu9aT85raYADmCGq5QfRVx071BehAj5ubWAhE5poyS5Flh8l31HcQj+U7gLWmenurTVNEqFeV38ff4yiMineZlySi/p2GMPSABqiAsQPjEAsq/U6panjrC8OMooOmbxujiPoqKA== 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)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5rUOXFCIOPQcyyB270ZcyKCTsC/E+VC8qlND0PSivpweVz9/98d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Mu0KHAM/FAZyPUecNRSIOdZ5+sUbj77MyK8rj3bJxMTGYlDvLn+p2tp3G9E+kbmnHzSNdzxtgysyzXBsFoSs5B6kYdJsuyOOiDPg5vf72ln42ldcqOGurKRXvldzKCcKfPNipgIR3D+NtApk/X5WCv0fUUfY76saxJZxM5l3bAMz37Qjv22xlhiC6ZZrJ02g/CB/jzIS2CFznrVMHThEXKgrVED/NynKJDLmf65vIFaZTL06b1fgWk7e49+9CbL/jtOi+oREvOyRob4N4D/vic/QQyf8rZId8o13V5AnQAUg4ebqZEeemG/9QKbUx2XoBOHaVc+Wt0J010McsxOXQ8fTbxZbFCWLdefAcWGdgt1h6aO9dD56sbtcSuHQnWIbrn7WFEgDHm3N473GC8c/0QrtQY2h2MwYnnS9U6ptSNC5JU6trj2iFSnjwdemWiDETKOismPpJPsVCJ/7nRIhRoA6z01Qd0xv3TDJ+Mn6JoU4ybp44cL+ORKqi9fSlphUWItlWUobuLcg= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: L8BvaVPx0vcv2FkqColvG8xYgqYwDolqJj6/pWRsnKhJjwBHNg2goTl/Jtdu4leFLGcF/s8ZT2a9HhMRK1njJlIimnB8e05GmpQl2y+0BLZjl9snAokbcGANohY+BxBN8UHu5OnKXZ0QiKdQ7I48JRN0xykdqz05Ki4PMnNLY1sGzfB8KQwmtiWFREAnkrrBanMW+EOVywlPRvbrlbgpzQYFUvPWlQ89nocWbrfQz0yAHmknYdN/EWNmcE2bYab8n6FE9BSwrep5Mq7YoiJIHCkXZYBeWKVobRJuvzShjD/Z50Hzwut3EONkLGz1aN1VSKx8l+caZTLE6TeepUFf7my9RubiPE9fUA1NHPCO6E1rVWtd+HWUoksnbxje+TXtm3uTrFoYzYTKJIWGJiI2OPkxGHr9ZfOI4mw5f6/ubiDQ9jotc9nFdsMGrpOLvb4SR6QC0tuRc3DnMpMh4XASDO34kbq1Qi05KJoebVQAVt8V/IXsgmAlro0Y/modM1df/lv8yBSUrScNAzoULuUrAZnptpfstlEFBNwqnNxznVss8U+fghucWRoRqP4qP8hRXqD2Kx/NU1NafH3QB6g2++D8gTAslyy8idSmrSJN+YI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4c7618e-0895-4fee-d100-08dca544eca6 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 03:11:02.7307 (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: V2Dmg0YjFN6TRjQNX/h3rYj8a2gxfx3Re1tz0hqAV5iToLwPzVS6vOLfTvvaqKV1VYIS+aw7RlJST1Hhc3H9EoTZb6FTF+zJloffx9jfxQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6380 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-07-15_19,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407160023 X-Proofpoint-GUID: KMw2ghDvGdpTslXD3v5vggBNWsC1I-Am X-Proofpoint-ORIG-GUID: KMw2ghDvGdpTslXD3v5vggBNWsC1I-Am 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 --- Notes: 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