diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 84dcc90..3e71609 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -3056,18 +3056,26 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf) memcpy(newdata, sym->sec->data->d_buf, sym->sec->data->d_size); sym->sec->data->d_buf = newdata; insn = newdata; - if (insn[0] != 0xf) - ERROR("%s: unexpected instruction at the start of the function", - sym->name); - insn[0] = 0xe8; - insn[1] = 0; - insn[2] = 0; - insn[3] = 0; - insn[4] = 0; rela = list_first_entry(&sym->sec->rela->relas, struct rela, list); - rela->type = R_X86_64_PC32; + + /* + * R_X86_64_NONE is only generated by older versions of kernel/gcc + * which use the mcount script. + */ + if (rela->type == R_X86_64_NONE) { + if (insn[0] != 0xf) + ERROR("%s: unexpected instruction at the start of the function", + sym->name); + insn[0] = 0xe8; + insn[1] = 0; + insn[2] = 0; + insn[3] = 0; + insn[4] = 0; + + rela->type = R_X86_64_PC32; + } index++; } diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c index fcb7161..4f08128 100644 --- a/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c @@ -332,7 +332,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf) #else rela = list_first_entry(&sym->sec->rela->relas, struct rela, list); - if (rela->type != R_X86_64_NONE || + if ((rela->type != R_X86_64_NONE && rela->type != R_X86_64_PC32) || strcmp(rela->sym->name, "__fentry__")) continue;