Re: [PATCH v2 2/7] objtool/klp: Fix size of empty special section entries
From: Song Liu
Date: Wed Aug 05 2026 - 16:42:05 EST
On Wed, Aug 5, 2026 at 7:30 AM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> 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 <song@xxxxxxxxxx>
>
> if (create_fake_symbol(elf, reloc->sym->sec, offset, size))
> --
> 2.54.0
>