On Wed, Aug 5, 2026 at 10:11 PM Josh Poimboeuf <[email protected]> wrote:
>
> On Wed, Aug 05, 2026 at 01:36:26PM -0700, Song Liu wrote:
> > On Wed, Aug 5, 2026 at 7:30 AM Josh Poimboeuf <[email protected]> wrote:
> > >
> > [...]
> > >
> > > diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
> > > index 492d7a012cffe..11e8f3ddbb0e6 100644
> > > --- a/tools/objtool/klp-diff.c
> > > +++ b/tools/objtool/klp-diff.c
> > > @@ -1627,6 +1627,7 @@ static int create_fake_symbols(struct elf *elf)
> > >         for_each_reloc(sec->rsec, reloc) {
> > >                 unsigned long offset, size;
> > >                 struct reloc *next_reloc;
> > > +               bool last = true;
> > >
> > >                 if (annotype(elf, sec, reloc) != ANNOTYPE_DATA_SPECIAL)
> > >                         continue;
> > > @@ -1641,10 +1642,11 @@ static int create_fake_symbols(struct elf *elf)
> > >                                 continue;
> > >
> > >                         size = reloc_addend(next_reloc) - offset;
> > > +                       last = false;
> > >                         break;
> > >                 }
> > >
> > > -               if (!size)
> > > +               if (last)
> > >                         size = sec_size(reloc->sym->sec) - offset;
> >
> > Some comments about "last" logic here can be very helpful.
> >
> > Also, with the last flag, "size = 0;" before the for_each_reloc_continue()
> > loop can be removed.
> >
> > Other than these nitpicks:
> >
> > Acked-by: Song Liu <[email protected]>
>
> How about this on top?

Looks great! Thanks!

Song

> diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
> index 11e8f3ddbb0e6..38fae861d12c7 100644
> --- a/tools/objtool/klp-diff.c
> +++ b/tools/objtool/klp-diff.c
> @@ -1634,7 +1634,10 @@ static int create_fake_symbols(struct elf *elf)
>
>                 offset = reloc_addend(reloc);
>
> -               size = 0;
> +               /*
> +                * Find the start of the next entry so the fake symbol size 
> can
> +                * be calculated.
> +                */
>                 next_reloc = reloc;
>                 for_each_reloc_continue(sec->rsec, next_reloc) {
>                         if (annotype(elf, sec, next_reloc) != 
> ANNOTYPE_DATA_SPECIAL ||
> @@ -1646,6 +1649,10 @@ static int create_fake_symbols(struct elf *elf)
>                         break;
>                 }
>
> +               /*
> +                * If no next entry found, this is the last entry, so its size
> +                * is from the current offset to the end of the section.
> +                */
>                 if (last)
>                         size = sec_size(reloc->sym->sec) - offset;
>

Reply via email to