Re: [PATCH v3 5/6] x86/ftrace: Use text_poke()

From: Martin Jambor
Date: Thu Jan 23 2020 - 05:20:03 EST


Hello,

On Wed, Jan 22 2020, Josh Poimboeuf wrote:
> Global noreturns are already a pain today. There's no way for objtool
> to know whether GCC considered a function to be noreturn,

You should be able to get a good idea with -Wsuggest-attribute=noreturn:

$ cat a.c
int __attribute__((noreturn)) my_abort (void)
{
__builtin_abort ();
}

int foo (void)
{
return my_abort ();
}

int bar (int flag)
{
if (flag)
foo ();
return 4;
}

$ gcc -S -O2 -Wsuggest-attribute=noreturn a.c
a.c: In function âfooâ:
a.c:6:5: warning: function might be candidate for attribute ânoreturnâ [-Wsuggest-attribute=noreturn]
6 | int foo (void)
| ^~~

GCC 9 and newer even have -fdiagnostics-format=json if you are into that
kind of thing.

Hope this helps a little,

Martin