mirror of https://github.com/dynup/kpatch
consolidate variables func->old_offset and func->old_addr to just old_addr
To reduce redundancy, remove/change the old_offset fields in the kpatch_func and kpatch_patch_func structs to just old_addr. Since old_offset is being used as a placeholder for old_addr, might as well consolidate it to just one variable.
This commit is contained in:
parent
8464c25d95
commit
6a69f5f91a
|
@ -711,16 +711,15 @@ static int kpatch_link_object(struct kpatch_module *kpmod,
|
||||||
goto err_unlink;
|
goto err_unlink;
|
||||||
|
|
||||||
list_for_each_entry(func, &object->funcs, list) {
|
list_for_each_entry(func, &object->funcs, list) {
|
||||||
unsigned long old_addr;
|
|
||||||
|
|
||||||
/* calculate actual old location */
|
/* calculate actual old location */
|
||||||
if (vmlinux) {
|
if (vmlinux) {
|
||||||
old_addr = func->old_offset;
|
|
||||||
ret = kpatch_verify_symbol_match(func->name,
|
ret = kpatch_verify_symbol_match(func->name,
|
||||||
old_addr);
|
func->old_addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_unlink;
|
goto err_unlink;
|
||||||
} else {
|
} else {
|
||||||
|
unsigned long old_addr;
|
||||||
old_addr = kpatch_find_module_symbol(mod, func->name);
|
old_addr = kpatch_find_module_symbol(mod, func->name);
|
||||||
if (!old_addr) {
|
if (!old_addr) {
|
||||||
pr_err("unable to find symbol '%s' in module '%s\n",
|
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;
|
ret = -EINVAL;
|
||||||
goto err_unlink;
|
goto err_unlink;
|
||||||
}
|
}
|
||||||
|
func->old_addr = old_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add to ftrace filter and register handler if needed */
|
/* 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)
|
if (ret)
|
||||||
goto err_unlink;
|
goto err_unlink;
|
||||||
|
|
||||||
func->old_addr = old_addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct kpatch_func {
|
||||||
/* public */
|
/* public */
|
||||||
unsigned long new_addr;
|
unsigned long new_addr;
|
||||||
unsigned long new_size;
|
unsigned long new_size;
|
||||||
unsigned long old_offset;
|
unsigned long old_addr;
|
||||||
unsigned long old_size;
|
unsigned long old_size;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
@ -44,7 +44,6 @@ struct kpatch_func {
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
struct hlist_node node;
|
struct hlist_node node;
|
||||||
unsigned long old_addr;
|
|
||||||
enum kpatch_op op;
|
enum kpatch_op op;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -257,9 +257,8 @@ static int patch_make_funcs_list(struct list_head *objects)
|
||||||
func->new_addr = p_func->new_addr;
|
func->new_addr = p_func->new_addr;
|
||||||
func->new_size = p_func->new_size;
|
func->new_size = p_func->new_size;
|
||||||
|
|
||||||
/* find correct func->old_offset */
|
|
||||||
if (!strcmp("vmlinux", object->name))
|
if (!strcmp("vmlinux", object->name))
|
||||||
func->old_offset = p_func->old_offset;
|
func->old_addr = p_func->old_addr;
|
||||||
else
|
else
|
||||||
func->old_addr = 0x0;
|
func->old_addr = 0x0;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
struct kpatch_patch_func {
|
struct kpatch_patch_func {
|
||||||
unsigned long new_addr;
|
unsigned long new_addr;
|
||||||
unsigned long new_size;
|
unsigned long new_size;
|
||||||
unsigned long old_offset;
|
unsigned long old_addr;
|
||||||
unsigned long old_size;
|
unsigned long old_size;
|
||||||
char *name;
|
char *name;
|
||||||
char *objname;
|
char *objname;
|
||||||
|
|
|
@ -1983,7 +1983,7 @@ void kpatch_create_patches_sections(struct kpatch_elf *kelf,
|
||||||
sym->name, result.value, result.size);
|
sym->name, result.value, result.size);
|
||||||
|
|
||||||
/* add entry in text section */
|
/* 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].old_size = result.size;
|
||||||
funcs[index].new_size = sym->sym.st_size;
|
funcs[index].new_size = sym->sym.st_size;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue