mirror of
https://github.com/dynup/kpatch
synced 2024-12-21 20:59:57 +00:00
3bfc85732d
kpatch-elf::kpatch_write_output_elf will call the gelf_getclass() to acquire the output elf's class. But the input parameter kelf->elf is NULL, the gelf_getclass(kelf->elf) will return ELFCLASSNONE, not the value we expect ELFCLASS32 or ELFCLASS64. the gelf_getclass function code: int gelf_getclass (Elf *elf) { return elf == NULL || elf->kind != ELF_K_ELF ? ELFCLASSNONE : elf->class; } the gelf_newehdr fuction code: void * gelf_newehdr (Elf *elf, int class) { return (class == ELFCLASS32 ? (void *) INTUSE(elf32_newehdr) (elf) : (void *) INTUSE(elf64_newehdr) (elf)); } Luckily, when we create a patch for x86_64 or powerpc64, if we pass the ELFCLASSNONE for the function gelf_newehdr, it will return elf64_newehdr, so don't cause the fault. But it's better to use the gelf_getclass(elf) instead of gelf_getclass(kelf->elf). Signed-off-by: chenzefeng <chenzefeng2@huawei.com> |
||
---|---|---|
.. | ||
gcc-plugins | ||
insn | ||
create-diff-object.c | ||
create-klp-module.c | ||
create-kpatch-module.c | ||
kpatch-build | ||
kpatch-elf.c | ||
kpatch-elf.h | ||
kpatch-gcc | ||
kpatch-intermediate.h | ||
kpatch.h | ||
list.h | ||
log.h | ||
lookup.c | ||
lookup.h | ||
Makefile |