Re: [PATCH] objtool: fix .cold. functions parent symbols search
From: Josh Poimboeuf
Date: Wed Nov 07 2018 - 15:29:47 EST
On Wed, Nov 07, 2018 at 07:42:46PM +0100, Artem Savkov wrote:
> On Wed, Nov 07, 2018 at 11:08:56AM -0600, Josh Poimboeuf wrote:
> > On Wed, Nov 07, 2018 at 03:05:59PM +0100, Artem Savkov wrote:
> > > The way it is currently done it is possible for read_symbols() to find the
> > > same symbol as parent for ".cold" functions.
> >
> > I seem to remember having this discussion for kpatch-build, but I forget
> > the details. Can you explain how this can happen (and also add that
> > detail to the commit message)?
>
> find_symbol_by_name() traverses the same lists as read_symbols and when
> we change sym->name in place without copying it it changes in the list
> as well. So if child function is before parent in sec->symbol_list the
> same function will be returned as "parent".
Ah, I see.
> It is hard for me to put it into words worthy to be included into
> commit message.
The above description made sense to me, so it sounds like you're on the
right path :-)
> > I haven't seen any bug reports, is it purely theoretical?
>
> No, 4.20-rc1 (actually anything after 4a60aa05a063 "objtool: Support
> per-function rodata sections", before that add_switch_table() doesn't
> seem to be called for those .cold. funcs) fails to build for mewith
> KCFLAGS="-ffunction-sections -fdata-sections" because objtool is
> segfaulting.
If you only see it triggered with -ffunction-sections, that would be
another useful nugget for the commit log.
Also, if it's fixing a regression, be sure to add the 'Fixes' tag.
Thanks!
--
Josh