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

Song Liu
2024-09-07T17:43:22Z

On Fri, Sep 6, 2024 at 11:46 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> On Tue, Sep 03, 2024 at 10:32:00AM -0700, Song Liu wrote:
> > +++ w/tools/objtool/elf.c
> > @@ -468,10 +468,8 @@ static void elf_add_symbol(struct elf *elf,
> > struct symbol *sym)
> > *
> > * TODO: is this still true?
> > */
> > -#if 0
> > - if (sym->type == STT_NOTYPE && !sym->len)
> > + if (sym->type == STT_NOTYPE && !sym->len && false)
> > __sym_remove(sym, &sym->sec->symbol_tree);
> > -#endif
>
> Song, can you explain this change? Was there a warning about
> __sym_remove() not being used? Not sure how that would be possible
> since it should be static inline:
>
> INTERVAL_TREE_DEFINE(struct symbol, node, unsigned long, __subtree_last,
> __sym_start, __sym_last, static inline, __sym)
> ^^^^^^^^^^^^^
>

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.

gcc didn't complain here.

Thanks,
Song