From nobody Tue Dec 2 02:30:07 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 A538B364051 for ; Wed, 19 Nov 2025 14:33:24 +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=1763562806; cv=none; b=KfTRXjceM/WpIXeypmg+DrRHUvgJwA2E0TM4wWdgNpJB14jcUKcC1iPGT+NV3rhEbBCKP7NTKQD1zHt7KzZdpYxWoHdJyfNRYXASixwABISWqm48iBTlQwvpHmH3LG1GCU9F0dLZ85VzbPtDjzyL3dov1hf4l0ZwQYnI6tPLYa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763562806; c=relaxed/simple; bh=95K/Q5zxLPGKMSA3WOKaRU2vl5mgeraLLgVVWwwfURk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gCu3MQLhizhyOghidb5IEWmxWV2yRHPKEIjyKLQ0fgM2qQ7jJkCHIg6mJ1ZGkokQbHiNabc9iCRidnuzbrqT8idhuazOy3Ml5qru3NEg93xEy6nCueteg94zBVporTO++tisbT/7GPEGUWpT8XAyjr35Cd9+TIJONusg+SAQUtg= 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=H47EYYyK; 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="H47EYYyK" 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 5AJEQsLC030440; Wed, 19 Nov 2025 14:32:54 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=H47EYYyKAbGWh9vz/O4sG ZIuUruhcHw+1JnEbe+IG5crGxp3g+f52JJIyfmadVKO4mCNYN1FMGc5+G+yM/VXd D8idigDdJ7qe26DC8VnKD4Q5uTqLegcGca7v8cqMc/TJngVluU/6cYp5UTp7KOoy tYJ7MTt773vYEd0Uut/qFmo1+xCbFOfJP/TkhHeP9wiMpRtT6IYEyNRl3E04PwWD 1EV5tDXgXdrqmpVfVsKvCeXgIGwasfJsv/LQN+Cp7zMRSmHWH1+DFED8RRyw3Eao bXyP5edPuXEHYwDdYtpW6WU7VJZnBPP7tlx2he4kaPG3twhNlooTxEUzr9kXKv6W Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aejd1f1uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:32:54 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJDqdZ8002406; Wed, 19 Nov 2025 14:32:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyanr8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:32:53 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AJEWnn8022495; Wed, 19 Nov 2025 14:32:53 GMT Received: from laptop-dell-latitude7430.nl.oracle.com (dhcp-10-154-160-110.vpn.oracle.com [10.154.160.110]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4aefyanr5p-3; Wed, 19 Nov 2025 14:32:52 +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 v5 02/30] objtool: Create disassembly context Date: Wed, 19 Nov 2025 15:32:19 +0100 Message-ID: <20251119143247.3944213-3-alexandre.chartre@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251119143247.3944213-1-alexandre.chartre@oracle.com> References: <20251119143247.3944213-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-19_04,2025-11-18_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511190116 X-Proofpoint-GUID: mCf1kD-bdQW2g_1tVVUxTo-rM9pdKGyb X-Authority-Analysis: v=2.4 cv=Z/jh3XRA c=1 sm=1 tr=0 ts=691dd516 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=-R_vEHidSSj7PnaEDHgA:9 a=EBa_rOYxF3VBboPlVeQ_:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMSBTYWx0ZWRfX75VhVp02XyjM T1rXJsA+4qPicoHIwrtj/XiGKc/nkMUANQri7QiXGN3XjrODijK9cMln2ctYNx90lSxkKaP44Ob fGyLrR0Nlxw/LbNxaRPgII/SvtiNxMWLjV36RdkiE25AaiP+wwJ3ZN2lgXqGjQ6tfwYPwgo+SFO XhuU4eNYbyvKgcWW/Yw6Kj7495Jpz93iOsAw36d0iiG6Df9sCPVRiFcddXIKgFwyrwilqzhpgDa +zrEi/bkTrLvpfnR6IIaGT0DM7OCPccBVY2Kj3/IRf/a9c/LfstUEX6inaDibLAr8/rZxGaW7Fv 8iQJZNkzOjqCAEmOAuu3rJCgQE9IGiEZibo2ZH62ergAnHL55nyuUMdMRpiXy4OGeUrriaOUX+2 0/OwFfK+HCrVecvUlZ6u7oquyAg89w== X-Proofpoint-ORIG-GUID: mCf1kD-bdQW2g_1tVVUxTo-rM9pdKGyb 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