diff --git a/kmod/core/core.c b/kmod/core/core.c index 8c1bb37..e17234b 100644 --- a/kmod/core/core.c +++ b/kmod/core/core.c @@ -711,16 +711,15 @@ static int kpatch_link_object(struct kpatch_module *kpmod, goto err_unlink; list_for_each_entry(func, &object->funcs, list) { - unsigned long old_addr; /* calculate actual old location */ if (vmlinux) { - old_addr = func->old_offset; ret = kpatch_verify_symbol_match(func->name, - old_addr); + func->old_addr); if (ret) goto err_unlink; } else { + unsigned long old_addr; old_addr = kpatch_find_module_symbol(mod, func->name); if (!old_addr) { pr_err("unable to find symbol '%s' in module '%s\n", @@ -728,14 +727,14 @@ static int kpatch_link_object(struct kpatch_module *kpmod, ret = -EINVAL; goto err_unlink; } + func->old_addr = old_addr; } /* add to ftrace filter and register handler if needed */ - ret = kpatch_ftrace_add_func(old_addr); + ret = kpatch_ftrace_add_func(func->old_addr); if (ret) goto err_unlink; - func->old_addr = old_addr; } return 0; diff --git a/kmod/core/kpatch.h b/kmod/core/kpatch.h index be73593..7523227 100644 --- a/kmod/core/kpatch.h +++ b/kmod/core/kpatch.h @@ -36,7 +36,7 @@ struct kpatch_func { /* public */ unsigned long new_addr; unsigned long new_size; - unsigned long old_offset; + unsigned long old_addr; unsigned long old_size; const char *name; struct list_head list; @@ -44,7 +44,6 @@ struct kpatch_func { /* private */ struct hlist_node node; - unsigned long old_addr; enum kpatch_op op; }; diff --git a/kmod/patch/kpatch-patch-hook.c b/kmod/patch/kpatch-patch-hook.c index b957a61..b901c54 100644 --- a/kmod/patch/kpatch-patch-hook.c +++ b/kmod/patch/kpatch-patch-hook.c @@ -257,9 +257,8 @@ static int patch_make_funcs_list(struct list_head *objects) func->new_addr = p_func->new_addr; func->new_size = p_func->new_size; - /* find correct func->old_offset */ if (!strcmp("vmlinux", object->name)) - func->old_offset = p_func->old_offset; + func->old_addr = p_func->old_addr; else func->old_addr = 0x0; diff --git a/kmod/patch/kpatch-patch.h b/kmod/patch/kpatch-patch.h index 7f013e9..3ce4832 100644 --- a/kmod/patch/kpatch-patch.h +++ b/kmod/patch/kpatch-patch.h @@ -25,7 +25,7 @@ struct kpatch_patch_func { unsigned long new_addr; unsigned long new_size; - unsigned long old_offset; + unsigned long old_addr; unsigned long old_size; char *name; char *objname; diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 52d9e57..849a92e 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -1983,7 +1983,7 @@ void kpatch_create_patches_sections(struct kpatch_elf *kelf, sym->name, result.value, result.size); /* add entry in text section */ - funcs[index].old_offset = result.value; + funcs[index].old_addr = result.value; funcs[index].old_size = result.size; funcs[index].new_size = sym->sym.st_size;