From nobody Tue Dec 2 02:04:16 2025 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 DF3802D8DC4 for ; Fri, 21 Nov 2025 09:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718836; cv=none; b=tdvnVirI58Tj4x5VIggI0AKTeLYoIvDzw7YeuYdqDNENlzVM5C5mSBEfn1Zf5au1dbQCWgpcg8i5Pby0Og3+BXobCuk4pssi0Yi5VeCmfGyi2yZ/hK4H7yUeQGnoi8oR2kPJTiCeAtoHCuzuC2eTY+jcc/yLPx0X1VeEUJyfNxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718836; c=relaxed/simple; bh=95K/Q5zxLPGKMSA3WOKaRU2vl5mgeraLLgVVWwwfURk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XLppLhxi1Zj13UhqXB9stKgFDKDRhI1kb5PE64i49wt1VnRxiRfl5+nkcxAg+lKlPy8D0ckel0HOha7x9TZQRY0txorgA60JOWr9mUM+yhLE8qIIFD84mRC6+ABYNUBf6EdrPwZESr82LI0gLKVbuIG+H6FgZtATgYgUXgnICFA= ARC-Authentication-Results: i=1; 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=YQTrd6DD; arc=none 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="YQTrd6DD" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL1xx5U021821; Fri, 21 Nov 2025 09:53:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=/j0Bb GUY91yblx/1ZicbT4wGKsgAXWlYfC2RMzCuA3w=; b=YQTrd6DD11tnk2EZh7ndU 2ETVFQteZN9RTG9g4ulE0qc2MuYpkTll3qis8s17RKa5qHskHYV55t7W/dDM95+5 aP6fy1/Vh86iC7pglzsvKPIH9ZqVYTGf2Wq6JQtQjUMNa0NBm4nB1JMnnLdz0N+K SyhuZg7Mnh1G6Nm8e+Z5LrfF8ZrgpbWvvv2255Sh4xyXmtCvEut45j0gN4m0Gqyy blV7xcQOuALMVKpALuQCoV6Fp+w9x3zF8gQjGNcXGBKTakSb6OCinWeAXjMWBlcl z5zP7ZlaI/141RbL8yGWSIxw8Y7bnnlxJXP+ElqwpKuYR3Kb8wR0ENRXPnSkP7tQ Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aejd1jtqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:53:47 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL8E1qF005173; Fri, 21 Nov 2025 09:53:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyd4uce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:53:46 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AL9rgU8021648; Fri, 21 Nov 2025 09:53:46 GMT Received: from laptop-dell-latitude7430.nl.oracle.com (dhcp-10-154-175-150.vpn.oracle.com [10.154.175.150]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4aefyd4ub2-3; Fri, 21 Nov 2025 09:53:46 +0000 From: Alexandre Chartre To: linux-kernel@vger.kernel.org, mingo@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, david.laight.linux@gmail.com Cc: alexandre.chartre@oracle.com Subject: [PATCH v6 02/30] objtool: Create disassembly context Date: Fri, 21 Nov 2025 10:53:12 +0100 Message-ID: <20251121095340.464045-3-alexandre.chartre@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251121095340.464045-1-alexandre.chartre@oracle.com> References: <20251121095340.464045-1-alexandre.chartre@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-21_03,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511210075 X-Proofpoint-GUID: 3MywW0cABc4bvchTWeW6FQE3nXYjQKS3 X-Authority-Analysis: v=2.4 cv=Z/jh3XRA c=1 sm=1 tr=0 ts=692036ab cx=c_pps a=XiAAW1AwiKB2Y8Wsi+sD2Q==:117 a=XiAAW1AwiKB2Y8Wsi+sD2Q==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=-R_vEHidSSj7PnaEDHgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMSBTYWx0ZWRfX7u/RodOvI7fR Q+XvgVQlWiihiNIH/gcOJdsOSAn2k7t5914GIc/OuZJ2bV6TXVUgUxf9wQDGW41OBrirs2MsHMR 2KRBhgpnWr2Wmsv16hAIXuq5PYF5f6P/7ok44lsT0w1RfOPx+wmW1rQPxj0aE/w/dmh9fQ9Jb/3 4nbMmCcwPeFBGGZzPBHDhanGtRLciwCYYi/oUWiIxYOdOrVgFJVsLFm3OHsv/lZ+DCI7jmX3iTI +MqoLzGvWhViSMR8RIoIPZKv5zK7XVRzmlEHA8irL2F5gn0SmK0aNYTuOF4Y0f2Z3IwTx+PXoOG lXhT1O7PqcBOwCW8o/2N65dXLrCWEz7z7VZ13e+5WZpB7Q9IXWdhOVRJBb3rKIzkM/ybg6lV61h w/rJYdn8NLq3po6pdVk6vuhUWdhBjw== X-Proofpoint-ORIG-GUID: 3MywW0cABc4bvchTWeW6FQE3nXYjQKS3 Content-Type: text/plain; charset="utf-8" Create a structure to store information for disassembling functions. For now, it is just a wrapper around an objtool file. Signed-off-by: Alexandre Chartre --- tools/objtool/check.c | 6 ++++- tools/objtool/disas.c | 32 +++++++++++++++++++++++-- tools/objtool/include/objtool/disas.h | 14 +++++++++++ tools/objtool/include/objtool/objtool.h | 2 -- 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 tools/objtool/include/objtool/disas.h diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6a5b06052dd22..5083e47eef08d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -4854,6 +4855,7 @@ static void free_insns(struct objtool_file *file) =20 int check(struct objtool_file *file) { + struct disas_context *disas_ctx; int ret =3D 0, warnings =3D 0; =20 arch_initial_func_cfi_state(&initial_func_cfi); @@ -4997,7 +4999,9 @@ int check(struct objtool_file *file) if (opts.verbose) { if (opts.werror && warnings) WARN("%d warning(s) upgraded to errors", warnings); - disas_warned_funcs(file); + disas_ctx =3D disas_context_create(file); + disas_warned_funcs(disas_ctx); + disas_context_destroy(disas_ctx); } =20 if (opts.backup && make_backup()) diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index 3a7cb1b8002ec..7a18e51d43e62 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -4,10 +4,35 @@ */ =20 #include +#include #include =20 #include =20 +struct disas_context { + struct objtool_file *file; +}; + +struct disas_context *disas_context_create(struct objtool_file *file) +{ + struct disas_context *dctx; + + dctx =3D malloc(sizeof(*dctx)); + if (!dctx) { + WARN("failed to allocate disassembly context"); + return NULL; + } + + dctx->file =3D file; + + return dctx; +} + +void disas_context_destroy(struct disas_context *dctx) +{ + free(dctx); +} + /* 'funcs' is a space-separated list of function names */ static void disas_funcs(const char *funcs) { @@ -58,12 +83,15 @@ static void disas_funcs(const char *funcs) } } =20 -void disas_warned_funcs(struct objtool_file *file) +void disas_warned_funcs(struct disas_context *dctx) { struct symbol *sym; char *funcs =3D NULL, *tmp; =20 - for_each_sym(file->elf, sym) { + if (!dctx) + return; + + for_each_sym(dctx->file->elf, sym) { if (sym->warned) { if (!funcs) { funcs =3D malloc(strlen(sym->name) + 1); diff --git a/tools/objtool/include/objtool/disas.h b/tools/objtool/include/= objtool/disas.h new file mode 100644 index 0000000000000..5c543b69fc612 --- /dev/null +++ b/tools/objtool/include/objtool/disas.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. + */ + +#ifndef _DISAS_H +#define _DISAS_H + +struct disas_context; +struct disas_context *disas_context_create(struct objtool_file *file); +void disas_context_destroy(struct disas_context *dctx); +void disas_warned_funcs(struct disas_context *dctx); + +#endif /* _DISAS_H */ diff --git a/tools/objtool/include/objtool/objtool.h b/tools/objtool/includ= e/objtool/objtool.h index 35f926cf9c254..f7051bbe0bcb2 100644 --- a/tools/objtool/include/objtool/objtool.h +++ b/tools/objtool/include/objtool/objtool.h @@ -49,6 +49,4 @@ int check(struct objtool_file *file); int orc_dump(const char *objname); int orc_create(struct objtool_file *file); =20 -void disas_warned_funcs(struct objtool_file *file); - #endif /* _OBJTOOL_H */ --=20 2.43.5