[PATCH 03/13] objtool: Improve __noreturn annotation warning

Josh Poimboeuf posted 13 patches 11 months ago
[PATCH 03/13] objtool: Improve __noreturn annotation warning
Posted by Josh Poimboeuf 11 months ago
Clarify what needs to be done to resolve the missing __noreturn warning.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/Documentation/objtool.txt | 12 +++++-------
 tools/objtool/check.c                   |  2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index 7c3ee959b63c..87950a7aaa17 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -319,14 +319,12 @@ the objtool maintainers.
    a just a bad person, you can tell objtool to ignore it.  See the
    "Adding exceptions" section below.
 
-   If it's not actually in a callable function (e.g. kernel entry code),
-   change ENDPROC to END.
+3. file.o: warning: objtool: foo+0x48c: bar() missing __noreturn in .c/.h or NORETURN() in noreturns.h
 
-3. file.o: warning: objtool: foo+0x48c: bar() is missing a __noreturn annotation
-
-   The call from foo() to bar() doesn't return, but bar() is missing the
-   __noreturn annotation.  NOTE: In addition to annotating the function
-   with __noreturn, please also add it to tools/objtool/noreturns.h.
+   The call from foo() to bar() doesn't return, but bar() is incorrectly
+   annotated.  A noreturn function must be marked __noreturn in both its
+   declaration and its definition, and must have a NORETURN() annotation
+   in tools/objtool/noreturns.h.
 
 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 2b5249af7b0f..6b9ad3afe389 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4458,7 +4458,7 @@ static int validate_reachable_instructions(struct objtool_file *file)
 		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",
+				WARN_INSN(insn, "%s() missing __noreturn in .c/.h or NORETURN() in noreturns.h",
 					  call_dest->name);
 				warnings++;
 				continue;
-- 
2.48.1
Re: [PATCH 03/13] objtool: Improve __noreturn annotation warning
Posted by Brendan Jackman 10 months, 4 weeks ago
On Fri, Mar 14, 2025 at 12:29:01PM -0700, Josh Poimboeuf wrote:
> Clarify what needs to be done to resolve the missing __noreturn warning.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  tools/objtool/Documentation/objtool.txt | 12 +++++-------
>  tools/objtool/check.c                   |  2 +-
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
> index 7c3ee959b63c..87950a7aaa17 100644
> --- a/tools/objtool/Documentation/objtool.txt
> +++ b/tools/objtool/Documentation/objtool.txt
> @@ -319,14 +319,12 @@ the objtool maintainers.
>     a just a bad person, you can tell objtool to ignore it.  See the
>     "Adding exceptions" section below.
>  
> -   If it's not actually in a callable function (e.g. kernel entry code),
> -   change ENDPROC to END.

Did you mean to delete that?
Re: [PATCH 03/13] objtool: Improve __noreturn annotation warning
Posted by Miroslav Benes 10 months, 4 weeks ago
On Mon, 17 Mar 2025, Brendan Jackman wrote:

> On Fri, Mar 14, 2025 at 12:29:01PM -0700, Josh Poimboeuf wrote:
> > Clarify what needs to be done to resolve the missing __noreturn warning.
> > 
> > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> > ---
> >  tools/objtool/Documentation/objtool.txt | 12 +++++-------
> >  tools/objtool/check.c                   |  2 +-
> >  2 files changed, 6 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
> > index 7c3ee959b63c..87950a7aaa17 100644
> > --- a/tools/objtool/Documentation/objtool.txt
> > +++ b/tools/objtool/Documentation/objtool.txt
> > @@ -319,14 +319,12 @@ the objtool maintainers.
> >     a just a bad person, you can tell objtool to ignore it.  See the
> >     "Adding exceptions" section below.
> >  
> > -   If it's not actually in a callable function (e.g. kernel entry code),
> > -   change ENDPROC to END.
> 
> Did you mean to delete that?
 
I would say so but it should go to the next patch 4/13 alongside the other 
doc updates.

Miroslav