Re: [RFC 00/31] objtool, livepatch: Livepatch module generation

From: Josh Poimboeuf
Date: Mon Sep 09 2024 - 17:19:14 EST


On Sat, Sep 07, 2024 at 10:04:25PM -0700, Song Liu wrote:
> I think gcc doesn't complain, but clang does:
>
> $ cat ttt.c
> static inline void ret(void)
> {
> return;
> }
>
> int main(void)
> {
> return 0;
> }

Ah... That's probably why the kernel adds "__maybe_unused" to its
inline macro (which the tools don't have).

Does this fix?

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index d1740a724eb2..74fec9f97339 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -100,7 +100,7 @@ static inline unsigned long __sym_last(struct symbol *s)
}

INTERVAL_TREE_DEFINE(struct symbol, node, unsigned long, __subtree_last,
- __sym_start, __sym_last, static inline,
+ __sym_start, __sym_last, static inline __maybe_unused,
__sym)

#define __sym_for_each(_iter, _tree, _start, _end) \