From eeddd805728914c9bdbea394588f31ca22dcb657 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Wed, 26 Oct 2022 14:57:37 -0700 Subject: [PATCH] Silence objtool warnings from 55d7afa4 The use of __noreturn__ in 55d7afa4adbb4ca569e9c4477a7d121f4dc0bfbd on spl_panic() caused objtool warnings on Linux when the kernel is built with CONFIG_STACK_VALIDATION=y. This patch works around that by restricting the application of __noreturn__ to builds for static analyzers. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Richard Yao Closes #14068 --- include/os/freebsd/spl/sys/debug.h | 3 +++ include/os/linux/spl/sys/debug.h | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index a5bd677b16..91e2cfe553 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -54,6 +54,9 @@ /* * Common DEBUG functionality. */ +#if defined(__COVERITY__) || defined(__clang_analyzer__) +__attribute__((__noreturn__)) +#endif extern void spl_panic(const char *file, const char *func, int line, const char *fmt, ...) __attribute__((__noreturn__)); extern void spl_dumpstack(void); diff --git a/include/os/linux/spl/sys/debug.h b/include/os/linux/spl/sys/debug.h index 8ad1998086..3c6f6d1b83 100644 --- a/include/os/linux/spl/sys/debug.h +++ b/include/os/linux/spl/sys/debug.h @@ -54,8 +54,21 @@ #define __maybe_unused __attribute__((unused)) #endif +/* + * Without this, we see warnings from objtool during normal Linux builds when + * the kernel is built with CONFIG_STACK_VALIDATION=y: + * + * warning: objtool: tsd_create() falls through to next function __list_add() + * warning: objtool: .text: unexpected end of section + * + * Until the toolchain stops doing this, we must only define this attribute on + * spl_panic() when doing static analysis. + */ +#if defined(__COVERITY__) || defined(__clang_analyzer__) +__attribute__((__noreturn__)) +#endif extern void spl_panic(const char *file, const char *func, int line, - const char *fmt, ...) __attribute__((__noreturn__)); + const char *fmt, ...); extern void spl_dumpstack(void); static inline int