From nobody Sat Jun 13 22:19:33 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4C642421EFD; Tue, 5 May 2026 10:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978564; cv=none; b=c3zEN2d7/AsHpzZP5oNT1z5FOijchYoOWshL8jGMqaaW4hgY2nuD7JD+N1NUhopbpN0KFMuBKWn9eSXjdWkOWqqI+htUWRdl4i3oHP52mCoMa2BjQ577bMKxiyT1ZxPss5kXsuareUAT35VaIRD0Od/k1+CAZ8S8SC1x/V04EJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978564; c=relaxed/simple; bh=2cFZJ1el03FYPhS1TmBRxcRWyx5QwjVPJbIhvfnL8n4=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=hySNb+gtvFnFntK/kmT2ivO60hNhvHE53QLrLkMEF/GxmQaDHeqU+9PYcuGmqE2a54aXKI1l06DzIWR/WQNBQcxfFI1HiZBjdYvH6FK1GnE25knuc6XpcPrwjZvg2wfEJQoU/VqgaEegqx2X+EbOsGKQe6hgLgEuosQYhoPUnwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Bi04prLi; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SzHo6sk+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Bi04prLi"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SzHo6sk+" Date: Tue, 05 May 2026 10:55:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777978559; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=s2O8yGak9kEIpWIGHydwKWouxbsYSrcvFV0li4p6cvY=; b=Bi04prLiaNGZKfnv8AAPDoObB7K7sNfonzbhPzM/tEgzlkURQ4rMl/178/A81TYFpsVcDa 7P4LrmWzPsPpbj/nStQhmb2zfDA2Phbi88i6sIMZbSnmlJLQP89WwqKlrelujMP8gk3UzB 4/9SCAu6n/qd9empJMZ7e3cZk+FO46xF/+6IJFDszMws3NVnh8UQ4DyFSeurnLDizZolUc Gu9sjjqInftn76HLqmGKxe0YkJ7SfdtQ0PRzfTOGBy7BJobROV45qdghCfmwuoohM+NDH/ B1NPb3VC6/7w4qUV+A1WbZxgp6j+3wJ0PgzObRSvJMEIeEnWXNzlcJrm+XE75A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777978559; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=s2O8yGak9kEIpWIGHydwKWouxbsYSrcvFV0li4p6cvY=; b=SzHo6sk+ZiqYFGoc89mjLGTEpezm23ky5x9BVw2d/Ec95m+JWDcdf2b/owLtCUaWn6GNKe cJyquE+m3wS2D+DQ== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool/klp: Add correlation debugging output Cc: Song Liu , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177797855798.424702.3968720100269589284.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: 5d6a03eeb7173179ef3c64e31806d21966a99875 Gitweb: https://git.kernel.org/tip/5d6a03eeb7173179ef3c64e31806d2196= 6a99875 Author: Josh Poimboeuf AuthorDate: Mon, 20 Apr 2026 22:58:37 -07:00 Committer: Josh Poimboeuf CommitterDate: Mon, 04 May 2026 21:16:06 -07:00 objtool/klp: Add correlation debugging output Add debugging messages to show how duplicate symbols get correlated, and split the --debug feature into --debug-correlate and --debug-clone. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/include/objtool/warn.h | 16 ++++++---- tools/objtool/klp-diff.c | 42 +++++++++++++++++++++------ tools/objtool/objtool.c | 3 +-- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/o= bjtool/warn.h index 595ee80..a9936d6 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -109,7 +109,7 @@ static inline char *offstr(struct section *sec, unsigne= d long offset) #define ERROR_FUNC(sec, offset, format, ...) __WARN_FUNC(ERROR_STR, sec, o= ffset, format, ##__VA_ARGS__) #define ERROR_INSN(insn, format, ...) ERROR_FUNC(insn->sec, insn->offset, = format, ##__VA_ARGS__) =20 -extern bool debug; +extern bool debug, debug_correlate, debug_clone; extern int indent; =20 static inline void unindent(int *unused) { indent--; } @@ -148,15 +148,21 @@ static inline void unindent(int *unused) { indent--; } (unsigned long long)checksum); \ }) =20 -#define __dbg_indent(format, ...) \ +#define dbg_correlate(args...) \ ({ \ - if (unlikely(debug)) \ + if (unlikely(debug_correlate)) \ + __dbg(args); \ +}) + +#define __dbg_clone(format, ...) \ +({ \ + if (unlikely(debug_clone)) \ __dbg("%*s" format, indent * 8, "", ##__VA_ARGS__); \ }) =20 -#define dbg_indent(args...) \ +#define dbg_clone(args...) \ int __cleanup(unindent) __dummy_##__COUNTER__; \ - __dbg_indent(args); \ + __dbg_clone(args); \ indent++ =20 #endif /* _WARN_H */ diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index a9c9932..ed3bf1c 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -33,6 +33,9 @@ struct export { char *mod, *sym; }; =20 +bool debug, debug_correlate, debug_clone; +int indent; + static const char * const klp_diff_usage[] =3D { "objtool klp diff [] ", NULL, @@ -40,7 +43,9 @@ static const char * const klp_diff_usage[] =3D { =20 static const struct option klp_diff_options[] =3D { OPT_GROUP("Options:"), - OPT_BOOLEAN('d', "debug", &debug, "enable debug output"), + OPT_BOOLEAN('d', "debug", &debug, "enable all debug output"), + OPT_BOOLEAN(0, "debug-correlate", &debug_correlate, "enable correlation d= ebug output"), + OPT_BOOLEAN(0, "debug-clone", &debug_clone, "enable cloning debug output"= ), OPT_END(), }; =20 @@ -583,6 +588,14 @@ static struct symbol *find_twin(struct elfs *e, struct= symbol *sym1) else if (csum_orig =3D=3D 1 && csum_patched =3D=3D 1) match =3D csum_last; =20 + if (!match) + return NULL; + + if (name_orig !=3D 1 || name_patched !=3D 1) + dbg_correlate("find_twin(): %s%s -> %s%s", + sym1->name, is_func_sym(sym1) ? "()" : "", + match->name, is_func_sym(match) ? "()" : ""); + return match; } =20 @@ -686,10 +699,14 @@ static struct symbol *find_twin_suffixed(struct elf *= elf, struct symbol *sym1) match =3D sym2; } =20 - if (count =3D=3D 1) - return match; + if (count !=3D 1) + return NULL; =20 - return NULL; + dbg_correlate("find_suffixed_twin(): %s%s -> %s%s", + sym1->name, is_func_sym(sym1) ? "()" : "", + match->name, is_func_sym(match) ? "()" : ""); + + return match; } =20 /* @@ -742,6 +759,10 @@ static struct symbol *find_twin_positional(struct elfs= *e, struct symbol *sym1) if (idx_orig !=3D idx_patched) return NULL; =20 + dbg_correlate("find_twin_positional(): %s%s -> %s%s", + sym1->name, is_func_sym(sym1) ? "()" : "", + match->name, is_func_sym(match) ? "()" : ""); + return match; } =20 @@ -998,7 +1019,7 @@ static struct symbol *clone_symbol(struct elfs *e, str= uct symbol *patched_sym, if (patched_sym->clone) return patched_sym->clone; =20 - dbg_indent("%s%s", patched_sym->name, data_too ? " [+DATA]" : ""); + dbg_clone("%s%s", patched_sym->name, data_too ? " [+DATA]" : ""); =20 /* Make sure the prefix gets cloned first */ if (is_func_sym(patched_sym) && data_too) { @@ -1375,7 +1396,7 @@ static int clone_reloc_klp(struct elfs *e, struct rel= oc *patched_reloc, =20 klp_sym =3D find_symbol_by_name(e->out, sym_name); if (!klp_sym) { - __dbg_indent("%s", sym_name); + __dbg_clone("%s", sym_name); =20 /* STB_WEAK: avoid modpost undefined symbol warnings */ klp_sym =3D elf_create_symbol(e->out, sym_name, NULL, @@ -1426,7 +1447,7 @@ static int clone_reloc_klp(struct elfs *e, struct rel= oc *patched_reloc, } =20 #define dbg_clone_reloc(sec, offset, patched_sym, addend, export, klp) \ - dbg_indent("%s+0x%lx: %s%s0x%lx [%s%s%s%s%s%s]", \ + dbg_clone("%s+0x%lx: %s%s0x%lx [%s%s%s%s%s%s]", \ sec->name, offset, patched_sym->name, \ addend >=3D 0 ? "+" : "-", labs(addend), \ sym_type(patched_sym), \ @@ -1481,7 +1502,7 @@ static int clone_reloc(struct elfs *e, struct reloc *= patched_reloc, if (is_string_sec(patched_sym->sec)) { const char *str =3D patched_sym->sec->data->d_buf + addend; =20 - __dbg_indent("\"%s\"", escape_str(str)); + __dbg_clone("\"%s\"", escape_str(str)); =20 addend =3D elf_add_string(e->out, out_sym->sec, str); if (addend =3D=3D -1) @@ -2121,6 +2142,11 @@ int cmd_klp_diff(int argc, const char **argv) if (argc !=3D 3) usage_with_options(klp_diff_usage, klp_diff_options); =20 + if (debug) { + debug_correlate =3D true; + debug_clone =3D true; + } + objname =3D argv[0]; =20 e.orig =3D elf_open_read(argv[0], O_RDONLY); diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c index 1c36221..a4e139d 100644 --- a/tools/objtool/objtool.c +++ b/tools/objtool/objtool.c @@ -16,9 +16,6 @@ #include #include =20 -bool debug; -int indent; - static struct objtool_file file; =20 struct objtool_file *objtool_open_read(const char *filename)