kpatch/kpatch-build
chenzefeng 3bfc85732d kpatch-elf: fix the unexpected elf classes
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>
2019-05-15 14:10:47 +08:00
..
gcc-plugins gcc-plugin: Include additional header for GCC 8 2018-05-30 19:39:48 +05:30
insn
create-diff-object.c create-diff-object: fix the condition for the sections changed 2019-05-10 08:58:36 +08:00
create-klp-module.c fix memleak in the create-klp-module.c 2019-04-26 11:37:19 +08:00
create-kpatch-module.c Fix multiple sign-compare warnings 2018-04-13 16:26:06 +02:00
kpatch-build kpatch-build: find_parent_obj should search subdirs 2019-05-07 15:41:18 +08:00
kpatch-elf.c kpatch-elf: fix the unexpected elf classes 2019-05-15 14:10:47 +08:00
kpatch-elf.h create-diff-object: add symbol relations 2018-07-11 09:57:31 +02:00
kpatch-gcc kpatch-gcc: use relative path when filtering objects to ignore 2019-02-15 10:10:24 -05:00
kpatch-intermediate.h create-klp-module: get rid of redundant kpatch_relocation.offset field 2017-11-09 19:16:14 -06:00
kpatch.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
list.h
log.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
lookup.c lookup: Fix memleak in symtab_read() 2019-04-23 12:03:17 +05:30
lookup.h kpatch-build: use symbol table instead of kobject 2018-05-18 09:24:40 +02:00
Makefile ppc64le: fix gcc-plugin installation 2018-04-19 10:16:37 +02:00