[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251031140944.GA3022331@ax162>
Date: Fri, 31 Oct 2025 10:09:44 -0400
From: Nathan Chancellor <nathan@...nel.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>, linux-kernel@...r.kernel.org,
linux-tip-commits@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
Joe Lawrence <joe.lawrence@...hat.com>, x86@...nel.org
Subject: Re: [tip: objtool/core] objtool/klp: Add --debug option to show
cloning decisions
Hey Boris,
On Fri, Oct 31, 2025 at 12:49:19PM +0100, Borislav Petkov wrote:
> On Thu, Oct 16, 2025 at 09:52:15AM -0000, tip-bot2 for Josh Poimboeuf wrote:
> > The following commit has been merged into the objtool/core branch of tip:
> >
> > Commit-ID: 7c2575a6406fb85946b05d8dcc856686d3156354
> > Gitweb: https://git.kernel.org/tip/7c2575a6406fb85946b05d8dcc856686d3156354
> > Author: Josh Poimboeuf <jpoimboe@...nel.org>
> > AuthorDate: Wed, 17 Sep 2025 09:04:00 -07:00
> > Committer: Josh Poimboeuf <jpoimboe@...nel.org>
> > CommitterDate: Tue, 14 Oct 2025 14:50:18 -07:00
> >
> > objtool/klp: Add --debug option to show cloning decisions
> >
> > Add a --debug option to klp diff which prints cloning decisions and an
> > indented dependency tree for all cloned symbols and relocations. This
> > helps visualize which symbols and relocations were included and why.
> >
> > Acked-by: Petr Mladek <pmladek@...e.com>
> > Tested-by: Joe Lawrence <joe.lawrence@...hat.com>
> > Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
> > ---
>
> ...
>
> > +#define dbg_indent(args...) \
> > + int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__; \
>
> so this compiler:
>
> Ubuntu clang version 15.0.7
>
> doesn't like this, see below. With some configs only, I've attached one.
>
> Newer clang is fine so I guess this old one which we support can't do that
> unused var squashing or so.
Correct, I fixed this in clang-17 so clang-15 and clang-16 will show
this.
https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61
> How about this fix?
Yeah, that looks good to me and matches the workaround that Peter did in
include/linux/compiler-clang.h. If cleanup is going to be used more in
objtool, it might be worth taking that approach there too like:
#ifdef __clang__
#define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))
#else
#define __cleanup(func) __attribute__((__cleanup__(func)))
#endif
> Seems to work here.
>
> ---
>
> diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
> index e88322d97573..289fbce428c5 100644
> --- a/tools/objtool/include/objtool/warn.h
> +++ b/tools/objtool/include/objtool/warn.h
> @@ -127,7 +127,7 @@ static inline void unindent(int *unused) { indent--; }
> })
>
> #define dbg_indent(args...) \
> - int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__; \
> + int __attribute__((cleanup(unindent))) __used __dummy_##__COUNTER__; \
> __dbg_indent(args); \
> indent++
>
> ---
>
> build error:
>
> ---
>
> klp-diff.c:601:2: error: unused variable '__dummy___COUNTER__' [-Werror,-Wunused-variable]
> dbg_indent("%s%s", patched_sym->name, data_too ? " [+DATA]" : "");
> ^
> /home/amd/kernel/linux/tools/objtool/include/objtool/warn.h:130:41: note: expanded from macro 'dbg_indent'
> int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__; \
> ^
> <scratch space>:132:1: note: expanded from here
> __dummy___COUNTER__
> ^
> klp-diff.c:1045:2: error: unused variable '__dummy___COUNTER__' [-Werror,-Wunused-variable]
> dbg_clone_reloc(sec, offset, patched_sym, addend, export, klp);
> ^
> klp-diff.c:1016:2: note: expanded from macro 'dbg_clone_reloc'
> dbg_indent("%s+0x%lx: %s%s0x%lx [%s%s%s%s%s%s]", \
> ^
> /home/amd/kernel/linux/tools/objtool/include/objtool/warn.h:130:41: note: expanded from macro 'dbg_indent'
> int __attribute__((cleanup(unindent))) __dummy_##__COUNTER__; \
> ^
> <scratch space>:138:1: note: expanded from here
> __dummy___COUNTER__
> ^
Cheers,
Nathan
Powered by blists - more mailing lists