create-diff-object: -mcount-record support

4.18 adds -mcount-record to KBUILD_FLAGS when supported by the compiler.
This results in most of kpatch_create_mcount_sections()'s work being
already done, so we can at least skip the last part of it that updates
the first instruction in patched functions.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
Artem Savkov 2018-07-26 11:43:57 +02:00
parent 13d8267a0d
commit 19c4b52105
2 changed files with 18 additions and 10 deletions

View File

@ -3056,6 +3056,15 @@ 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;
rela = list_first_entry(&sym->sec->rela->relas, struct rela,
list);
/*
* 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);
@ -3065,9 +3074,8 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
insn[3] = 0;
insn[4] = 0;
rela = list_first_entry(&sym->sec->rela->relas, struct rela,
list);
rela->type = R_X86_64_PC32;
}
index++;
}

View File

@ -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;