[PATCHv7 08/13] kexec_file: Factor out routine to find a symbol in ELF

bot+bpf-ci at kernel.org bot+bpf-ci at kernel.org
Sat Mar 21 19:14:22 PDT 2026


> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c

[ ... ]

> @@ -1221,6 +1266,22 @@ int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf)
> 	return ret;
>  }
>
> +/*
> + * kexec_purgatory_find_symbol - find a symbol in the purgatory
> + * @pi:		Purgatory to search in.
> + * @name:	Name of the symbol.
> + *
> + * Return: pointer to symbol in read-only symtab on success, NULL on error.
> + */
> +static const Elf_Sym *kexec_purgatory_find_symbol(struct purgatory_info *pi,
> +						  const char *name)
> +{
> +	if (!pi->ehdr)
> +		return NULL;
> +
> +	return elf_find_symbol(pi->ehdr, name);
> +}

This adds a new wrapper kexec_purgatory_find_symbol() here, but the
original full implementation of kexec_purgatory_find_symbol() earlier
in the file was not removed:

kernel/kexec_file.c:kexec_purgatory_find_symbol() {
    ...
    ehdr = pi->ehdr;
    sechdrs = (void *)ehdr + ehdr->e_shoff;

    for (i = 0; i < ehdr->e_shnum; i++) {
        ...
    }

    return NULL;
}

Both definitions are static and live inside the same
#ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY block, so this will fail
to compile on any architecture that selects that config (x86, s390,
powerpc, riscv).

It looks like the old function body should have been replaced with
the new elf_find_symbol() wrapper, as was done in v5 of this series.
Was the deletion of the old body lost during a rebase?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/23393379437


More information about the kexec mailing list