From nobody Sun Feb 8 11:22:12 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEFE5C77B7D for ; Thu, 18 May 2023 11:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbjERLIh (ORCPT ); Thu, 18 May 2023 07:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbjERLIa (ORCPT ); Thu, 18 May 2023 07:08:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1381F10EA; Thu, 18 May 2023 04:08:05 -0700 (PDT) Date: Thu, 18 May 2023 11:08:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684408082; 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: in-reply-to:in-reply-to:references:references; bh=QOLKbqZ+WEyAA/7wcsnVMTanilWInv/gKVP1qd2MJ1c=; b=sXqCLz91X7I8seLlwJprPcBJXo+uwFO2ng5l6DsvF+DiZq9nMJIb20zqV+NI2DGhbdmH2D bpNoxhCPam01WzuviiS6oEUoHdv/YP2AfKHyRSnV1YFGI3DtwxYziRJL16r73dpYuKEeVN Oz2vSlmVnTX496tPz4k0YV/bd1DZWFC6sXG+GWC+fn62CgrCyhXrLti2FjTSXla9clQ+Bs jh/qtYh2OqIeIISnWYQOUQNRRBIFSkiX7YYlD35kfPp4/qz0dt63DgEax5/MO11p3re/qT tgoSaOJO70OThmgxw5wMLNQO2VGremDipRw3+kFMzdIAo1jQZWGpTy2dsgAr3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684408082; 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: in-reply-to:in-reply-to:references:references; bh=QOLKbqZ+WEyAA/7wcsnVMTanilWInv/gKVP1qd2MJ1c=; b=K+dWE8F0qSlzUzYPx9hMdFGPgFcYhNMIiQSLbwEqNVIiLgkjQSQLSvmCz+Th2HZZSVsBHP dSa7SSUzcPG5VaDA== 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: Detect missing __noreturn annotations Cc: Miroslav Benes , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org> References: <6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168440808219.404.11188702829106131273.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: fedb724c3db5490234ddde0103811c28c2fedae0 Gitweb: https://git.kernel.org/tip/fedb724c3db5490234ddde0103811c28c= 2fedae0 Author: Josh Poimboeuf AuthorDate: Tue, 18 Apr 2023 14:27:50 -07:00 Committer: Josh Poimboeuf CommitterDate: Tue, 16 May 2023 06:31:53 -07:00 objtool: Detect missing __noreturn annotations Most "unreachable instruction" warnings these days seem to actually be the result of a missing __noreturn annotation. Add an explicit check for that. Reviewed-by: Miroslav Benes Link: https://lore.kernel.org/r/6e2b93d8c65eaed6c4166a358269dc0ef01f890c.16= 81853186.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 6 ++++++ tools/objtool/check.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index 9ec8cbf..f9345e0 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -303,6 +303,12 @@ the objtool maintainers. If it's not actually in a callable function (e.g. kernel entry code), change ENDPROC to END. =20 +3. file.o: warning: objtool: foo+0x48c: bar() is missing a __noreturn anno= tation + + The call from foo() to bar() doesn't return, but bar() is missing the + __noreturn annotation. NOTE: In addition to adding the __noreturn + annotation, the function name also needs to be added to + 'global_noreturns' in tools/objtool/check.c. =20 4. file.o: warning: objtool: func(): can't find starting instruction or diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 71985f3..8d1b422 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4507,7 +4507,8 @@ static int validate_sls(struct objtool_file *file) =20 static int validate_reachable_instructions(struct objtool_file *file) { - struct instruction *insn; + struct instruction *insn, *prev_insn; + struct symbol *call_dest; int warnings =3D 0; =20 if (file->ignore_unreachables) @@ -4517,6 +4518,17 @@ static int validate_reachable_instructions(struct ob= jtool_file *file) if (insn->visited || ignore_unreachable_insn(file, insn)) continue; =20 + prev_insn =3D prev_insn_same_sec(file, insn); + if (prev_insn && prev_insn->dead_end) { + call_dest =3D insn_call_dest(prev_insn); + if (call_dest) { + WARN_INSN(insn, "%s() is missing a __noreturn annotation", + call_dest->name); + warnings++; + continue; + } + } + WARN_INSN(insn, "unreachable instruction"); warnings++; }