Re: [PATCH 11/48] objtool/klp: Fix handling of zero-length .altinstr_replacement sections

Josh Poimboeuf
2026-04-28T15:49:11Z

On Fri, Apr 24, 2026 at 02:19:52PM -0700, Song Liu wrote:
> On Wed, Apr 22, 2026 at 9:05 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > When a section is empty (e.g. only zero-length alternative
> > replacements), there are no symbols to convert a section symbol
> > reference to. Skip the reloc instead of erroring out.
> >
> > Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
>
> Acked-by: Song Liu <song@kernel.org>
>
> With a nitpick below:
>
> [...]
>
> > @@ -1293,12 +1301,15 @@ static int clone_sym_relocs(struct elfs *e, struct symbol *patched_sym)
> > !strcmp(patched_reloc->sym->sec->name, ".altinstr_aux"))
> > continue;
> >
> > - if (convert_reloc_sym(e->patched, patched_reloc)) {
> > + ret = convert_reloc_sym(e->patched, patched_reloc);
> > + if (ret < 0) {
> > ERROR_FUNC(patched_rsec->base, reloc_offset(patched_reloc),
> > "failed to convert reloc sym '%s' to its proper format",
> > patched_reloc->sym->name);
> > return -1;
> > }
> > + if (ret > 0)
> > + continue;
>
> Functions that return -1, 0, 1 are usually more confusing. Shall we add more
> comments for convert_reloc_sym()?

Indeed, thanks.

--
Josh