From nobody Sat Jun 13 22:15:52 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 BDDD248097B; Tue, 5 May 2026 10:56:40 +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=1777978602; cv=none; b=q6Spoiia2V+eX6Od97L3djjvLCSkL8Vnlans7auZTIkc45e1V0BmQ8xInjgMPD8sGS9OyDZeuKlGJkW4gjBmrF+BCBVLDoawuYcRSLIJ8+hkFnEXQC225SzWFZbmu3imgiIatXj5E0AsCU4kFdultfdv8Mgdbs/Rc1MKVlSQ+9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978602; c=relaxed/simple; bh=MlaxzvUYPQjvuvjO3KwUH0qwhSMaj8xTnCC/my0qja0=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=S2lZGNWMHPl/B+pJrXZDeRKitTXsHpnUr1R3ppPYKThVjLjBwV/KKdpVPyq7XHRekdE8nqfccCVDdgBzEbGF5OiEPazciPWEuSgij81aaH4IO2+mVEU9mTuOiciMkOPPzc3FdbPmcsBY5Gg6fANPr7AOcR6FzzzKK8TatJUswAw= 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=NHt0ok7X; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wgn6dtNS; 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="NHt0ok7X"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wgn6dtNS" Date: Tue, 05 May 2026 10:56:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777978599; 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=GpiqpK5FT0rPtOxCKXAhq4DMbCIaH8YctdV0fsgUs6g=; b=NHt0ok7XJxgqNIbvQhQy42y82jL8pT9TlgjcLkaipfiDVh3foVNJ3CEWmSC9vlEL/0H7pa OFM924y4uFkE1Kxws+DY+A12XQTLnOWtKI6psxgcbyN5qj04qcJ7+WP2jL7Z80s+obR/dy YZk9JaVkDo7hWSxpnoVEV5YIK+zWZntjFVUsf6gTzjaHj2Cxs80ahEDZRcQDx8vORpcve4 H9pdvH4xiBQGyN7I7hZcEIvWGSXw4+IkXP6++NyH4LyHHrJdJDS/ZNgGP1YQZBq+xoYt8a qbIG8ZSqihByIyLAYB3/2eKl9wQHknXKOHt5qUAzdTjswNNFd38+jA0ars/mNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777978599; 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=GpiqpK5FT0rPtOxCKXAhq4DMbCIaH8YctdV0fsgUs6g=; b=wgn6dtNSgWqTvID+w68IPjcWIWJrw4ErlM6RIYDsN8BsaoCGYnQEBZ2B7RBnBnBHkxzWgw CkI2827MLwFBTaCg== 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: Fix extraction of text annotations for alternatives Cc: Song Liu , Miroslav Benes , 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: <177797859825.424702.4780903830860475578.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: 62a7a01fde87c99926cd7e9670b4226c4c79ebaf Gitweb: https://git.kernel.org/tip/62a7a01fde87c99926cd7e9670b4226c4= c79ebaf Author: Josh Poimboeuf AuthorDate: Fri, 03 Apr 2026 14:53:32 -07:00 Committer: Josh Poimboeuf CommitterDate: Mon, 04 May 2026 21:16:01 -07:00 objtool/klp: Fix extraction of text annotations for alternatives Objtool is failing to extract text annotations which reference .altinstr_replacement instructions: 1) Alternative replacement fake symbols are NOTYPE rather than FUNC, and they don't have sym->included set, thus they aren't recognized by should_keep_special_sym(). 2) .discard.annotate_insn gets processed before .altinstr_replacement, so the referenced (fake) symbols don't have clones yet. Fix the first issue by checking for a valid clone instead of sym->included and by accepting NOTYPE symbols when processing .discard.annotate_insn. Fix the second issue by deferring text annotation processing until after the other special sections have been cloned. Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffin= g object files") Acked-by: Song Liu Reviewed-by: Miroslav Benes Signed-off-by: Josh Poimboeuf --- tools/objtool/klp-diff.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index 17a6146..42970b3 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -1437,6 +1437,7 @@ entsize: /* Keep a special section entry if it references an included function */ static bool should_keep_special_sym(struct elf *elf, struct symbol *sym) { + bool annotate_insn =3D !strcmp(sym->sec->name, ".discard.annotate_insn"); struct reloc *reloc; =20 if (is_sec_sym(sym) || !sym->sec->rsec) @@ -1446,7 +1447,16 @@ static bool should_keep_special_sym(struct elf *elf,= struct symbol *sym) if (convert_reloc_sym(elf, reloc)) continue; =20 - if (is_func_sym(reloc->sym) && reloc->sym->included) + if (!reloc->sym->clone || is_undef_sym(reloc->sym->clone)) + continue; + + /* + * Keep special section references to cloned functions. + * In some cases annotate_insn can also reference cloned alt + * replacement fake symbols; keep those references as well. + */ + if (is_func_sym(reloc->sym) || + (annotate_insn && is_notype_sym(reloc->sym))) return true; } =20 @@ -1590,15 +1600,28 @@ static int clone_special_section(struct elfs *e, st= ruct section *patched_sec) /* Extract only the needed bits from special sections */ static int clone_special_sections(struct elfs *e) { - struct section *patched_sec; + struct section *sec, *annotate_insn =3D NULL; =20 - for_each_sec(e->patched, patched_sec) { - if (is_special_section(patched_sec)) { - if (clone_special_section(e, patched_sec)) + for_each_sec(e->patched, sec) { + if (is_special_section(sec)) { + if (!strcmp(sec->name, ".discard.annotate_insn")) { + annotate_insn =3D sec; + continue; + } + if (clone_special_section(e, sec)) return -1; } } =20 + /* + * Do .discard.annotate_insn last, it can reference other special + * sections (alt replacements) so they need to be cloned first. + */ + if (annotate_insn) { + if (clone_special_section(e, annotate_insn)) + return -1; + } + return 0; } =20