From patchwork Thu Aug 15 15:03:36 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: 13764884 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6D1F1A7068; Thu, 15 Aug 2024 15:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734261; cv=fail; b=uw25+emeJZgL04HPtaSS72ZXNqPJYxJhJT+79KoXiDPkyjKgp9QJ/BCAxw5SDupjMVze4/oaBmbGJe/nsF06DIRONkMg9OJQnzxvXQ7hQCQlAmLX2I1RlxdvpL5Fvyl6JfJOkILAGB+EbkuvfHQyMJloYheS1bFXQzGuyboCqM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734261; c=relaxed/simple; bh=cEONTywy9PC2pn0ZQd0GmZMKSqurVf+mxXj7SbHYHng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=tznDMo50hujXm8p2cuxsNmJmDeLhPiuBQejrhPitY8F7Ly3hpkHM6Ru5hry8CM9M0ovuNmZagN4KR/52tL6yAq7OSnelprXFFhS2kXagZMADTGyBolV5SzBVpq8buHhi3yhzKJzJD4pFqEwlcCbCndI3NVQk4ru65PouJv8yOMs= 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=Y7ZRlttH; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Wrt5zJ0v; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Y7ZRlttH"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Wrt5zJ0v" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47FEta6S007719; Thu, 15 Aug 2024 15:04:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b= Y7ZRlttHPmCL//nipRMknsz/FWVy+ALeiago5gTuOEveNHAapxXCG8atXpcCJexr A8Z2fGlCWD8OykHtQN9mypYzeTmRjrVSjB8DI7gHgoIdH+alHscQo+pJDhxfD4vT fWDFZYKxihCp6ESqF1j3UpeAH7q1+ek9NvEAZ11kVF0zsW0Pfx3yjICjhGCFfUNb G/16Mb3F0myPEpsA2aQwn9vKhhzdupyw5rzDgFGsv+iGsv27IyxfwVFiwSYp/BCW LEiXw45Bzwtf5xiqo9B6gQsYJuPkRsoQyavKaNoeqmUbBTFIje3jL6Eq220XEDwF aRS2k+Ig0pJx9H6rxoIKsg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x039afyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:07 +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 47FErl7Y003532; Thu, 15 Aug 2024 15:04:07 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnb4abf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GaB2JXI/MwQRxh4w8/pM2i1ZmUUPbb9KrNRcQueVXMDe6KR32/e/3utw4DYwLAKtKm2kRhAR52sN7EVHUAvI0N4Z4yjucvbhiOcAZwNjimZEFgGlPFJBn1szgectaKBmKUxzdEjqVUD+tgL1wIqnEqKL4j2Js1of1CYu6k1wkiOuscfo6nLbguOWgtSNFZchA/AuyHPZgBuypBVQDa3FNxLXlYbLyBXhAX4lTAb6pcN9hylpxZ7WzYbJOnSWPxurkicB6oHCwgoqcWSHP47hw2MMm26mTel2oQU4X6gzrwEV7OLVhC9mO8dRHwtCR4b/6wLsygE8YXJLs4MrG4u8dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b=vqQbmJ6Ddzm/DmeSeiw8RK9vnge2fw1EylcDE16UQzDNBoVtKOodA8X27ARXxU5z0kUAmNIH5navAafW/778guszGsTs4c4gMIhhumWTaa1D/HB78BWXoCJOQmbar/IsXKS01LAuG7HqarWvF9H0FOiFTvfUbd9D9c9Q5AkjATYJbBGVena2wBAWDXh+EMtLDkIIfuZred6CgZd2/88LTOJ2yAaCB8aGa5lZfGESKgswreMo/MDZKx1vy0SggDuTwXS8yupAueLYGqb/u3fPc1jfreVMii5crdFT+r86h5dMneIYfDjj5NVtaZ7UGu8kPNm0WkOnfxWB5vx6a2Ecvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YixqDMhab5DwvjOPkCCMuSsunYvDC0NxdMbagT+VLjc=; b=Wrt5zJ0vVhu450OaGtPGOtJDvdfFucnHD7RGew9Z/WpDTf2uVKzSNrjRqst+9WGpDyl/61dG+pppxhMtqrDjFSaa5ot9TFFKXUgVmavdTdeimaz7knnKbDJMqosSPuwBZruHAQGdCnCCTXVnONlsRkP6BpAG5DdqrZQupeyw+TM= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CY8PR10MB6657.namprd10.prod.outlook.com (2603:10b6:930:55::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Thu, 15 Aug 2024 15:04:04 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 15 Aug 2024 15:04:04 +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 v6 1/4] kbuild: add mod(name,file)_flags to assembler flags for module objects Date: Thu, 15 Aug 2024 11:03:36 -0400 Message-ID: <20240815150339.1564769-2-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240815150339.1564769-1-kris.van.hees@oracle.com> References: <20240815150339.1564769-1-kris.van.hees@oracle.com> X-ClientProxiedBy: YT4PR01CA0375.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fd::10) 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_|CY8PR10MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: 81de72d2-1528-4522-b3ec-08dcbd3b80f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: oN66G1oeLfHth622dANd4qj3R5iYCkaQxMjoVhnjYdHdSk3JiJxtKbH1QS63h86W+VKTcvFWf/q1g7q3AGF59cgXXVsNii1cNmN4fGS7ZJ1VTMHO7KZ5yVO+Uqf9DGm/AhINDSKvexfRQQOTG2OQnxQV3B/KccZE/RIMV3O8I+CAcz2/eAFSN4IFA06wEsUtLMSng/JwlMsIoFWNaakFGSunV9VT0OV1vNewca+DilCN3HyT0z2+uYP1HUjZGb/stqk0SP6bWMqmzb6+aFA9rikdPqS08CuoMr2Q0XKYgzj5JwpyfDfkUVbEyC6+V8UXUrDD3A3rS1+VyjeaAA5waRvYMODHjKebX3YAwoAjq/0diIUTYPyuwC7UEp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.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0BJ21Yw8DeVKZBfpmzQY55HDb28vqoC2zzQKwijpVFGOLw4GAnzC8JOV4RugelhY5tS0xYHvioaR+kPec5NpeWXnJ7Qg+CxUFEtu0fhTNCqPamwn83IXISdCtoqRTp+YTaNqezok4TM4TmlSpn767D2TVkc9+hCdBuaABUotkZciPRVSBOaIs2+iVD8TTi4gn66qvUXQru9t91v8jv5DfqRJQW8ogJDHqcRvjQTFEDMKX5VeDw42tJvMSqsz9dUxNso9a22qHp/PUj/NSG1R4DVW8A5DWrQW+lN4dl8Cf48tbzAmE+WkXLE65BuoO9wYhiNasSDfUmqTzUPF5XaHV8PWrlG2Z6dcBL/+ZuWf7DcJ8rKsTLjirf6g6QB/exBEAZ/qFZ8RTlLxRamvNjZars1hP9eJCUV7mFkrVoHgVALkjT0Ixn6KVrd0/scXQHX3/2lG2Qe8BalqENAJU1NYSwmV14uOcJIXwAjDCmUf2E2K9Z3MFSvOZrtKniVVZ2PWEetGzGqMWvZJPCFrWnI75Fgz7yslBe2O3Aas5Dg2m616+0waHxJ+W53Q7oM/gQQd3BEAl9WN+Dvqh3dmrgDnB7o4Z1oheZtLT1jQVe/7tIB6Hi4inmygw1aP3EyitMsoJFwJOEdz9pZvvfQd1yFE6EP2bxVVchiuj8g4BIf7vH7Tg3npl/Pb92N+fsRD+m1Ievm1Gok+8J011uYoWEFRPqUEDTzHZZbPjJFZ3wme9QRTFtYBK3jDwwXMZO7kbGd52/2NBrxTNG621RKSw1ZpVKyu20MuRVZsAevAosUeDx5JmmvwJr+NcG5Z5m0Eeb/EAaUXrj3yWRwWftUQkYYDdxuUwycFSTkkhVsuF7ZjRYZGcWKG2UBkLDJgxAFQX7pLx6gxla9F5WSthqCRTf0rBHGAF6SYQgnVCevyDep50nuylnq8Q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oVV+W8QYwjCZQESxTfrB/rLRhNbQb39I6VuPkHjL4Et/G6nqizDE5FBplLuZPjcYZk07VpuNEjk67Yy3YBNzouGQGMJEkjkm2EZGg6UvScV7FwkDSdIWBDXYuHL7YOswLFE+Del4lX1gZ7GLIKU3XoWce/FGrfUvKrLryv7NehzCzQ17Rcaw8ggL/8kAUVn3fI7c/rxSMQckP/Q/XTjlvQrsU1dtgYisyMy7/rfilAGhWJNsw+njuAZ3lq0r1G6ZlYNs64QKZpTjE8AO72D1Uj5vKDDTIWCQRp2zPcgb9n1SJU+ruv7G00E6YJSc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81de72d2-1528-4522-b3ec-08dcbd3b80f3 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 15:04:04.5083 (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: 4nkzOdCghf1uTXc6DRg5BBmotwW66z93lzm0RMPurcoLtRizT/edAWzpzFJx5lPAQcWqqlCpFPHHqzveC/faZA0w10UHE8Kd2YdPecM/xFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6657 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-15_07,2024-08-15_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxlogscore=909 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150109 X-Proofpoint-ORIG-GUID: DQEv1WEQz0p2kOMEqJ3PEHCmVAg5f9Uq X-Proofpoint-GUID: DQEv1WEQz0p2kOMEqJ3PEHCmVAg5f9Uq In order to create the file at build time, modules.builtin.ranges, that contains the range of addresses for all built-in modules, there needs to be a way to identify what code is compiled into modules. To identify what code is compiled into modules during a kernel build, one can look for the presence of the -DKBUILD_MODFILE and -DKBUILD_MODNAME options in the compile command lines. A simple grep in .*.cmd files for those options is sufficient for this. Unfortunately, these options are only passed when compiling C source files. Various modules also include objects built from assembler source, and these options are not passed in that case. Adding $(modfile_flags) to modkern_aflags (similar to modkern_cflahs), and adding $(modname_flags) to a_flags (similar to c_flags) makes it possible to identify which objects are compiled into modules for both C and assembler soure files. Signed-off-by: Kris Van Hees Reviewed-by: Steven Rostedt (Google) --- scripts/Makefile.lib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index fe3668dc4954..170f462537a8 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -238,7 +238,7 @@ modkern_rustflags = \ modkern_aflags = $(if $(part-of-module), \ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ - $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)) + $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(modfile_flags)) c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ -include $(srctree)/include/linux/compiler_types.h \ @@ -248,7 +248,7 @@ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ rust_flags = $(_rust_flags) $(modkern_rustflags) @$(objtree)/include/generated/rustc_cfg a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(_a_flags) $(modkern_aflags) + $(_a_flags) $(modkern_aflags) $(modname_flags) cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ $(_cpp_flags) From patchwork Thu Aug 15 15:03:37 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: 13764885 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B60C1AAE1F; Thu, 15 Aug 2024 15:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734264; cv=fail; b=bBORnt2zL1IGuJfa0jLP+WbW47iqEFa7tt/KIj1h5oBOLvofZWYgrj9AJlqdXrLxf27HiMyhNHkgxHd/SDK+xakCuDMWb+u4BYCWoHssrDFY6AUsptc/b8dnTK6dpUqWgM9dtUisrwiwE8FYMHOODqaGJuHeinU/1ankgLkY3cI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734264; c=relaxed/simple; bh=pRe2TzdsTc5G2CIIWyS9XeM2rziIb11t6UGeOjRQ5RI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=q1gavD3BxCTyud+s2xYk0LdmSSvWC3hOm6/JtB2Jeo1QCt0bvItyuurCJiEXcobhsHoJewoZm4uf4yS6SdHjXjbQj1oShy7YERsmD5P8BzfvyP/W2TM9eUQm5zqGp4k6nwrA1U8DDxMP6W3j17mt79DpibFVN+hui4fhdDAofOw= 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=fn+m6Cko; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=IvMeVUaG; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="fn+m6Cko"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="IvMeVUaG" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47FEta6U007719; Thu, 15 Aug 2024 15:04:15 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=GaaM6snQg/N8OYuCQG1wPoYERypmgLeF+WQh6Am2mQg=; b= fn+m6Ckosx9mH2tNKoovzwttqkznLrO6jhJrGpu25+MAQIhXnWC1raMGVCIYZ8w3 gOjW3xVRzlWOID/oyc2UO2lwIKF6s2HS9ZtHPTQmXvoo0XtDyTh6sBvzqqLP/x/k Qh+PS3Jf2cQ0AaOqk3gGWzzHPlrzrR0KelPUGEJ3Nt/MHxKhT4dLrN6pG16Fo3YE Ugf749QiF6jVMahb9lb2IAp5oscraa24vHhGyqrIykaK9K1viF6IhdXlZlLpufXZ URsGtuflCfZpybrGgy/iNiFvUT2h7H3IYveHg3nqlZm8lDpZ0yg75MB56BM5oPs1 BhITGX5XdWIMXa7xaQHrAw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x039ag03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:14 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47FDbUPN021064; Thu, 15 Aug 2024 15:04:13 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnhqu05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VcTLLIT0FkxWqvQnx3tfNcQqk35tUx7OQ4BxTkWJzthGo0evcJuYvZ+pZ+ypKtGpiEGNLysG5NLeHQFXmln88OOh7AYdaKILWm2G58oQdKrzFHKfbNlkazdQEQbMXubvlbrPZtL1ygILWeN9XgJlsFkvdjurwe4qcnhHFuW41jId4i1BdYdLYvra7e2bMA15gvLDsO5Y4oZcbKNFlZqswqWmjGg0hdRl9y0FYpxhqCSmc5q4C5DQiPfIKu1LZkT9wkpJUyXEpPuTDUMM3w2Oz4Fd9ggDVo8EaQ9xcgGqhVy6t2RP5hHLA8isFsaMYr4Q+B11OPggm2Y5ENkwPld9Mg== 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=GaaM6snQg/N8OYuCQG1wPoYERypmgLeF+WQh6Am2mQg=; b=XYJBNAs0aQDr398gev/oJW/Twg6ykvqqs8Hb6LLn/CpFSvoYYaxogqtgQXWLOC4kf51DZ8t/AGKzYmA7tDVx6tzSyl/yg3aYOehVbLXiFCyVWRVpg9yef28T5NUiooeuL31wYDD/QxWLuIt1rv3eHzFSW49JMaQBmy9LfgfPqwrRQgRqVAPyqlDqsCoMVSokAfcWRR81Qwo6+F+6Uv+q62taIyJssqrPgYZvhmiuoPILjU4jrS+tRsrO/bpLuKVF8iIqbmCqSdDF2AWbX5Z2M7ux6Lmh+ZqtQ2KyC69EyAmJEByOEWZRud9X6ijESWM1cibbYBMKOaVNCGNc9qPJoA== 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=GaaM6snQg/N8OYuCQG1wPoYERypmgLeF+WQh6Am2mQg=; b=IvMeVUaGita5no23FjndJzPrq7Ui/Kf0ZMpsV03yc/Qn6ymG0fKWwcRG7xwCH/RcmT8AIq5c8RQg2oxktsecwsn5JVGYPQ5TZzUKcvzLF5VUf1AVUgyciAG+VUDrYyiXyuUntStnzNV4tJHtXMnUsUl78c0o4SfJZOT02wgxAek= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CY8PR10MB6657.namprd10.prod.outlook.com (2603:10b6:930:55::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Thu, 15 Aug 2024 15:04:07 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 15 Aug 2024 15:04:07 +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 v6 2/4] kbuild, kconfig: generate offset range data for builtin modules Date: Thu, 15 Aug 2024 11:03:37 -0400 Message-ID: <20240815150339.1564769-3-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240815150339.1564769-1-kris.van.hees@oracle.com> References: <20240815150339.1564769-1-kris.van.hees@oracle.com> X-ClientProxiedBy: YTBP288CA0009.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:14::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_|CY8PR10MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: c89baa2c-b22a-4117-8fb5-08dcbd3b82ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: D6MKFsZPtGR7mALHudfM4pFddFAwDEUE7G3vsdiRKzz3jX/0Y2HPaTKR/b/Qf/SfcqUQs/6PENuLeizomSlpgaEf1clPqPAnKN3sjYlA4/1ckapAuWG8tX4EP0htvOdGymhBhh1Cun3aBVwTcyRS1TBm0HVCOegyZ8cviKTpg1C0tP4YLDqFjuGYfjQaVakgUGo03Slh1PpWcD+pU7NoULPW5LZ/jlIceXCkIVzyYmGNPh3Zh+VHE0b0OS5acmEarwOydzut8MRJRI7MrqmWdT7+VqKYl6lXpR3BVGZ3+tT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V:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aKnohj2kLbGQIqh2o6oSsLyzHEHIxEp99vc2+F7OPB+FXm1Fra8hzvmQYcVjIus4WZfcVhKavHtIBB9KXQcvpuPZsgRf5mKwzwZrKyzQ+0zffWBBeZ8S18Eh0KtOCLkJUubqrz8zBtETCN7lpXs4Z1il9xYFFtuHbkPv5PKiwH3stuQJRgtiJt3+JaJRbMYJ93GCqbsMvRO0z33LkOR/LjxhtRiVWINAo6fMqWzKKjLPw63mFbHxwpQZwJaxynHlzFrpc3y03WkhnchYFOrxBNG8E0o3FdT9PmD6M/i/oovDT2z+Qp7xQkT5DjC7CdUSfj0mw1kA6hdRuNBonPy89dAmKKnbkuCO99DAwTtGOdBWNwC614UfPUVojU9fql+jb/vSJASz1kdbxFuvDRMJZY6hRcqu12Q3Ho5crjh/7B1K0UK3r9/gTxI623qykVlGW5CC0cnQ5zJiwcFf17du05xw+VLWuwXhsZbRyE5suKQLQW5pvwDZv5iHfROfoKTyIKPR82j/JO9ecctK8xQU6YOe9t6UreUzuPKd5SlP57nHtml97Qfl6JukWv40gmm/Dm+hryTZpHGFJ8IzDHhwOQCLvLwadCHxTzRBU5zGsbznefFMooxGKO3Sf5eOzfg1/KfuE4WNKOeoGDwyxhVqx+jBQL2A/fPVLrsK4pP8ECmif0bgToVemAKEG1zqTmv2vIrnueMyxIsPPOvDn063RWxjd7SzVa2c/Q1SWojCLQtOPU79x3jc7mKK/5UafMs54c4xPqaiE19zHRvurdas1KsfVRTRWBOUwdWbWHgBqkiapMKmzFJ8b68OHUszyaa/dolTp66OqDDF4EottvuTWTHtByhaY1k/T2u5KD/by4bqAT1ll2jwp06GP2xKv9bKAwGfoZiU0J7SUoRNwzwX+n7dttowv3GOW7jYvgHXbiESRwfRIpduwiP6nw1zZAHhk0ObWFSkXUABa5D9JTTAx81z57jLKbPcQJVSq4tmJV5psr8dhJQKoR0qGBD2+CaSxStkqK67CPRNFvxlIwzSkvbKXo1oaGHCF1LXClvx1HpWoZei42mtDmkzVtmxLFni8Rk4RS2wzaCPfNKJhGG/4cpE3vsg6iIBbzCr9ruMfOBYdRYglp7prV9PADtrILCxtCO94zV6gEsEGftHbLbQCt26UldVvzrilgR6sso4HLRlZSVFz+7EeZcsYZcXhFmgkjcbDUMpUdHY9gFp7KuvRAcULXQK73MCK+f9uzo/Bd42j3jYX4Mi7IAYtwrwuzFaZSwriAqLCPxu7NMV0Lx+XBAgqq/2Loe84oLnSfuxSPIzfpvs/P0ROxtkFdIEtatWmvs/1dRJNZWfKUf0YZeWhAYoN1HOSyEUHDaSscH706SfJqUTJNyf77lieEm8JjNU6ztzVa3/tOiWsU2q03bz9xWK0k0b1ckMO2hX7wKdWsSb1LM1k7end1FXSqQotTcWbg2cwPtgNAaT9b9RffJhdSx9P17OSYcfR73Ym2zcwPDQyHQ1ijYXXwGNmF3LfhpHc86qfWk2q/8Gthzdn8itMDjHuttKsw9gnRtacCNDna886w4Kch9JP32eC3Ept5VxMlvUuwziHZbR8zlhmxMg6c0k0/KFKWArA20hknW67QI= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TgbJejdGafiMQ8BU0aoeERnZev5byNinFGF6/6jkfcuVQHo81LMprbOER/94bcja2RevEpmRyuLkpkhwCiYNnjdu9XqvMDHVzcepJKagbHGWbGHxaoi5vpyKl6rB0uyO8AHns/Aj+0TjhDYA3OTLtF4eW7TRVGNizCBfOxcPAXZsXAyN1RIB7kd8FbU8PnakF/azJD+d+++XbonMoVOU2xvrbc3W6WztkuEb75cDsV5MMtI38rMI6XIYM59roGMuEn0be1+eSLz84uDSrLAU9/zthEjFG+/WKMrBvTZZ5WwNGvymsFtyOfmo+NdPsT1ZpEhPXRgnKPvqBECr6TDtYyBfOS16E9n8kACpXpJv1muRxDsXQmspKqb1NY7bHiy0hALIRWLKl+4GriI5ay7aMXoSdDEJbp8+Sx3HDKnBvEKim8vPpWjnlEXuLBMw3ftC0acVLsa/4dDqx+t15jwHBHwlrk2gvHpIdkyFkwyN8gOb3WyppP2+WN4FhYZ43XXQcUD+4jDiNJMvxjl/BdmcNrc/o1mh30PPecZTKKOE97VVVcthC1pAgFDOLV/Q0y6pA6tNS3g1IxDFow7mT6uegP6xA/TQHOj9NAVZ+2yB2Ro= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c89baa2c-b22a-4117-8fb5-08dcbd3b82ab X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 15:04:07.6222 (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: lRIJRuw+320YAzBmKFW0/6JbY0ibeTm97718vatOyh3CDHuaZomy22fXur+GgpLX+MkT5GXTiol/sVjpA5mBlG7UbkU2LbP9Ia0IueUDFJ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6657 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-15_07,2024-08-15_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150109 X-Proofpoint-ORIG-GUID: AMVZxAVXoTeN9FpKdFDls7pjnslBYYR5 X-Proofpoint-GUID: AMVZxAVXoTeN9FpKdFDls7pjnslBYYR5 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 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: - 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 v5: - Removed unnecessary compatibility info from option description. Changes since v4: - Improved commit description to explain the why and how. - Documented dependency on GNU AWK for CONFIG_BUILTIN_MODULE_RANGES. - Improved comments in generate_builtin_ranges.awk - Improved logic in generate_builtin_ranges.awk to handle incorrect object size information in linker maps Changes since v3: - Consolidated patches 2 through 5 into a single patch - Move CONFIG_BUILTIN_MODULE_RANGES to Kconfig.debug - Make CONFIG_BUILTIN_MODULE_RANGES select CONFIG_VMLINUX_MAP - Disable CONFIG_BUILTIN_MODULE_RANGES if CONFIG_LTO_CLANG_(FULL|THIN)=y - Support LLVM (lld) compiles in generate_builtin_ranges.awk - Support CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y Changes since v2: - Add explicit dependency on FTRACE for CONFIG_BUILTIN_MODULE_RANGES - 1st arg to generate_builtin_ranges.awk is now modules.builtin.modinfo - Switched from using modules.builtin.objs to parsing .*.cmd files - Parse data from .*.cmd in generate_builtin_ranges.awk - Use $(real-prereqs) rather than $(filter-out ...) --- Documentation/process/changes.rst | 7 + lib/Kconfig.debug | 16 + scripts/Makefile.vmlinux | 16 + scripts/Makefile.vmlinux_o | 3 + scripts/generate_builtin_ranges.awk | 515 ++++++++++++++++++++++++++++ 5 files changed, 557 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..dcdf14ffe031 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -571,6 +571,22 @@ config VMLINUX_MAP pieces of code get eliminated with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. +config BUILTIN_MODULE_RANGES + bool "Generate address range information for builtin modules" + depends on !LTO_CLANG_FULL + depends on !LTO_CLANG_THIN + 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. + 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 Thu Aug 15 15:03:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13764887 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 CF9A21AD9D9; Thu, 15 Aug 2024 15:04:28 +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=1723734270; cv=fail; b=T1E/5TUJb32b61MHK+3sn64t7dQKp8ouqvpNtv1xTN5W6NAmBZ4fRm0zTeL1o6RHJeivKgBmsjbyKwbtrNdTutl6aQWiJlnl2hmEq76iWkCfCfTi8InonfAn26q/jRnG39oSBMg/xp7D9jBLblzp4AwHw00bzMTDtnazGg1+4CY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734270; c=relaxed/simple; bh=ftSiw6pJwtJSBUEnrSMTon6hGKj2JCRrSdZcHLKbfjs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OByWY64uiOPR3v0xurndhKd0A2bmH1IR46wA9g9hGgqk4o6Mmyf22B73T7pG2wb7vARYfX38KMe4y2Hf9Wza1hfkpEr44q2plouMrM8N7aF/wAmcVN7iuEFEE3Dle7AZWjneYQ7lrIbkdWVaSnVvRFdGKoSyTQ04UYDO9i/KfTk= 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=FV+sEew1; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gl6WvI5l; 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="FV+sEew1"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gl6WvI5l" 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 47FEtXJt016195; Thu, 15 Aug 2024 15:04:15 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=PxilyXXdM6Ve7rkFM6qZeXu7Rm7nXpj1Ft7ycoSTWvY=; b= FV+sEew1wfYaR7KC97KQ8iOG9LBQB0qxTefKNpDi4VtZzXbxuXeMqIV6l/rPPPR0 oNLlC0jOuKbSVCEAG8vx7P9fpVCyT5nI8etdTQlKBJdqdQI9nfPI8o2MfgzxFjNt 0oxz2bY/tofGvo5ckebWLoGSqZfCg0qEL5Al6nvy+NEcBUvxhMWKKump7ZnJsLWW 8MdzOIlT0wk71uljtdISm0uqRZqpI+4Prkbbn7LBRUIAPJ6EwfaJ5gaFifawiqGf CQdlI3QlbUH75UqpMfsNTgtlnBPEyl/wkoDRwTSgLOD4SfV5bKKBwZKYiO97udt3 qnxc1S2HsI1riMHn+xPPMg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxmd2huv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:14 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47FDbUPO021064; Thu, 15 Aug 2024 15:04:13 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnhqu05-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tC1yvZOaB1pMmWcpXZU8O5B0Rs7vFZLFxythR7vv+wl9NLhGLW7l1stp/iZ1PbkQpOVy0pFrPe6nvBGcAWRhlUVNJ2DnjNrYPgRVJlWt0UxRDc3EWvrc9p6mudFAhs8laQwW6qgXYOVUHeAJ6kMHuJBXwQyHtNby7m89Rni7lHWPQKu8XxW82SAVJ7R6saujnBw0BRSwOHs1Oo3q3zIPKNUPNCH0UbMRODm/TeI9e3QQQCKP6gdYhf5zLz/x58bpJ62Putfz8hVJDU+FeRGrwonu54Hodg9O6C4x+BoaiY8magUUCe0EoZvon9bGxwtwVoi/+3QdUBcQEkjRk/ljTQ== 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=PxilyXXdM6Ve7rkFM6qZeXu7Rm7nXpj1Ft7ycoSTWvY=; b=KfJloRyjJcaIVYlp3Q5VLUWSMh0aIEDIdlXTcC4LM1Mi3WwV57mJhRlmxGDfx1pkAEXeOuYlA/Taco797iIi+5r9/hF1W26YGBCCZk0FRii3Zi8E69/fH/p15zBsH2kH4LDSU+RuNRorJevkVAMx6IWbEYfVojQx0CBam09xJULXeDnFQtzIM3VCeAxR+azr42T6zoselKhJROlRhnrzJVJx3xXaummoe1kaZCcdsDneKBwynNJ7sLznALNRcEinKYQC+aSdoSkW2alkV/FZz9U6WN4OLoXyh677a2I8hhtPDEXi2MIT7f54dvff4XoYZkQiTKzg9cTKL+fayVNTrA== 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=PxilyXXdM6Ve7rkFM6qZeXu7Rm7nXpj1Ft7ycoSTWvY=; b=gl6WvI5lT0cZTQAzxc/+quMxrAwy5uSMKdffxHjpWZS+ET6JJAhkNJC8mYJSiEt3JFumlXUAKMjiYqM4IzPLhPaKEOPvC50kbfhfcsM0jmlF4Sni/v95s+nPBOOSb7UwlbTSj+/0e+hc3W8kVOSvE4TmaJ5+CXc5KOV81re4XcA= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CY8PR10MB6657.namprd10.prod.outlook.com (2603:10b6:930:55::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Thu, 15 Aug 2024 15:04:10 +0000 Received: from SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29]) by SN7PR10MB6287.namprd10.prod.outlook.com ([fe80::5a47:2d75:eef9:1d29%3]) with mapi id 15.20.7897.007; Thu, 15 Aug 2024 15:04:10 +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 v6 3/4] scripts: add verifier script for builtin module range data Date: Thu, 15 Aug 2024 11:03:38 -0400 Message-ID: <20240815150339.1564769-4-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240815150339.1564769-1-kris.van.hees@oracle.com> References: <20240815150339.1564769-1-kris.van.hees@oracle.com> X-ClientProxiedBy: YTBP288CA0014.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01:14::27) 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_|CY8PR10MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: 082b28f7-5afb-4f99-3b86-08dcbd3b8453 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: RByFlOvPP8MOPJ3WpGBXooEd2mZAlUAn4clPhgo2ER/ApA60S/Z6VYNVplCA4/Tv/u1U5QttTQESZOX5wjL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h/3CL0vSLM/zDh1AeLabaTe+R2pOmASzzo0+9dOqjYTj7ucKJ2+JYXj70hl1qphxLl7oKFvnkWzWLIpnIS22Cgknh+LkElhouG5yTEd4YdSI4Pc/tcQTkDiI1INJmCxvOGw+FGsxy/Xv+1fzDAzSRXkkA69l8sXFauQDKSZIWXubG8XSxDKzbCsCMjQeujaaqL0968FV2gb51lotUWWY72oRbnw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9bnhbpvPIfJOLsw4ebeze8HjPhdMAcFoEssTxuEuwY0AxpTRutyMQVQY21W5JTJiuEB+ZlWDtXj6VZBXmVJHGxBl3gUAwkjSM/sNyDH+XaZrHfmDfWApB/Ba0BowbDpXSc3lyIl8/MeUasz//rMB0DMabMSLEXnQSHiCNaYR09BhXsX+4EDUSy04/mf5oqguot9GXYtM0FtHZ3IHSsVzvn0Av7SSgzlVwlrMfeX/5UU8dr8UDApqkWb53PPMvozq/t3OlL7eD7i3obIuLzWMZMAowQoWzLFkO7OOx0ycAaKRYK32fg5uRWmCRxHZLIo8LQUir1qc+CKtwtuqm5wJXdCNK9sNa+RH75AOM/1KzFUJIxwHLRFs0BWA5MBaKfF4YJWJDV1y7BMIyKouXqyjO0TKRs+Xi5L39MtDXbbdrRHa5PelMUDwd4d4pbrbWKsNabcv9RQNX1NllXsfPQQ1lKJuexhJH5QMxzOvrfo/SxvlMInUEgjD1+mHHo5rJWTNC66OpFIrdUEJrJCqeJz0abgwAb9wndM2t63CmYoT/ehb6JutpyuOoQ8VMgYwbaUCCeRtKKgtaP4X3qb/Xx4CYrljTUyoWYVmizw9XmnUMIWSMjhimdN0wDwFJOOMTdYs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Data-0: SpuogbzMcjGM3l79e5UKJw9lZm6kIDaH2P6o8QrIyB/1Wi1GMFBatd7BEL/o1gBTW/Vbt3FAmsN0jmA33IUb1/5Zt8+EWwuyeB4RD9weB3NfcYvmpkoEFDpCPyjJYFhCr659BslMuzBCOhsz13JprW/jVfCDQ6zs2DP/mBy4qlhD3i7hrlv4V7vyPWA0Msjh4GUnnnOApYfOzJDqcG9HqLAd0wc/xZKcLCVdpZh3mUEpRgd+CmC8kYfdM5l59h/Og8KpGRdEi4HIWjHVnPqB+Jlw4Jy2NlKIGCfhnu9JypggjKAC9Srkhp4IMTZF5WG+mOggIydiYSgGhfBAObiSgGo0Kq8GjIF48EJR5DXi7X5LHeiTn/VF5V5phIpGQQUMFYkBnWi5y5NAndSNItu6eVOvyy8aHu0tCPmyj3OPC9vno/bxWjaIeqTUWmEKJSW8zv/wVWCJDAGCgGXrJUtRq71NRGF5mzrENc+WAipghTe47HHrq+77j0+Y8bTjvIso0YsJ9qzFbFHFlv/IDdCFk/RQf3+/mV8O2b4lkjIlc0xGfHL3oTjL5JC6L2PwiKKsVn0mkgd/Lf3kUMOALtHGiogV8fjgR0fxoXzrS4rHkn4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 082b28f7-5afb-4f99-3b86-08dcbd3b8453 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 15:04:10.1680 (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: QImydNtPPb2QLibdae2OFg7i6R1buPSd/oP8tn73MWOtkll38G2kHlcymoI2zfbGU40TmfwoQhF5SkusWi5c0EtTXKoLfY2GrPVQykqIhHk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6657 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-15_07,2024-08-15_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150109 X-Proofpoint-ORIG-GUID: DFW-iZCXOjOmk8yPftHR_PkPht07pJEO X-Proofpoint-GUID: DFW-iZCXOjOmk8yPftHR_PkPht07pJEO 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 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 | 365 ++++++++++++++++++++++++++++++ 1 file changed, 365 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..b82cf0a0fbeb --- /dev/null +++ b/scripts/verify_builtin_ranges.awk @@ -0,0 +1,365 @@ +#!/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 = kdir "/" 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); + } + } 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)) + 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); +} + +# 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 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) { + printf "Verification of %s:\n", ARGV[1]; + printf " Correct matches: %6d (%d%% of total)\n", matches, 100 * matches / total; + printf " Module matches: %6d (%d%% of matches)\n", mod_matches, 100 * mod_matches / matches; + printf " Mismatches: %6d (%d%% of total)\n", mismatches, 100 * mismatches / total; + printf " Missing: %6d (%d%% of total)\n", missing, 100 * missing / total; + } +} From patchwork Thu Aug 15 15:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kris Van Hees X-Patchwork-Id: 13764886 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 964411ABEA5; Thu, 15 Aug 2024 15:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734265; cv=fail; b=DBiw5UzXeKiLDzhY3y01jAd30D7C9/3QenRVOxuyQbCU8HXLtwuGubU/ckr154LM6kwuNkIEoffX3nCxIE98wOp2ETq5rcCKgPoYTK3E2pw8EsqYl9ncO8bNF1yR1VaRcbIHLapyAjvbxUhTM3TCdB2eM/1VuWHLgHxK7XqI4tA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723734265; c=relaxed/simple; bh=YrmsrHdvhN6Bi3OLDiVY61cRYA/t9f/Heq9ACtkmqXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qGMDGpk0wVUwSoWf0qEx6463q44VIv7LZ8RzWbwMf61Wm6m8w5LvxgFhRcZYabeeSEbGLvDH4vHMAVkEuCBTVhSFIZPeP0k9ZkeX5toMQguGJ2DH3+aRyqQ8h0kr3EXiyGip0nG5+efWKxwsT84/QaMzdFEW+6vifSKEvhawT2E= 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=ZKIf5YHb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ak1aFiGJ; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZKIf5YHb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ak1aFiGJ" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47FEtaKG007707; Thu, 15 Aug 2024 15:04: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=q8mEcHIT6tdZ0c01dmwaG/cUG0iTf3Q7Vxz9YBAujs4=; b= ZKIf5YHbmbFJNQKzOUW69yTACmA0SboEfLKAAjXPlcQEuobmzwoxVlLa86coxLAK jWqIoqRAZcPvOUZjp60mhf0vo2m7MwqZHQjCAAea41NVXV0gNsV3+mYV6a7juebn Q1e8u1m1fykla8BWGQ34pI/KELmAzwoVFa/8QojmOCg1Tdfe14ksTEYqRL2WRiJ+ m+KCzfY4mcKhNXla488Z9hcOdWAKCUfOBVWopMgNicl/fchUoFzVvI8Ylc3ulmrL AqH9GBHNEqleKBSMyvaJQkht4c/lHk4l/6qUCqQUZUJzL7SapmXLGVALavT6F2+s fPYmHfcB033LCnt6H9F2wg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x039ag05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:17 +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 47FEgHYU003739; Thu, 15 Aug 2024 15:04:16 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnc7ka2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 15:04:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e8NwsjTujiaatljV/Ed0EYfKJ2tIqgYFFJYRvnbcuiuw6mXrRDP+OqCN3YTNF03Gts5+2zFRSOly1dzPyw+EdnKUGzlXz1KIYshJabsUZVbFToScKB33EmaWc+PAx9pVza9FBi7cv5ueeN7wutNIIE4UiKpvpp0tQyTw8PHwyAd7Iru28e0JSaszfRHXzA9TaXa3dJjdfXKWbDtA9K84480zgp6Szl9CmMney6aatn4y6oNrYERSpBNQX+1Cs7SJ9gqc8efU9y98jglSKCXvX0msc+4ksj0CBNnlZNZO1hvRzcq7+iJQ6WOevkXQbHI9N9qI6yD7eKzfdlP/7uVxSA== 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=HF964ZbDYVgQXqbvNyIoXMohnCavrnAhYljZ218w7BOZEiVo54yWxJZTqyYwzfcE4lWlXJVuTVtG+Sh2cd7mmv2Ttz/MPrjfe6IJ7szVDatF12poZfENWS11rXE1CMAZOItAYU1MP2WetIFQlw8VqfKY0x5YXZt8wAPoZUJWaOl1bUP6bUrfDIWU26kzaAw7lYGIO/VRe404jWKgTc+z3lkSmOk7xqEQLbAZENnpzdGJZpyoObf1EohJo3+MzNbDsSFSToRLu3zRa1BKLHVA7FItHDvn8WeWm8Pcrh4uKMj9TGcgrTqsMUxoT7v+Q8Hhl6EQLThfxz8GD2Ka1yL9jw== 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=ak1aFiGJx8lB+oOP6OrjilAMjl5xpWx3DNQUwnt/gYbwUNdfkBF1TZLHXu9IgpjhR7tVJ8jfb69Jg3PQ7VN50XVNzeEdppVuGk61cDi8kDjabCd8Nl0IHzOIrDTDjzQdbVJB9CymIaZS2ziryFlyEHnddpntl7WN+h1Ugs2mD78= Received: from SN7PR10MB6287.namprd10.prod.outlook.com (2603:10b6:806:26d::14) by CY8PR10MB6657.namprd10.prod.outlook.com (2603:10b6:930:55::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Thu, 15 Aug 2024 15:04: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%3]) with mapi id 15.20.7897.007; Thu, 15 Aug 2024 15:04: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 , Nick Alcock , Masahiro Yamada , Steven Rostedt , Luis Chamberlain , Masami Hiramatsu , Nick Desaulniers , Jiri Olsa , Elena Zannoni Subject: [PATCH v6 4/4] module: add install target for modules.builtin.ranges Date: Thu, 15 Aug 2024 11:03:39 -0400 Message-ID: <20240815150339.1564769-5-kris.van.hees@oracle.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240815150339.1564769-1-kris.van.hees@oracle.com> References: <20240815150339.1564769-1-kris.van.hees@oracle.com> X-ClientProxiedBy: YT4PR01CA0026.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:fe::11) 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_|CY8PR10MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: c98c1f42-6c48-4c28-a4cb-08dcbd3b8616 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: cRxNxB2DmgameLUGtpYiXs48PmG2YJH9+c46mPC2ubK/A05oU3TstsNm2yNJx1R6qczUGvqOVpeLEojRJNMMdSQXGtuI074Eh7Mkxk1Ylw2gZeAH++WdoH0pUftUW30SdHNBeXus+Dwjs4/1zVQ/dUObMZeFelCTA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HOnmZI/1yqXaXr4oahSm7jy0TMOlDykdqJL6/C2Min7yuRKWQ2xbqOwWLvAwGunkr3IrpEh0LcK6q4aTkIAYNhvjODzKr2NX7GTCDRDVostbHUBZNZ2sS4m/zkXpD0ep4AEA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR10MB6287.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Inq1VPeIGcJslGfVbwugX2nDnVo6FnLGdIT3TyQV7AP7oqJ5X5Z5iolsq/ZhkQXVKQ9qT2rXgxqrqlJJMC1RccHjDd9qMJws20QU0gNbHEGrSOTkrXL6DLWOWJT8ZbXW7vqoKQNPjLc+JAldog8gkcbW/nOFkCbi1zpdxM4Nmzi/ERDtb7UdgGIN/0d7nJf/ROxZIbqM2QhbnbRwMg+8DitE9dE/6C3N1QzTUCfnzOIzYVlbqUtcAwZ/+672Y4SrWxSDiX7gzA+pNZVg9FVpCwACYCHR7wERMFrvt3M918ycDPTw2U0U3Ikpi0CJ/XP+0l54jQai80Eoev8csE3xYiZvxN+Z37TIUn3M1O5LftrjpD4c9UmuPjr5SnBLRxwitj059V72SSikcUSh8h8dCQ9QS/PlgSYaGbhT7Mcw/bBRV/mhl3M/yCp9Rynyk5jxySJKZqTjGAwKP5I2yuxPjK5Y/rTbcc8Dr2LE3SjOgqKhxEefjTSn9hXwN+/tMJU/iNfGqp/gfYN/LunWgx8DqZO/qYMU/ruD/wCIWrf1sX0IrCgoByjgC7PNXakJRaVXWAslXD9v8zk9Ns0cUqxfDVDP5Nt8qdzt1uzB5QQPGLzjhH47E7MBkR2XQMzHbKh+7MQRUenpI+R150uAZB2qkDni3KUt8eBu0YR1ot9qGFodwpV2u5+7nVj9P77Kl4oL40BnAYveF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+ZNBLwcd2OmpepIR0KtbxoTECHJnqi8iYooat6zAB7PB0lLT5gQRj6nBS2I6AlVTJ/H19S81xzswODyOKUrFuQocGidRXIyy5BhSHyz1vZ1lnYyJMWT0irpspXyvLjOFksh+b2dRtI4kKXSTLjHdy7JdSztfogCAYI16WGoMzutXktBxlYIyKqRSclGD5k9ZAnp0DfGg5TiJ/VqPND1uqG8XGugk18yfcEu6+NPjcKLBlkhZ4LujZOGG5EAV9gMJZozlNyMfTJLwlnts4yP25H9XNYSIWTdr/kSlcW5yDQkZJVwGSrjaGCUd0KnsWhf8km8VN9f7cQpbXg6DV4HhXCv0jiyr/SwaZ20Tr6CEzP+snJS9FYPj+m0oEllxWCe6gTxDapISN3JjL6lsBirNr4lzQ3kwUbnCf9m45BvdADWc/Up9got/TVbTK6BFhEqdfPaO4krWTd+lG4I7tALYhQUCJEd47lQpzjn4ARtFGdYO1dTVlAdbv69owmpkwMB8dQKIwCW6lidNz1erBJ3Tar2Fy/+Zd4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c98c1f42-6c48-4c28-a4cb-08dcbd3b8616 X-MS-Exchange-CrossTenant-AuthSource: SN7PR10MB6287.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 15:04:13.0923 (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: TKa/zpmBW4IWmH3vxcWH09+Ao01i9uUtSPuOFfbVagi46xNXh+SDz4pQFBrU89FX0ZtwJyCU2g6RhhW9h0hzIN/WgEGtKtKu2slUH/SHtB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6657 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-15_07,2024-08-15_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150109 X-Proofpoint-ORIG-GUID: VYyLpHOSjLrqggb0GtATgjIBuowpAZJH X-Proofpoint-GUID: VYyLpHOSjLrqggb0GtATgjIBuowpAZJH 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