From 2ddeccccb22dbcdc200ad5515f5776acb0523d01 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Mon, 16 Jan 2023 09:33:55 -0500 Subject: [PATCH] kpatch-elf: copy ELF e_flags from patched .o Kernel v6.2+ commit de3d098dd1fc ("powerpc/64: Add module check for ELF ABI version") now verifies the ELF header e_flags for its ABI value and refuse to load modules with complaint, "Invalid module architecture in ELF header: 21" Like other ELF header details, copy the flags from the reference ELF input file to the new ELF file to avoid module load errors. Signed-off-by: Joe Lawrence --- kpatch-build/kpatch-elf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c index c7d12ec..213ff5f 100644 --- a/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c @@ -948,6 +948,7 @@ void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile, ehout.e_machine = eh.e_machine; ehout.e_type = eh.e_type; ehout.e_version = EV_CURRENT; + ehout.e_flags = eh.e_flags; shstrtab = find_section_by_name(&kelf->sections, ".shstrtab"); if (!shstrtab)