mirror of
https://github.com/dynup/kpatch
synced 2025-03-11 05:07:53 +00:00
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:
parent
13d8267a0d
commit
19c4b52105
@ -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);
|
memcpy(newdata, sym->sec->data->d_buf, sym->sec->data->d_size);
|
||||||
sym->sec->data->d_buf = newdata;
|
sym->sec->data->d_buf = newdata;
|
||||||
insn = 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,
|
rela = list_first_entry(&sym->sec->rela->relas, struct rela,
|
||||||
list);
|
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++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ static void kpatch_find_func_profiling_calls(struct kpatch_elf *kelf)
|
|||||||
#else
|
#else
|
||||||
rela = list_first_entry(&sym->sec->rela->relas, struct rela,
|
rela = list_first_entry(&sym->sec->rela->relas, struct rela,
|
||||||
list);
|
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__"))
|
strcmp(rela->sym->name, "__fentry__"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user