summaryrefslogtreecommitdiffstats
path: root/tools/objtool/check.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-04-18 23:27:50 +0200
committerJosh Poimboeuf <jpoimboe@kernel.org>2023-05-16 15:31:53 +0200
commitfedb724c3db5490234ddde0103811c28c2fedae0 (patch)
treeb3d61b25d2c2ba469a84f4aa2abc08270e2a42f5 /tools/objtool/check.c
parentobjtool: Include backtrace in verbose mode (diff)
downloadlinux-fedb724c3db5490234ddde0103811c28c2fedae0.tar.xz
linux-fedb724c3db5490234ddde0103811c28c2fedae0.zip
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 <mbenes@suse.cz> Link: https://lore.kernel.org/r/6e2b93d8c65eaed6c4166a358269dc0ef01f890c.1681853186.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools/objtool/check.c')
-rw-r--r--tools/objtool/check.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 71985f3a6fa6..8d1b4226608c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4507,7 +4507,8 @@ static int validate_sls(struct objtool_file *file)
static int validate_reachable_instructions(struct objtool_file *file)
{
- struct instruction *insn;
+ struct instruction *insn, *prev_insn;
+ struct symbol *call_dest;
int warnings = 0;
if (file->ignore_unreachables)
@@ -4517,6 +4518,17 @@ static int validate_reachable_instructions(struct objtool_file *file)
if (insn->visited || ignore_unreachable_insn(file, insn))
continue;
+ prev_insn = prev_insn_same_sec(file, insn);
+ if (prev_insn && prev_insn->dead_end) {
+ call_dest = 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++;
}