From nobody Tue Dec 2 02:30:06 2025 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 44DA4363C54 for ; Wed, 19 Nov 2025 14:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763562848; cv=none; b=rTK+RTqlULE19l12dLNzRBJNIith3QatqSIKMC7bQHFFC3GoYQmAkBxS3ADe/eXCUEULI6tJ5L00ouQXRxecnl9kwDDN3BlOzy25oYrCsQyBZZghcaHgu/uSu9rxps8oWnLdAjEZ3Xuv+0iEXWBsRE/wQygq5e9QRMyxFsuN6kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763562848; c=relaxed/simple; bh=RPTX3kGz79mBxVb9u/CEo7szFCC65oiuzYR5QmRLTiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m6Yl6ap+myrQuCDjK6/1K5QD2lKXqcHO8tkzm3c5octz/DK79e73kTrAmNES2fl87sdgRTEg1O9CNMsnXrU1FrlUPpTh01frcDaLOyjuBYZPXe1BXesTgjz08jAkcnPa0A/agwsqhItDO4es4tqchEm8MIjtqmFNUUeNSU/MILY= 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=n8juzLrT; arc=none 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="n8juzLrT" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJERKdg009664; Wed, 19 Nov 2025 14:33:31 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=FQU5N WryaqfnzfgFWnDZOWxT64H75yJFRcbp9t2CNfs=; b=n8juzLrTwXW3K1jBnvna1 8VjxaiBOy2v6bcqwM1rQVPEaGHtjmvxvCRjSIfD7kzcEzJQVvcfxu8Y/R8jDIYxE rAOy3a4UqDdVG7Jm9swWcCJ/GoQQ5fW4yF5MrEZVNPI9bGCqFVFiRDJJqsSdVhAE 4scREUA34ZYgD8PVE4cm65af81ETb5pjpxt3ZI1XDlhqnv9qy0nbCVL9bm1eYosH EGHlSdR/PcbWw+XgFusHAI8FjatIvM0llUY/9BU6dCa+rnCeC2IU+6Y8MbP8WIlg 1xYEIrEiUhG0b6lDGXNUUnJXdGDqzQLl7h1rMy94UNK0OyOjTmEmL2UtnWCTxqaz g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aej8j75js-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:33:30 +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 5AJCs2Je002711; Wed, 19 Nov 2025 14:33:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyanrvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:33:29 +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 5AJEWnnk022495; Wed, 19 Nov 2025 14:33:29 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-22; Wed, 19 Nov 2025 14:33:29 +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 21/30] objtool: Print addresses with alternative instructions Date: Wed, 19 Nov 2025 15:32:38 +0100 Message-ID: <20251119143247.3944213-22-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-ORIG-GUID: dsk5i2n_XGlorfo3n3mnyWa1yJ4bwn1E X-Proofpoint-GUID: dsk5i2n_XGlorfo3n3mnyWa1yJ4bwn1E X-Authority-Analysis: v=2.4 cv=I7xohdgg c=1 sm=1 tr=0 ts=691dd53a b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=S3f6In5oQaLI2rDuRkMA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMSBTYWx0ZWRfXxpWn6raUv/rQ sJXb0C1/zrBuAJkuXdyD7pU/112yL9O0GGZF+3nEM3QwEXWzdheak9TY2QS01tF4mI4fgOTomnN ATP+6Lvfx5GCC/2cHW3Np/7nKi7O5G5RX+OBqEARaQ5TFLCCmroWJCeGa/EgYPBHwc/PSxown9N F0dO784749EeUnleGBqW2btUAZCK2VOQtJpCl7khkGWmYtkpgUGc+adKRuMpypmje3WxhMpg6rv 6cijwbmf+cia+5j05+WKKaxb4F8JnaBuMIJD8tb7qE7M15R+JrP/GZx6Ouw12Yl4f+gLo9T0LQ2 CJD1uZa0BVFnt758tZOFPbAiR+dvg7IIrhXRR+NP4DpbGBgCkTvxakSeGkBK8QwOvSDsU1VBeps BOTdOSYInG1wXtCWQVBxB7qvDNw3fQ== Content-Type: text/plain; charset="utf-8" All alternatives are disassemble side-by-side when using the --disas option. However the address of each instruction is not printed because instructions from different alternatives are not necessarily aligned. Change this behavior to print the address of each instruction. Spaces will appear between instructions from the same alternative when instructions from different alternatives do not have the same alignment. Signed-off-by: Alexandre Chartre --- tools/objtool/disas.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index ae69bef2eb37e..6083a64f6ae49 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -47,7 +47,11 @@ struct disas_alt { struct alternative *alt; /* alternative or NULL if default code */ char *name; /* name for this alternative */ int width; /* formatting width */ - char *insn[DISAS_ALT_INSN_MAX]; /* alternative instructions */ + struct { + char *str; /* instruction string */ + int offset; /* instruction offset */ + } insn[DISAS_ALT_INSN_MAX]; /* alternative instructions */ + int insn_idx; /* index of the next instruction to print */ }; =20 #define DALT_DEFAULT(dalt) (!(dalt)->alt) @@ -361,10 +365,9 @@ char *disas_result(struct disas_context *dctx) disas_print_insn(stdout, dctx, insn, depth, "\n") =20 /* - * Print a message in the instruction flow. If insn is not NULL then - * the instruction address is printed in addition of the message, - * otherwise only the message is printed. In all cases, the instruction - * itself is not printed. + * Print a message in the instruction flow. If sec is not NULL then the + * address at the section offset is printed in addition of the message, + * otherwise only the message is printed. */ static int disas_vprint(FILE *stream, struct section *sec, unsigned long o= ffset, int depth, const char *format, va_list ap) @@ -607,6 +610,7 @@ static int disas_alt_init(struct disas_alt *dalt, { dalt->orig_insn =3D orig_insn; dalt->alt =3D alt; + dalt->insn_idx =3D 0; dalt->name =3D alt ? disas_alt_name(alt) : strdup("DEFAULT"); if (!dalt->name) return -1; @@ -615,7 +619,8 @@ static int disas_alt_init(struct disas_alt *dalt, return 0; } =20 -static int disas_alt_add_insn(struct disas_alt *dalt, int index, char *ins= n_str) +static int disas_alt_add_insn(struct disas_alt *dalt, int index, char *ins= n_str, + int offset) { int len; =20 @@ -626,7 +631,8 @@ static int disas_alt_add_insn(struct disas_alt *dalt, i= nt index, char *insn_str) } =20 len =3D strlen(insn_str); - dalt->insn[index] =3D insn_str; + dalt->insn[index].str =3D insn_str; + dalt->insn[index].offset =3D offset; if (len > dalt->width) dalt->width =3D len; =20 @@ -641,12 +647,14 @@ static int disas_alt_group(struct disas_context *dctx= , struct disas_alt *dalt) { struct objtool_file *file; struct instruction *insn; + int offset; char *str; int count; int err; =20 file =3D dctx->file; count =3D 0; + offset =3D 0; =20 alt_for_each_insn(file, DALT_GROUP(dalt), insn) { =20 @@ -655,9 +663,10 @@ static int disas_alt_group(struct disas_context *dctx,= struct disas_alt *dalt) if (!str) return -1; =20 - err =3D disas_alt_add_insn(dalt, count, str); + err =3D disas_alt_add_insn(dalt, count, str, offset); if (err) break; + offset +=3D insn->len; count++; } =20 @@ -685,7 +694,7 @@ static int disas_alt_default(struct disas_context *dctx= , struct disas_alt *dalt) str =3D strdup(disas_result(dctx)); if (!str) return -1; - err =3D disas_alt_add_insn(dalt, 0, str); + err =3D disas_alt_add_insn(dalt, 0, str, 0); if (err) return -1; =20 @@ -710,9 +719,11 @@ static void disas_alt_print_compact(char *alt_name, st= ruct disas_alt *dalts, for (i =3D 0; i < alt_count; i++) { printf("%*s=3D %s\n", len, "", dalts[i].name); for (j =3D 0; j < insn_count; j++) { - if (!dalts[i].insn[j]) + if (!dalts[i].insn[j].str) break; - printf("%*s| %s\n", len, "", dalts[i].insn[j]); + disas_print(stdout, orig_insn->sec, + orig_insn->offset + dalts[i].insn[j].offset, 0, + "| %s\n", dalts[i].insn[j].str); } printf("%*s|\n", len, ""); } @@ -811,7 +822,7 @@ static void *disas_alt(struct disas_context *dctx, for (i =3D 0; i < alt_count; i++) { free(dalts[i].name); for (j =3D 0; j < insn_count; j++) - free(dalts[i].insn[j]); + free(dalts[i].insn[j].str); } =20 free(alt_name); --=20 2.43.5