From patchwork Sat Aug 24 03:37:54 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: 13776258 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 89B1A26AFB; Sat, 24 Aug 2024 03:38:24 +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=1724470706; cv=fail; b=pTddtuMGF95ag+JZgwkwwYzI/BLVw4F43IW0urun29wFsjD7D2RgJLuICJCaSR/voKF7Cpinmt+mdYZQ/yjrInK3Q0eEk/W1gzcztZ4Tn4+kE1A8FA8c3M73Q/WoG0Lc61yPGalDneXWzsGJPLRXK3Go2PYfz3CKt0GaUKJjGXw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724470706; c=relaxed/simple; bh=33y95mB/DzsE4xb4hj9GK+8VGJdU9OMMqIrTdY70R+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=P2cE5WOV8MzjCV3tWreWM3NdSshwu5e3gsgKML6Wce+yjOAd9d7/WWmCPbGNcQhnCiQLwxoFzIlrp94SK1Ajp0gfawazplnLwyZWaRLqBU3JQ2KJ7Zd2xjytqIhZQU8aBHATbWPyaawyMrc2YE/tEgyAe58Hom2sSOZGacv81z4= 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=Q2IGU5xm; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QsD2XwtC; 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="Q2IGU5xm"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QsD2XwtC" 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 47O3SKtt014477; Sat, 24 Aug 2024 03:38:17 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=B8kwHHRUqQRpzk0HAeWFGSJ2cyutYZ8YBNXT5RK7ntY=; b= Q2IGU5xmYjWu0exQ4Duo8fgTBg2/haCHY/0TgAobp3Iz15NFiuJzACALqNOGA7PY RQABqujlE7sEljzkr/OdvEKGbNalJjPFAIM1pESOp/d6VDkaZLRFqnhaGK2IWQIq JtAsioLzx6YKKJym1MgRPNOIaypykOO5ja2s3VZhy9IaJqf9XWSwNcB//g95MhnR XL9i5r5na63sRprOtBS+/NHsjYgQ+rSavGEEnzI0gyGdeB5B620VynjIoHI3sDJ5 pMtymuYmS1XA17Hv3gIAOksDItn+z3dx50w3+r328c3s2WMs6Jq2X92VHDQePsvK Tz1AeqlCViwgkvlKHWryWw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4177n4007c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:17 +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 47O2H0IH027642; Sat, 24 Aug 2024 03:38:16 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2047.outbound.protection.outlook.com [104.47.56.47]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4176kgh9r2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iWr6Fz6DXTJeCjARrDU8o6VXCrE9AZLEId4gL44A4PbFXuMDAdfXn1m4UHmo/4M5oDq6TUyghoTTC4XAFwzgOk50q0xMez6e/RYAVSy4D4kNSSedtsC6jaqb8YLBiKqe8IXQ+ECI6g0hZs7fnvrIJoOnymCkPXdbcLNlH+80pfNTeNaGvBuxDEGFb9k7Oa9Wi+/EecxlL8Pu/TBAlFyuQSCfVJZNczb4Bxelxub6h6TncYlBflvGrFa00qkEP/etWPVszXCMn0O/ujQe+X1niKB8EXxA+sb4y7i90m3D5cs7b1LsPq0f2GYcmii5pjCRo5miOx2qPtAdKY7HVxi7JQ== 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=B8kwHHRUqQRpzk0HAeWFGSJ2cyutYZ8YBNXT5RK7ntY=; b=tMRZoocUDxmGYj9BhH0YLEyZn2Z+MhpywJcLbAOjEZt9rieovXhEWE5nqoW+So5p2Mi6ExATVad3hrqQ8zT/iC/ark6aXM5v1GTplVdGynmgNwx0d35sj/KCkw5cFgZl0wt3oVF5A4RpZUhIokwNSExTlvQ2UyknLlLrzfY7yvpJgo0uOZ1mL7awEhTtoQdZgaOhr4AvUrOZOvZKshKPth7gpy9fsrcLHU6k4fFhmL/xHgC1Sz0Z3QY0OBFiCOSwu+HW4x7Jxo8F3EdM8IgRdxTObV6/Je5zrwqqDQJNCd55OTEFJZhMdBkRIOPtNdWs2Z+ShiaEk6UNuYDe5vHzZQ== 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=B8kwHHRUqQRpzk0HAeWFGSJ2cyutYZ8YBNXT5RK7ntY=; b=QsD2XwtCjly40dSD9rfqcIX8SarpNh5ZTo+c1re2qG1Lsfmvf8xwAp6OOB67+CoGpZG9SpizS7rnuaH+MdRagqVbgfjWsvATDbYzkgynMVwkERMepQdeu81bL6jr93yn97On1ghekkgeYPj521KzksFEv9wf10k8Wwx/ps2Q/PU= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by BLAPR10MB5171.namprd10.prod.outlook.com (2603:10b6:208:325::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Sat, 24 Aug 2024 03:38:13 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%5]) with mapi id 15.20.7918.011; Sat, 24 Aug 2024 03:38:13 +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 v9 1/4] kbuild: add mod(name,file)_flags to assembler flags for module objects Date: Fri, 23 Aug 2024 23:37:54 -0400 Message-ID: <20240824033757.52005-2-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240824033757.52005-1-kris.van.hees@oracle.com> References: <20240824033757.52005-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BYAPR04CA0024.namprd04.prod.outlook.com (2603:10b6:a03:40::37) 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_|BLAPR10MB5171:EE_ X-MS-Office365-Filtering-Correlation-Id: c194b853-dd4c-4817-3b02-08dcc3ee2edb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: WBBCsZ3+UImjidoFPjUzihy8tUSNidIZxfvjzs5EkaI0A8C1ZHvZ4XKsJ96TCZ8dz5SNouHukX8332MWWY/NLzAWN/fHkkbDrErqz+M6y4CESjerTCjC/wsYwdgUC2l0uZz5nAZbKIJdq5gWC7WmBmPMGwEy0IFQ745dZ6cNgjym2QWkxB7ISOOIFKGOiODJJi1FHiU8u8meEgwY+6zr5Ai7q2IjGJq9CNN9F/WQk1A/IxjB15I+TkAUotlw+j4+LrxWun4jtTS1iBLOpJQYLitM1UGWdiBYr3TG1aDmomm8/8NUyW2bWBXksYTpWG9QYAFJ1VCG0/4KDPs94x6NBCnu4hL2zyP1DudpGkrFJb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PV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pc0PVTOYfFvWYZ+sYoJJa7RKEw/Jj3kaEIiHxtna4y9N+R3ddC+tYzptzw7/I3Lxgo0vAzf4XFYYf1veq2qusM3H1Y7iHphwAjov42sNSILuBZf5urw2HymTbQlflCkHo6ZttQYlib3PmFwQjrK2ZPzLnpMA4wvXnl8ZIvMIE8Fx3kSzIiZfkbQ73eFXI6fV6Y0o+uFSAe8QROiqhDBrzH3bJFAXfPQkCnUPBb7z40NRIcG2jG39lmym5iDE9OvuGUw6oTD+6BcKlnq8FgXWqUj3UWttGgF1UtW+/mWUSwRNXUy5k8RzE8wmCHlk1b0NnpM2UVWF6odqo/vLu9Hc04+KOiv5vyZvBHktAaMdyFCSaihuRQJFw2UvSqzzjr4eH5vQyHnzLkRQ4UJspO/izqdhEO875o/A8xzOF3MN4/uvOWG9WJ3icm2Kpf0VllpJX5ndqEZVCsyQJDzPa6zqlH5N1gyS6EO67saC7KaOxetwJjki7QPhfZmDe94wsiJjwuU1NaupYknXIHpcdEcnoV+whgjFuG6aQZyrETVAka/UwsJ2IQvs6y9pUZaKCHuH5xTk3kurDD6y+yRB7bvxtfe8TqNzqMnKsHMwZvXBw6KtIOrTtsfH8M5FH1P9v+mP8ICVvEBa2BMM1JcXSB8YOqTOjJS48XS3RKL/vpyhEO6G5D5IEjI7UkYsNRx439Ld0oTwCxeWS8kW9nbDpw2P9qgGX+jYPtWs3gxTRas3s7+w+jCCIu/4hBBye+M24LauYwSK8ciDF6B6Sn1x9H3JiBfWP3mb3v/CV5gCORBRVPNxckMYSM2OrhLzsBQuczL3RgzXgqKGerD6Au46eKUG2NU6vfDQUmbUdn4P1FuScEWRu3UWTBZ8Nc3JvcDsIMGco7tc7hT4M5XtYLkaZcTrOfd+2ptsGziTNSoJBON+tfEO6as4j8ZTLt9CsXbBed/4cSdqUOYy/2EB+WIwx+n3uoPmzgLuw1BjcNKX0ts+hibyvgFNaUHMh7cWK+l4S/49QCEe6wvnh+V/VmYqZQwS7riae3wXE7DofLQWJp13PLV917FMqRjAdMI2j5eqUouF0wIxFWdPQ0J8hW/GEf1novhQ001ksQrpLOQRgWdbpW00iimin9ORIb9zKCq7CWIG/2wLfGV0E52F5wZpxaA9e7slzqtRcWZLQ6+KwbN4NAmoAmKlYWx5PlYJ4kfhXmcyJ2E43bznSe00k6TtfB41QE4KxzD73DIFLa0z+gkXVjY6Q8026DgJ2zh7OKcghYy1SSvaBPS9B54KN5WJ4yJWL0xBACmjPqAoNZRl7lO5i4c3vdJHWHe1E9tFfOxeZQX1gfKSJVDbypjmstt499+f9/JMi2dBGSpT1aMmm6YgL6fAOzhUsv1k9kL/QaTsioAI+HzSeR+64Swrn+Em+NtVqmCE5zmOkcukajpsU7RL/ov9vevzthSvEd6wQGKmuF9xRD3bkv9Gtdle8jWdBZk10hhnaSROqH61xrVHhmT858WxMSGXx3ZqkiNcdWa3WDr/grJKl2WyKrnCJ/CbWTwg5FgUr45HmqeP33k8YyBzZsN0QbeQzq02EGxN2skmNMfUJNxOafcwwIYw6232754Zk6H300dGR7uG/mdmxF/IXes= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rkm/TfuhTffsn4I9TYK87gtR2rXCOy1v43kAnYyIDjvdIDf8mJFLduE7WKho1vQwF1/DBnHXD96p++4kdrDay2/cn3EOkHXTwjBDIAPqEEtQeMCsQuHgimrFMMYjksnPfpwurt65jUZcf65EdYh4CrQXpTG4ul8a5B6+gYM57JR5q38vZQCCD0bXheghjDe90wK0Ys6g1BQMwjiZrvZIs0bssMo9z2Dui3uO6EJD/KpM+BNhFogr4yVIt9PscRaYrodgcaaZe1FUSclsELHa/dYs1TwlnupmmTHOHMFCx/bvbLS3Y+fIZc26YDmQVdIoi/LZRekUms4IJpeHeXidAN+tNtK4FSI+ucKmiMUyvenky5Tv9cMxDvgO72cEt9MHe81cWVG0TzMjU+LHKtErYOjWxf4kDa1vAoPfHdHRjy/ba+UHOMH3/eUkYylV7QDJ07i4jU8Hj2lQwHj9o2sqCUYn4z+vTAhhqWambuPPvCzJj93dsobv359sLBA7uFOU8OAj4rO8nxGFwxuAzFSBE4Ov5dWCqun+bzfALShBvbiIaMYAxueMjm718PNUtvVoW1HYAol6J8chsZSstGLE4oHPdaS0OU57hNAcenFGXDQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c194b853-dd4c-4817-3b02-08dcc3ee2edb X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2024 03:38:13.6178 (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: NOEB27nKrNmEYkewGRT9jLcTAJJY/Q26VHhVN9uI4Pa+zOYfetdg1RWLF7clCs5bfh+nOeQTw4SNglFjdUpi1eOERpnKjKHFd1vUTLXezDw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5171 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-24_02,2024-08-23_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408240019 X-Proofpoint-GUID: 7B55O_YvCxQkv24RFs6qwSyDuLvHKsxC X-Proofpoint-ORIG-GUID: 7B55O_YvCxQkv24RFs6qwSyDuLvHKsxC 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_cflags), 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 source files. While KBUILD_MODFILE is sufficient to generate the modules ranges data, KBUILD_MODNAME is passed as well for consistency with the C source code case. Signed-off-by: Kris Van Hees Reviewed-by: Steven Rostedt (Google) --- Changes since v8: - Fixed typos. - Explained KBUILD_MODNAME being added for consistency. --- 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 Sat Aug 24 03:37:55 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: 13776261 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 E75382AF18; Sat, 24 Aug 2024 03:38:26 +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=1724470709; cv=fail; b=OPeeT5Va7J9FA0qEsEq0IIpolIkvB/JxMxuu3ZFvrToRZAY0K4R/b7OMmpxCP7P9eGXbtXLxxXThcfBVm+artSlM/IbctmsNlggL8WFMbt8KSSvc9fogifnX+GvIOEtHhga1O8d8jlMfVIAyMuQ4klACunsEfePjrExLg1HyIds= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724470709; c=relaxed/simple; bh=0OdkizaOcPpyrmW8BlNTOekl8wfYw8dp4a/Iirh1+kY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=PiVmmKXgrqVHBxCN2RkMnFO90Ctv3Iu0F4SBJWTMtVXzLC4H7lPo06h0LIMUpoTwI1oG18mappIEFrob/efrCT9/Ix9kUXwWc+kC/IjKx1uMwpJGljFAcfO1M735SZhMRjahKm3iklLNYUF4G9koxiHmV4gutw3AQ3MrzN8BuEs= 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=aUgU1hqq; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=P8bzU7BT; 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="aUgU1hqq"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="P8bzU7BT" 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 47O3OKC5006169; Sat, 24 Aug 2024 03:38:18 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=YJKfyIHeypDRiYqgA4HNCJTHdVhwpK8RzW5QhllD+7k=; b= aUgU1hqqtEpfeQ2A5Pg/5KqnIQj6EhapKdL2PBOYp+n9CqAbhDk3eHOWdnF/mIMd G7pd9eR50jD/SoMqgJrKixmo7AMDf1IIeFnlx0kRW04Vr2hx9eWeGS7W4esdaisx XJ0yC2fbKqUsZwmqxiYWxKL0ML/CQ9orRASeFXk+APnSYdmUhVENesuun310aFBG afopxUOyGHwn0PTaQiTX8mhKR7xr9Hi+M0nMki5WZabBzJ0qYVoqV3I5C0h9cEQp TZf5ei2nsRKWOiaFwEgvV1M7151qIt0VE9YRJExmX+l+WtgM/sdpfQCihfw6nCEz dYHIrcWLTbvOo6vXQgeKQQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4177jc809h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:18 +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 47O2H5XA027814; Sat, 24 Aug 2024 03:38:17 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4176kgh9s0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w4fc8cmqnF09WQrB+YdqJLGrb6g6leZCof7Ba2gB7JeEj7o9RklOn3pT1bFjzQ/X+6Xk9Zynr1uenb+kFi75+jI2rjLLbXF0KVcbkMZTHaiCDEu/sAThVbW3cKdzF1vnye0OD+Yc+SDw9DCPr8yt6vdlNP8wnBf2nqDYsRsd5OacIWg3fIPwqcis0jpOd8WNzXG5GUzGQfiKjTwQ+F1Q/6ICwKKMEscW5JJjjNdPH8gPwqZoGHAkwAP8DFLjEtcIzW5Xj+vaStlFbLL0EN+FsqQfEo9PQ8fXVcH++WqTEIhwhDyFy084UmjpHxKl40nyMs9FM0xX2vuc3/TkhS5TRQ== 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=YJKfyIHeypDRiYqgA4HNCJTHdVhwpK8RzW5QhllD+7k=; b=LbSukpzt0/JRzH05D6A45nAbsVIHF/IaXaSzk7tz7f6xV7h5zo8JJUYMDAdoDxmdVRx1aDC5/6A8+kHXRdo/slAXi4rRA+YmhrJ9o/s0DJGwhMgUBobo8xD1WK3XagsehHrkUf8FipDwDxClpHiFH6HS6oOT1RpZIZYTZizV/8iRLsid4kBLEEAejX1G4Chn1NMSc5Qbq8AWaBZXbt8xwuc+8bTbsE6JaH6SUe7+NOQdN7+hyufbNbDEVUeLddzIBsEtLB5e3Hlw/fxGRCeWmsnb3EF4f3tfuqAk87XmDq14dP63hjq23efYz/sdTPWTOKBmYB6WITXzW20FH0I70A== 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=YJKfyIHeypDRiYqgA4HNCJTHdVhwpK8RzW5QhllD+7k=; b=P8bzU7BTqsdyCGfE88MS79QE0c/5j6NrqCqRBymoJjUEXUgP4yL0LkbHRojAYoGhxm9LPvujFt4DsklFD86mvAoC2UjEVzneQRTYbxiOvg3mUaUG65dPaE5AK1+8GM5ZL62FRUBq9vfbM7iUHKM4Edh4jTEFl5yk1bCDIVs2ISk= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by BLAPR10MB5171.namprd10.prod.outlook.com (2603:10b6:208:325::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Sat, 24 Aug 2024 03:38:15 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%5]) with mapi id 15.20.7918.011; Sat, 24 Aug 2024 03:38:15 +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 v9 2/4] kbuild: generate offset range data for builtin modules Date: Fri, 23 Aug 2024 23:37:55 -0400 Message-ID: <20240824033757.52005-3-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240824033757.52005-1-kris.van.hees@oracle.com> References: <20240824033757.52005-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BY5PR20CA0032.namprd20.prod.outlook.com (2603:10b6:a03:1f4::45) 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_|BLAPR10MB5171:EE_ X-MS-Office365-Filtering-Correlation-Id: 1435128e-ab7c-4a4c-27e6-08dcc3ee2fa5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: VZP4KZ4jk5kAASJXgxx0AWZrsw6yJcO95AuOb3tytP5VTe+weWzg4UBJq0pZJWNkbr2gMzF/imbnh4quR1totItw6evupAJX01Walgzhf//JBDIXQ5yRWdE9h2Qbs1VuEdBiZkcoI4QU+8TRoCwwexxzU2WzPyeFMmD3hNoMn5sISwQoyAEOltRdl0ftPBtfdMq6hsmXAajLFPT08suuHTRU5L09HDCfm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DsczFvPRvB9X1QwlwNA4ACxK9vQ/t/gZPKpZVsQYped3tY= 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y9HrlxLlUXDHJI1LpJUzS1tgYiGZTOmJVGArV434Q8+DbMh1uWp0MvNZJXPtwmLQiyFQpB1LeTnZnHYEY0SCUXtPTDIdikr2VCp109uWd9He4EK2dZwPOB0N20YtP/2GwQmgnPIIqq7LpLCYa8kJYDBRrWr8Ng785mwGWVSIMmhwx0m9a8Yj5qySUlITeMqB2z0M7rXSY+ayw5RyT25hBrOM/r7F+b/KauBVXoKDPYaJpJ9Wh++Hfh4AFqmJfmJQw+egOU0iUUGegyLv55TAXgg8MleRKSfPBDAZQmoM2YSdVqBIcoHG3NIayz1J/6sYc+TZDzZdUrYq6/Q/iOHwEIpb+r7brUAR4j9hpM2+Zjz3HxbjdOZSPkGcGS6R1XwfiUZKaO4dnorYfd7M78RfWhekqyS+bYn8g2GnI5j7RpWhVx5MUhXaK07DN/m8jzKA3hKs0W3f0iweMNAjjtSYOBHIwQTIGoLExKZO3tPjKe+j8CnRmXRSy513s22JuAOd8AdzxD4mPywdsVh9/LzjzyyaA2WDkH4p5l9e6EBHNKWKz10JDX0+1WWhe9q+7ESggl8zrc7/C14n3e4gt20tnXO3w8fDOjAli3YyV0nhzuDXMsQ7y5v+VBxCMSDNW0ANWmQNWIX+sStKSD+K3YogSMo4F4vInkiD3vxYJrhtidfJ2XpF8WYZNRZ/8GD6Wr09UiSzWxWpVzTAoE3PNAcriv75r9HYrIHd903avA/nlhZRkFuAQoGBG9LbrVKCt0kmC8E3sndN9YXYfEklEOIxpZKyOH8ss9eQXC7SmVFtG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Gr9zouUqz4zBNqK9pr4OwpmjxBHtCmLZ61lcKoebGjiZ9mqTv33+96XKlQyyNfI0MiDdv44X4UO01HA7OkQeGzFY4VqYlo1Q+Hk2eI4DnSRlAepaiGutI+c9p0xTs466af8D4O9gTLvSYQGIHTxalWzQmSsPIkJO3DUFr1QK8jZ4Xgmuh+6wL1VtqTtZ1sIQHYhyVmYOggQwU8qqC0CqDOaiaPzQfBWGevTNtR/6vCCOplWdB9L2OGBAPQPhFTg7OLeKzrBzJt+yEpB8AEDR9fldT0B9in4ir7ZsznovQIFFKD008VvsCUmoJK51Nt7g9FYhN0h0pll1EQuh59Hp6vppAuxArsE9kW4HzgmaZDEq8IpgVnKBttJxfcCcGQy35eHLEai/XrT2PNScJ6Labp3fx0WBkuY99iG4HasH4wXX/jofrjhoSgcEwJPrtojZWvvQiG1nQbh8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1435128e-ab7c-4a4c-27e6-08dcc3ee2fa5 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2024 03:38:14.9961 (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: EnCTRVrgS/s67qp7+jLE6zNPDcr1CEqjpcchcsWI2o6ldI/gQNOmY0altakgQ4ulyL/8aJ2//yq7AQgkhIkfr0ztFBJ3DKsW7CbUGIt8Q8U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5171 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-24_02,2024-08-23_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408240019 X-Proofpoint-GUID: hMR8oqHZbFptMWymPuQQLpldLkggyuOX X-Proofpoint-ORIG-GUID: hMR8oqHZbFptMWymPuQQLpldLkggyuOX 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 straight-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 v8: - Added support for built-in Rust modules. - Added optional 4th argument to specify kernel build directory. Changes since v7: - Removed extra close(fn). - Make CONFIG_BUILTIN_MODULE_RANGES depend on !lTO. Changes since v6: - Applied Masahiro Yamada's suggestions (Kconfig, makefile, script). Changes since v5: - Removed unnecessary compatibility info from option description. Changes since v4: - Improved commit description to explain the why and how. - Documented dependency on GNU AWK for CONFIG_BUILTIN_MODULE_RANGES. - Improved comments in generate_builtin_ranges.awk - Improved logic in generate_builtin_ranges.awk to handle incorrect object size information in linker maps Changes since v3: - Consolidated patches 2 through 5 into a single patch - Move CONFIG_BUILTIN_MODULE_RANGES to Kconfig.debug - Make CONFIG_BUILTIN_MODULE_RANGES select CONFIG_VMLINUX_MAP - Disable CONFIG_BUILTIN_MODULE_RANGES if CONFIG_LTO_CLANG_(FULL|THIN)=y - Support LLVM (lld) compiles in generate_builtin_ranges.awk - Support CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y Changes since v2: - Add explicit dependency on FTRACE for CONFIG_BUILTIN_MODULE_RANGES - 1st arg to generate_builtin_ranges.awk is now modules.builtin.modinfo - Switched from using modules.builtin.objs to parsing .*.cmd files - Parse data from .*.cmd in generate_builtin_ranges.awk - Use $(real-prereqs) rather than $(filter-out ...) --- Documentation/process/changes.rst | 7 + lib/Kconfig.debug | 15 + scripts/Makefile.vmlinux | 18 + scripts/Makefile.vmlinux_o | 3 + scripts/generate_builtin_ranges.awk | 516 ++++++++++++++++++++++++++++ 5 files changed, 559 insertions(+) create mode 100755 scripts/generate_builtin_ranges.awk diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 3fc63f27c226..00f1ed7c59c3 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -64,6 +64,7 @@ GNU tar 1.28 tar --version gtags (optional) 6.6.5 gtags --version mkimage (optional) 2017.01 mkimage --version Python (optional) 3.5.x python3 --version +GNU AWK (optional) 5.1.0 gawk --version ====================== =============== ======================================== .. [#f1] Sphinx is needed only to build the Kernel documentation @@ -192,6 +193,12 @@ platforms. The tool is available via the ``u-boot-tools`` package or can be built from the U-Boot source code. See the instructions at https://docs.u-boot.org/en/latest/build/tools.html#building-tools-for-linux +GNU AWK +------- + +GNU AWK is needed if you want kernel builds to generate address range data for +builtin modules (CONFIG_BUILTIN_MODULE_RANGES). + System utilities **************** diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index a30c03a66172..5e2f30921cb2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -571,6 +571,21 @@ config VMLINUX_MAP pieces of code get eliminated with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. +config BUILTIN_MODULE_RANGES + bool "Generate address range information for builtin modules" + depends on !LTO + depends on VMLINUX_MAP + help + When modules are built into the kernel, there will be no module name + associated with its symbols in /proc/kallsyms. Tracers may want to + identify symbols by module name and symbol name regardless of whether + the module is configured as loadable or not. + + This option generates modules.builtin.ranges in the build tree with + offset ranges (per ELF section) for the module(s) they belong to. + It also records an anchor symbol to determine the load address of the + section. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNEL diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 49946cb96844..7e8b703799c8 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -33,6 +33,24 @@ targets += vmlinux vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) +# module.builtin.ranges +# --------------------------------------------------------------------------- +ifdef CONFIG_BUILTIN_MODULE_RANGES +__default: modules.builtin.ranges + +quiet_cmd_modules_builtin_ranges = GEN $@ + cmd_modules_builtin_ranges = $(real-prereqs) > $@ + +targets += modules.builtin.ranges +modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ + modules.builtin vmlinux.map vmlinux.o.map FORCE + $(call if_changed,modules_builtin_ranges) + +vmlinux.map: vmlinux + @: + +endif + # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 6de297916ce6..252505505e0e 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -45,9 +45,12 @@ objtool-args = $(vmlinux-objtool-args-y) --link # Link of vmlinux.o used for section mismatch analysis # --------------------------------------------------------------------------- +vmlinux-o-ld-args-$(CONFIG_BUILTIN_MODULE_RANGES) += -Map=$@.map + quiet_cmd_ld_vmlinux.o = LD $@ cmd_ld_vmlinux.o = \ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \ + $(vmlinux-o-ld-args-y) \ $(addprefix -T , $(initcalls-lds)) \ --whole-archive vmlinux.a --no-whole-archive \ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ diff --git a/scripts/generate_builtin_ranges.awk b/scripts/generate_builtin_ranges.awk new file mode 100755 index 000000000000..51ae0458ffbd --- /dev/null +++ b/scripts/generate_builtin_ranges.awk @@ -0,0 +1,516 @@ +#!/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 = kdir "/" substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; + if (getline s 0) { + mod = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mod); + } else if (match(s, /RUST_MODFILE=[^ ]+/) > 0) + mod = substr(s, RSTART + 13, RLENGTH - 13); + } + close(fn); + + # A single module (common case) also reflects objects that are not part + # of a module. Some of those objects have names that are also a module + # name (e.g. core). We check the associated module file name, and if + # they do not match, the object is not part of a module. + if (mod !~ / /) { + if (!(mod in mods)) + mod = ""; + } + + gsub(/([^/ ]*\/)+/, "", mod); + gsub(/-/, "_", mod); + + # At this point, mod is a single (valid) module name, or a list of + # module names (that do not need validation). + omod[obj] = mod; + + return mod; +} + +# Update the ranges entry for the given module 'mod' in section 'osect'. +# +# We use a modified absolute start address (soff + base) as index because we +# may need to insert an anchor record later that must be at the start of the +# section data, and the first module may very well start at the same address. +# So, we use (addr << 1) + 1 to allow a possible anchor record to be placed at +# (addr << 1). This is safe because the index is only used to sort the entries +# before writing them out. +# +function update_entry(osect, mod, soff, eoff, sect, idx) { + sect = sect_in[osect]; + idx = (soff + sect_base[osect]) * 2 + 1; + entries[idx] = sprintf("%s %08x-%08x %s", sect, soff, eoff, mod); + count[sect]++; +} + +# Determine the kernel build directory to use (default is .). +# +BEGIN { + if (ARGC > 4) { + kdir = ARGV[ARGC - 1]; + ARGV[ARGC - 1] = ""; + } else + kdir = "."; +} + +# (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 occurrence 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 information). +# +# 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 Sat Aug 24 03:37:56 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: 13776262 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 3658236AEC; Sat, 24 Aug 2024 03:38:27 +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=1724470710; cv=fail; b=NlFBoFlIlUFBUGcg+KRTDMR/kI3wrIsDHql6yJnWvy3Y9n2DHrFlE7Z/v2XI7QDtQPsGtrZa+F9QuSGmm2YOo269XbCyNALawN8IUfxklqgwT01HYxzOJRGE9lTM6UUUDhIWFY9Y2XxteVTrLQ3lBJleVHyEiNtl789iNWpFCaw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724470710; c=relaxed/simple; bh=xSsMh9h0mXsaB9S/lB9Oie7GIv4O7VyFHS6uV9U4uVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OxnHJpYun8OIh1tmD84490Z1fj3QcCn04B3c17Lr/H1GH70CvDNqdIWLPJZY3IgxRNGXn3nvdzCulEFsfIxyN2RXeU0iPBo3j2GK36EJJoGaE3fqYJbuxWJ+Z4xNfuVSqoeSnqWtrN0CBBTLY+9FI1cK7thy7UdOex5ZH9nOhpI= 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=O/BQHPCj; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=IJpUZLPa; 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="O/BQHPCj"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="IJpUZLPa" 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 47O3UMq1029505; Sat, 24 Aug 2024 03:38:19 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=+TefRTRsmdVPo/y0xXsaIEPlOQPhpw8XyOGGdQctnxs=; b= O/BQHPCjX0xiSYHJ5sdHULTQRq8mBrNLP4OLjvNlFc5Ao0hkhgyVBrYWfzCNlFkg ZHk6GSyMOVfYRK8NApddnST9eOoCohyi/MEXa2Ot863vsD1msDvUOyR1Ai0c6Mec shdQrWsw+TLjZ7jbj/EjbFnVRvNFKdQSsBEU+FldCZaRln9llN6jjawVAApPaOU/ N5ctd4DTTm4wTCwNhq84Ydfa3RICr8/GQimk7vU8xxyb6mHjlRYrIYa4V0Hgv3H+ B6NGFAGwcdZh8QkPbYdV2NkbsuKybjfurF8U/b1r8hlT3zPblamWp58vFt52Bbtq nosgyI5MZqMzDTOQpZsgHg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4177nw006e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:18 +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 47O2H5XB027814; Sat, 24 Aug 2024 03:38:18 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4176kgh9s0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oTd0DJFg4vewZXI/Un8NrWr3fwAU8GcrB3SWTtjeASXNV1CsCR5QjJ2AW9Tjm2WPStZU3QkZ28nhxfamwnsKPFUjbD6L5I2fTp7PzQtO193UjNGbR+NkNW/CCmSzrrai8tSMo9+E2cZFbUuss7Nbni9avajmAIMCXhM4PeFVI2HHm8IlxK0I3ugQxXuXrf0P9rtZ2btKhlzMkeVVzp6zxNVDVP7FVZ9EaaLyGo27OB8iMH6j0hDDkxuDqwqYn/H8/a0ZNB6XiP5NQ3LFeCRXzSyGgLGnxBrna0ccEuouf8Rp2wTmnXOizswIQpHeZb+rNrV/n425KhF8145rj6ceCA== 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=+TefRTRsmdVPo/y0xXsaIEPlOQPhpw8XyOGGdQctnxs=; b=Pc9VBCEE5ABBscVt2B48QAuHZqxUfYc5CWyTqBHESolkxytGLOQpa7hi2D39FvX+muqb32KYBLiJ1xH0T0N1rtbHKQalynQOvbn5VtR+RwQt+pzbQ+x6T4EOwmp5G2T1h6DnZSITR2X4FjxeacDSNzMZk+PVxJvtClWnCeDx6UWlWqAStpyAqSB7vZPGefGm2VBd4EusRWBK/3f7itHkFoKfszRCduj5x9Va06T0ggOPbJotNP0CZLnQ9StRk+zG0PPcOMLc4AeXDdQIm0T+VKHbyUGoDlUV87+im/h/gyv8HmjhtwH1wTjbQNKNuwjwxT3G/xG6/vPPxCIXbAbjAw== 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=+TefRTRsmdVPo/y0xXsaIEPlOQPhpw8XyOGGdQctnxs=; b=IJpUZLPaCURb8cxvWTqLibmVDyX+86L+vIWHXzdbXTYYcLcMrCnvw58WlFAehRcAAsV0FTuTKQ2B593r8Av4kt5MnNeXYcLXfyk/TwOUdTTZpb6+XVhJiWTOnNWhuWh0lQXXJ4G/piToy1/wWERxVGN3W6fLnE/f/xD5zj4klow= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by BLAPR10MB5171.namprd10.prod.outlook.com (2603:10b6:208:325::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Sat, 24 Aug 2024 03:38: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%5]) with mapi id 15.20.7918.011; Sat, 24 Aug 2024 03:38: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 , Nick Alcock , Alan Maguire , Masahiro Yamada , Steven Rostedt , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v9 3/4] scripts: add verifier script for builtin module range data Date: Fri, 23 Aug 2024 23:37:56 -0400 Message-ID: <20240824033757.52005-4-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240824033757.52005-1-kris.van.hees@oracle.com> References: <20240824033757.52005-1-kris.van.hees@oracle.com> X-ClientProxiedBy: BYAPR04CA0009.namprd04.prod.outlook.com (2603:10b6:a03:40::22) 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_|BLAPR10MB5171:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b155f08-1e89-4621-05d2-08dcc3ee3045 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: OlS47Xu07i/HzC6GjqABDlngMvhxK8mtlS3dNo5hzsuIUpWvE9N7DM+K53KhVRKy9+uEZsqbQBc1t1ePkJi9XtqL/GjjNqbpkIwNntAOmg56x7851mZUIzkwjRnK9m37tUfHlWY1l2OUtEQpnrQfOPBJXjXnRYi2pqZQqqSppxNfx9y7lkHt3hgeOjY60MX+3i34VZ56tqzN6Wr7Svbsx9Fbnroz8Ftk/ReV2gmYY8Z1XFaxEI69sT1T2cjwCXtUa6o/v4dWBVZMSHYEBWKQiQBZ753F3ao90sR9Mxu7/IIhfOKSJ987DwJ5+RKltzf9FHxfrANtxR8yNB2qSVce1UUOz5RWdN1Bhu3XJK1B7uf8JbG6rPneUFA8aBqXznyVMuUA+GbRN+7pHy+UOxKq0Suu16siAsLU8SqsLDZnkNlredg1doTZIFY6YQMPtGmxC8fX96E/ZPJLa1+P4E4hKlXoAVdn3pWBNB9x//bQrg1wixTIgzyYeERnBCVu5xnLSmdLkZ2o51cEY4P9BjlkBBf10gZKXS0y1mBfTrFl4ityZUDE0oVsYi4XZlVTe2TfASlWtJw1R4OgNDpkOdNys86LdlO4kqrZMfD3i58TUR22lnpebuyXIYOWrgjB9Alhi5mn0h0zxvYehQL7aoaEc6l5rxg7XxnmvEgMni/dJMXYOAfgYL0QEjAIVSNFEkvStj7NGQw75VFp3Z/arjb1zwvxXRi6D91z9nKbzUU6Z+kZageS9ntJ0u8uVPWyyrIeFsxeV+IN1GtL+l6WyXkVhho8h77TyE2nJYeVOwRdQBeztA5qLrYF/+4PGFvhSeU4ARWuSv3IZ09GWyycV4bPWBVdBNxL/Fv53J66ghw+4dOuwm3VatRqMe2fFJ9hTzOWLckhspngCA5dRUp3EEezm3+nOmMgn+wMBqvPda4RygQGrglXT2kUdotlfHUTpm09TZX/yKAJdn6Ja5QEWsxCynAH0YQnxqwGWOxJOP/qH1pcfr5JotEVs5OO4Kkf0iyr857d6y13FnBbJFJWtvOHhvErwa/YJcEjvbbal1U71nRZpDCOJwW5bsYqE2gonO9xXDuOT8abNOJrW5O7JAiDF9RCtBXj65nYikNK6XHJdGilSnMtOapO9xdEXm0t/KRUVQXvHVmt8QFEObzxmc9ReHC3hoXjV2iuZiSyiAK7OknUomTwJ2/CxDU2Zre5xAAbmx+YvqA1KsTG2Gmy9Ash/eNP1JZfjJxer+7+UujjK04JDS1cA3yLlBr0VBuKnOeYff40XEMb9cSJKJ9Sg1O3yo3RjyRplUp5kgcBOn4cY8KqjemzlJY/DVTwG7QmEGSXcLJV5ErauLz0wQPCcJaG1Q== 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L+iv2Zk955wRcNmsD72/Mh5WjkwsOoYzBoBZpUBd+uz1b62u8yVYlnnskaJ4CX4DP1NIVDPzuMVLo2qIEOnVCzfoKXui0LfeOCtcXsoc4AvEqZ43REWpeb7q2jTFgJ3JTdDeQPhdgdKlu2C482J5/whsoTGIMRr9VYppNbdbO/H0h8LIzP11bHKDnlwbJGTRiqw50Ml3FbQd7gMN1o7FmQ7Z9UZDBAMhSfoxZqFo1a2UWqPGsBmKZxtCfsr/fWY3wRaFcyPda39/xQVG7nlXkwTidup+KdtX1zfRqkbu5BLqpHg3Qg5ums4bQfByHo6wPUYXOLmWoW10F8FaklnBU3hoTf5eXzdtYgIAoYlNMatavbZ4jAEqt9lYFtJ82xb2hFssx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yW7qw9NCLi/OQYzxD5oswapC+1yLMxFqy9IT4MPgMeW5NwGf9y0oJYW5ixXPAtYBhpJOe/jOfp5nw3K8v2835NfH8o7CxLB+6qQSc8Xlj5ijswqLVHDqPuEUStxFrKK3ZJxge8I1s+6zACeAnRIecemBt8TkJ3dD3c2hrRJXMI0= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: T+eC5+acYjhib+9k8hj1GEoZgamDZS/HxzWwTav0k/97is0ybVyBNt8c3VnyaGW+bS3g6inAJ9saQaPBIFjHrZzBQsznEoJ7Pp16fGdZRSzwcdDvQC88WBVFPgSL5Ws2RuQBfqaj+ED5SmjCTvUUQyGTavGQdIwi13ZGV9YJzUchH3wl4Iki1Bg6xmGApfndXlAV8sFHdVgo13elir6TK5Ym4Z8wLejA15fsE4+6CNURWsetNresczg7BUtLvfC0PCOmm2BAtHc78f32q1cWySQ8h3PKOTxKtcf84ysED/5gvKfhk1m3eiN8+9hU/d08wa2KSQzodTvoV5jhAi1OunKGOYgLXGZ+Yk6j/yV8eCFCcnIIwSoby5UbGvv7lFiHlV9s+CcsmWr2SuGlg/b81n7lqow8GfNI66SkUNqGzz8VR+XlL/oUQ8oyH2Z4zli42ShS+mKySB6okOgTuqmAOvIe74/riLfVe8a/FZnHQXR3NphV5Rm/yNnp8Nu1LbOW2IsmcYxPvvYpQcWeS/4RtY30JmO+NiE6uj28zPpIwCtp5CsCUy4rwDXvKeD9nNh1vDpSS1jj6JsPvQSk04rzBR2VSdbjPaoOFQTg6XBNzF4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b155f08-1e89-4621-05d2-08dcc3ee3045 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2024 03:38:16.0383 (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: PNNL6ATCDWpjSZLv683DxndBEXZoKX4OqTTOCZBMHDk4z+oWAP+1rPAUcK1aZgDyXDU/F5nL/nhHucI84FSJF243yf/dI+XM7y0F0766QqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5171 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-24_02,2024-08-23_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408240019 X-Proofpoint-GUID: SZ0hlynHl5U0BGqEc74li0aiCPpDqZOb X-Proofpoint-ORIG-GUID: SZ0hlynHl5U0BGqEc74li0aiCPpDqZOb 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 v8: - Added support for built-in Rust modules. Changes since v7: - Removed extra close(fn) Changes since v6: - Applied Masahiro Yamada's suggestions to the AWK script. Changes since v5: - Added optional 6th argument to specify kernel build directory. - Report error and exit if .*.o.cmd files cannot be read. Changes since v4: - New patch in the series --- scripts/verify_builtin_ranges.awk | 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..f513841da83e --- /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 if (match(s, /RUST_MODFILE=[^ ]+/) > 0) + mod = substr(s, RSTART + 13, RLENGTH - 13); + } else { + print "ERROR: Failed to read: " fn "\n\n" \ + " Invalid kernel build directory (" kdir ")\n" \ + " or its content does not match " ARGV[1] >"/dev/stderr"; + close(fn); + total = 0; + exit(1); + } + close(fn); + + # A single module (common case) also reflects objects that are not part + # of a module. Some of those objects have names that are also a module + # name (e.g. core). We check the associated module file name, and if + # they do not match, the object is not part of a module. + if (mod !~ / /) { + if (!(mod in mods)) + mod = ""; + } + + gsub(/([^/ ]*\/)+/, "", mod); + gsub(/-/, "_", mod); + + # At this point, mod is a single (valid) module name, or a list of + # module names (that do not need validation). + omod[obj] = mod; + + return mod; +} + +# Return a representative integer value for a given hexadecimal address. +# +# Since all kernel addresses fall within the same memory region, we can safely +# strip off the first 6 hex digits before performing the hex-to-dec conversion, +# thereby avoiding integer overflows. +# +function addr2val(val) { + sub(/^0x/, "", val); + if (length(val) == 16) + val = substr(val, 5); + return strtonum("0x" val); +} + +# Determine the kernel build directory to use (default is .). +# +BEGIN { + if (ARGC > 6) { + kdir = ARGV[ARGC - 1]; + ARGV[ARGC - 1] = ""; + } else + kdir = "."; +} + +# (1) Load the built-in module address range data. +# +ARGIND == 1 { + ranges[FNR] = $0; + rcnt++; + next; +} + +# (2) Annotate System.map symbols with module names. +# +ARGIND == 2 { + addr = addr2val($1); + name = $3; + + while (addr >= mod_eaddr) { + if (sect_symb) { + if (sect_symb != name) + next; + + sect_base = addr - sect_off; + if (dbg) + printf "[%s] BASE (%s) %016x - %016x = %016x\n", sect_name, sect_symb, addr, sect_off, sect_base >"/dev/stderr"; + sect_symb = 0; + } + + if (++ridx > rcnt) + break; + + $0 = ranges[ridx]; + sub(/-/, " "); + if ($4 != "=") { + sub(/-/, " "); + mod_saddr = strtonum("0x" $2) + sect_base; + mod_eaddr = strtonum("0x" $3) + sect_base; + $1 = $2 = $3 = ""; + sub(/^ +/, ""); + mod_name = $0; + + if (dbg) + printf "[%s] %s from %016x to %016x\n", sect_name, mod_name, mod_saddr, mod_eaddr >"/dev/stderr"; + } else { + sect_name = $1; + sect_off = strtonum("0x" $2); + sect_symb = $5; + } + } + + idx = addr"-"name; + if (addr >= mod_saddr && addr < mod_eaddr) + sym2mod[idx] = mod_name; + + next; +} + +# Once we are done annotating the System.map, we no longer need the ranges data. +# +FNR == 1 && ARGIND == 3 { + delete ranges; +} + +# (3) Build a lookup map of built-in module names. +# +# Lines from modules.builtin will be like: +# kernel/crypto/lzo-rle.ko +# and we record the object name "crypto/lzo-rle". +# +ARGIND == 3 { + sub(/kernel\//, ""); # strip off "kernel/" prefix + sub(/\.ko$/, ""); # strip off .ko suffix + + mods[$1] = 1; + next; +} + +# (4) Get a list of symbols (per object). +# +# Symbols by object are read from vmlinux.map, with fallback to vmlinux.o.map +# if vmlinux is found to have inked in vmlinux.o. +# + +# If we were able to get the data we need from vmlinux.map, there is no need to +# process vmlinux.o.map. +# +FNR == 1 && ARGIND == 5 && total > 0 { + if (dbg) + printf "Note: %s is not needed.\n", FILENAME >"/dev/stderr"; + exit; +} + +# First determine whether we are dealing with a GNU ld or LLVM lld linker map. +# +ARGIND >= 4 && FNR == 1 && NF == 7 && $1 == "VMA" && $7 == "Symbol" { + map_is_lld = 1; + next; +} + +# (LLD) Convert a section record fronm lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && /[0-9] [^ ]/ { + $0 = $5 " 0x"$1 " 0x"$3 " load address 0x"$2; +} + +# (LLD) Convert an object record from lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && $5 ~ /:\(\./ { + gsub(/\)/, ""); + sub(/:\(/, " "); + sub(/ vmlinux\.a\(/, " "); + $0 = " "$6 " 0x"$1 " 0x"$3 " " $5; +} + +# (LLD) Convert a symbol record from lld format to ld format. +# +ARGIND >= 4 && map_is_lld && NF == 5 && $5 ~ /^[A-Za-z_][A-Za-z0-9_]*$/ { + $0 = " 0x" $1 " " $5; +} + +# (LLD) We do not need any other ldd linker map records. +# +ARGIND >= 4 && map_is_lld && /^[0-9a-f]{16} / { + next; +} + +# Handle section records with long section names (spilling onto a 2nd line). +# +ARGIND >= 4 && !map_is_lld && NF == 1 && /^[^ ]/ { + s = $0; + getline; + $0 = s " " $0; +} + +# Next section - previous one is done. +# +ARGIND >= 4 && /^[^ ]/ { + sect = 0; +} + +# Get the (top level) section name. +# +ARGIND >= 4 && /^[^ ]/ && $2 ~ /^0x/ && $3 ~ /^0x/ { + # Empty section or per-CPU section - ignore. + if (NF < 3 || $1 ~ /\.percpu/) { + sect = 0; + next; + } + + sect = $1; + + next; +} + +# If we are not currently in a section we care about, ignore records. +# +!sect { + next; +} + +# Handle object records with long section names (spilling onto a 2nd line). +# +ARGIND >= 4 && /^ [^ \*]/ && NF == 1 { + # If the section name is long, the remainder of the entry is found on + # the next line. + s = $0; + getline; + $0 = s " " $0; +} + +# If the object is vmlinux.o, we need to consult vmlinux.o.map for per-object +# symbol information +# +ARGIND == 4 && /^ [^ ]/ && NF == 4 { + idx = sect":"$1; + if (!(idx in sect_addend)) { + sect_addend[idx] = addr2val($2); + if (dbg) + printf "ADDEND %s = %016x\n", idx, sect_addend[idx] >"/dev/stderr"; + } + if ($4 == "vmlinux.o") { + need_o_map = 1; + next; + } +} + +# If data from vmlinux.o.map is needed, we only process section and object +# records from vmlinux.map to determine which section we need to pay attention +# to in vmlinux.o.map. So skip everything else from vmlinux.map. +# +ARGIND == 4 && need_o_map { + next; +} + +# Get module information for the current object. +# +ARGIND >= 4 && /^ [^ ]/ && NF == 4 { + msect = $1; + mod_name = get_module_info($4); + mod_eaddr = addr2val($2) + addr2val($3); + + next; +} + +# Process a symbol record. +# +# Evaluate the module information obtained from vmlinux.map (or vmlinux.o.map) +# as follows: +# - For all symbols in a given object: +# - If the symbol is annotated with the same module name(s) that the object +# belongs to, count it as a match. +# - Otherwise: +# - If the symbol is known to have duplicates of which at least one is +# in a built-in module, disregard it. +# - If the symbol us not annotated with any module name(s) AND the +# object belongs to built-in modules, count it as missing. +# - Otherwise, count it as a mismatch. +# +ARGIND >= 4 && /^ / && NF == 2 && $1 ~ /^0x/ { + idx = sect":"msect; + if (!(idx in sect_addend)) + next; + + addr = addr2val($1); + + # Handle the rare but annoying case where a 0-size symbol is placed at + # the byte *after* the module range. Based on vmlinux.map it will be + # considered part of the current object, but it falls just beyond the + # module address range. Unfortunately, its address could be at the + # start of another built-in module, so the only safe thing to do is to + # ignore it. + if (mod_name && addr == mod_eaddr) + next; + + # If we are processing vmlinux.o.map, we need to apply the base address + # of the section to the relative address on the record. + # + if (ARGIND == 5) + addr += sect_addend[idx]; + + idx = addr"-"$2; + mod = ""; + if (idx in sym2mod) { + mod = sym2mod[idx]; + if (sym2mod[idx] == mod_name) { + mod_matches++; + matches++; + } else if (mod_name == "") { + print $2 " in " sym2mod[idx] " (should NOT be)"; + mismatches++; + } else { + print $2 " in " sym2mod[idx] " (should be " mod_name ")"; + mismatches++; + } + } else if (mod_name != "") { + print $2 " should be in " mod_name; + missing++; + } else + matches++; + + total++; + + next; +} + +# Issue the comparison report. +# +END { + if (total) { + printf "Verification of %s:\n", ARGV[1]; + printf " Correct matches: %6d (%d%% of total)\n", matches, 100 * matches / total; + printf " Module matches: %6d (%d%% of matches)\n", mod_matches, 100 * mod_matches / matches; + printf " Mismatches: %6d (%d%% of total)\n", mismatches, 100 * mismatches / total; + printf " Missing: %6d (%d%% of total)\n", missing, 100 * missing / total; + } +} From patchwork Sat Aug 24 03:37: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: 13776260 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 780FB1BDDB; Sat, 24 Aug 2024 03:38:26 +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=1724470708; cv=fail; b=YeIOqKwaWm9Y9xokcogjhSyKj88gnyWFxkuV1GeSeLap1JD0uWA7eUtBxNkoqt7i4uUBDcJj7YuaEQ6fPInZPMNfZ0JrSeZ/flM3h4Ol7TVp4xxzmwQDFX6rXKCuwy1HbJkTi5fIZZN/8SN/AXq3d52YaNZAl7VPt+GGUIIAZf0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724470708; c=relaxed/simple; bh=YrmsrHdvhN6Bi3OLDiVY61cRYA/t9f/Heq9ACtkmqXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ZGE5cXojjr2bOsVhGI5804RViAqwh9NWSslsenD7QuI0QNSAWwF7eKt4j3rHpLlnBrg2nUSvM+EfPqKQZUNNoO68qUwfTBkxomR5m1BtM5yR7I2tjU0Hk/WZwuo87Lx+/FP8YghWF3x8BCpafwBxfoonEGCNbCP02K8F3H+pC9s= 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=cZtPWoUR; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=NMKw98d4; 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="cZtPWoUR"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="NMKw98d4" 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 47O3Nxfu006066; Sat, 24 Aug 2024 03:38:19 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= cZtPWoURth0neubi6KzQ6JXjfUsAlqTyaqiQ6xEA+GYvcri2BqrC9snF0BW29suQ DhMR0Vyg/njjDp6CMBgLDxp4U9MIu/WFpbfwNKTUd0k2opuXCqa7InNEIVVZoSHP 23A/PfOXDFtpQ2N/HmUACOQh7Z18s8Cxb/gnd1JFWU5YlVde6Fn+XJD36aKPUUm3 BwGWPDkYY5ujVKla8XHPhvTWHzzHYvzo9BBq9Htuo0HDr+Sbmkj9LgYrXXmeJ/dB e4BPsLWsIxYX8Ui9stHISqYKX8LY6Mg5q+nuoYcGD2C3aeLBXwCIpuwgbeJ1uh0R v8MFl3kq03g1ra7MpCJreA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4177jc809j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:19 +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 47O2H5XC027814; Sat, 24 Aug 2024 03:38:18 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4176kgh9s0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Aug 2024 03:38:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dpqXFEL7LRZtZVqKPm+UJoGlOx1HGyusoFBn2jbONFY4T/gL6WDnk9Uwj8wXiZVGZlVjkmV9xDOIysECsujd/bp78oCSXGXmEeeHg/cRX3Job9tL7q6a4eTRbfxypKwSDsseZmrOLcJPj8G8iCvFwE9WYwHIWMUtgzXgo/bowt4oYNFZkUS6ZKf6LT+JzjaQ5XhneR3cfjgSY0FTU/oBUxyXQPAqTKsMxE9UnPHivVW2H3NOpjZtaGq0ADrsrIQfoS9e6hhcGFAeK2ts3MXQ4Lym+V+mnqeekjIFz5G7vArozjRKcN9VswHd9uqbRkshaztrin+GE3n2kaWtR+M11g== 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=kX39+saKq/YE1IdKMaAvmmiJoQSkwWR7n8/MJy1O9ixZjbF7eXTCwLC7atVDyygenvdZigyP/KftRDZt4wvjDw8zjri9SkmDPP4jcp+5ML6A4O1+d8S15OxtcEI8HSWHZRX2THoTPJYacVjZcA2jH/fu7xFYi8mP7C/8FoT4VNbQCJWSXdnaWfojVtE8fZLCyxJ0qIwN/dMaierFc5Ni+1KqyNe/aYMmgAhMz86EdMu6HfOiIF1ZOjtevk8pZXRJBkFXBioEgalHfydhIkJwsTdH4ueqCgZ3c3CDa6gvFc2BZ1y+zU4MsXM8vZ0EUK2v0QzBcO0WFTe97g2xjHaMRQ== 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=NMKw98d4SbwZ0MgmAjYxCuGX6x1DDIdF0x/cCaFfuZbKmdw3V/5nQO+tchsRCqEPDbRrFUFLZiFWcXu39eB83jROlIZR2865vV0gn9WMmvD5KzugeE0CJDm4R41Jm2y6dYyfGJgNyMNbnrwdVq1gyc3fVp5oRVvBScg8zyTHDzc= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by BLAPR10MB5171.namprd10.prod.outlook.com (2603:10b6:208:325::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Sat, 24 Aug 2024 03:38:17 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%5]) with mapi id 15.20.7918.011; Sat, 24 Aug 2024 03:38:17 +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 v9 4/4] module: add install target for modules.builtin.ranges Date: Fri, 23 Aug 2024 23:37:57 -0400 Message-ID: <20240824033757.52005-5-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240824033757.52005-1-kris.van.hees@oracle.com> References: <20240824033757.52005-1-kris.van.hees@oracle.com> X-ClientProxiedBy: SJ0PR03CA0269.namprd03.prod.outlook.com (2603:10b6:a03:3a0::34) 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_|BLAPR10MB5171:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a94b779-8d45-4dcc-772c-08dcc3ee310f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-A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qARWrWjSMYgPFRVJhpLG2Vzchn+I2CxsxiJPfuUm0JH5eVIVsYPuxr+NY8Deux3KRFtB+QnXJLV13dmQy/Bjfe8LYd86q6rb00U1LhPp8JSoPc4WyVpNw4JS2ZS9i/8Yh8C/Pot2lwB4bLHFKn3FUv54RuC88i8SM2NwghsuFJkEL9JONOL0+5RTvoQR5IxLJoWDTyKOVsKGTVB9ftZoJ39fYId29TXe8xt766NDX5oK+SlNt3D8AQCWtyYgv6vU2SmgmYow5jaFbSFs7wp4YjryZe2izfLVGGVywQDYlodaIyWZoTZYZR6ViS1HwLRl+H0Mpaj8Odf1kMflnqg1K9mctZ/SXuLCSKGDKLlsta9opoiJmHyA== 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)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z+hk7rFZaJ4kdRE7g4bRn4j1ElKIg0ZyosD6mfz7vB50xHoo8iCe+XuDkYhJ0rwVHYku9iicJdMA9lo0DaaupnviHrHdtG2fEfIMQQWofy8nWrj9shLnb/QZNdRNeBI6/IkRfMYOIxEttpsrFFknGM9/9gCo2iC/QUpeWMiDsyuM0lsR0hHrGeKTVhqR9+JcFmMT2G0YU/4e9SygIWdbXyMtjbMpgVAf6sZ5vIPwsjKQ+yyAm19sUAZ/fYvE9cpvDQo7U60rgFAs7yuANK+wikv9KQV1/ouEfc5WYnZTiqan8W9Uw934Q1TCO4hPWVyipUCjNjav08HQzXfNvCOkpK0F+Cf7D9TyEXrnqzWl+KCWrunGGPATkvdSYyf7m7qmfQmYF7D0wWhis6SU6Rnb9AUq8Lt7O8MqE3D+RuXfEc8aC77+oPiET7xiR7H+zLVL0EfyMT2Vg/TLdbKcuv59OKP3Pj2X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1Uvlfk0fV4NIDK6AtQaWZ0dZGuzelpQ4racjYHASNmOPqJ3fkg798+y/Uev90e65k3aAdPl4POznvqCm/E= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gULjw4rBMSF83n/NPzhSgWinBVJdFGbqwTwmD6iV2Ee6OiNarZ5pzmrZ8GfcPRpqtQKxn6KxxPP5/i3bFAfrq/o45ND1xnFpwOvsaWUjExxFB2uDQd8LPiAm4pDndvSpWAJTbot+oxLtK+OwKfeam07UiLLw9IkGJbr0GD3ox1tPVSqMwXyJpEmKDUYBCHRGrpkJS6f6bs1ELIgemTk4Ovei/PlrJGoCvbHgS9xVl18fSw4YQtvjMOGLyNYLBvgva0f/9kK5J0SLp9Lcr01c0LL2BI1B1ZJ9k3HNCl04utsiYBI1XbXGeh5nhzx0+QWyD6p+YFmZW3rmKNgahozPSGqoLgnyLcmmlxHiuQMXjoiCK0+Dwx/DuosLJvP5N95U1SQXa7ZuJVD3vzWstHfxNZjokxs5O0c18zhWZS72fcTzAMhxP4g2UxMea2Pomj+vWhZlu2Itj2sAdKshSF02QLRIq4PZaXOH3C9EFkS5I+iZqJWAjhMZnhAG07JcfmKlqcnM6NvhTrdfJqdpuqSKyLo9IqT4S7pMSavVkrtm4Qkcdt8cROtDcy5LN4DpDDCnLIOMKMewEXovNNO6P9eHoV55RVFsrJ9aKbskPyKzljU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a94b779-8d45-4dcc-772c-08dcc3ee310f X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2024 03:38:17.3146 (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: IEwyPPw1bkHuW3uj9UYtls6mZk01A7iYPrWkeDEq8RerTIVSBOjKMrNavSd+bA0pBbHQqFvFkuoCdjN5MXnbuhe4QlVXz6yyz9+43+720Cw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5171 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-24_02,2024-08-23_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408240019 X-Proofpoint-GUID: Icz9bbXmGphPQzklxdZuKCxk3H-ELp-r X-Proofpoint-ORIG-GUID: Icz9bbXmGphPQzklxdZuKCxk3H-ELp-r 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