Re: [PATCH v2 2/7] objtool/klp: Fix size of empty special section entries

Song Liu <[email protected]>
Newsgroups org.kernel.vger.live-patching,org.kernel.vger.linux-kernel
Message-ID <CAPhsuW69pBfEzN=apAzQkSgY+FJvxeukgydNZwYSrpA6+kQ42Q@mail.gmail.com>
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]>

>
>                 if (create_fake_symbol(elf, reloc->sym->sec, offset, size))
> --
> 2.54.0
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.