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

Josh Poimboeuf
2024-09-07T20:14:47Z

On Sat, Sep 07, 2024 at 10:43:10AM -0700, Song Liu wrote:
> clang gives the following:
>
> elf.c:102:1: error: unused function '__sym_remove' [-Werror,-Wunused-function]
> 102 | INTERVAL_TREE_DEFINE(struct symbol, node, unsigned long, __subtree_last,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 103 | __sym_start, __sym_last, static inline, __sym)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /data/users/songliubraving/kernel/linux-git/tools/include/linux/interval_tree_generic.h:65:15:
> note: expanded from macro 'INTERVAL_TREE_DEFINE'
> 65 | ITSTATIC void ITPREFIX ## _remove(ITSTRUCT *node,
> \
> | ^~~~~~~~~~~~~~~~~~~
> <scratch space>:155:1: note: expanded from here
> 155 | __sym_remove
> | ^~~~~~~~~~~~
> 1 error generated.

Here's how __sym_remove() is created:

#define INTERVAL_TREE_DEFINE(ITSTRUCT, ITRB, ITTYPE, ITSUBTREE, \
ITSTART, ITLAST, ITSTATIC, ITPREFIX) \
...

ITSTATIC void ITPREFIX ## _remove(ITSTRUCT *node, \
struct rb_root_cached *root) \

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

ITSTATIC is 'static inline' so it shouldn't be complaining about it
being unused, right?

If you add -E to the cflags to get preprocessed output, can you confirm
__sym_remove() is 'static inline'?

--
Josh