From 724cac2e360b6c4ff46e6bd828435110816edda6 Mon Sep 17 00:00:00 2001 From: Li Bin Date: Fri, 16 Oct 2015 10:36:16 +0800 Subject: [PATCH] kpatch-build: support patching weak function Before this patch, if changed function is weak symbol, it is not be allowed to create live patch, and it will trigger the following error: /usr/local/libexec/kpatch/create-diff-object: ERROR: ***.o: kpatch_create_patches_sections: 2294: lookup_global_symbol *** And if the changed function reference the weak symbol, when loading the patch module will trigger the following error: module kpatch-***: overflow in relocation type *** val 0 insmod: can't insert 'kpatch-***.ko': invalid module format This patch fix it and add support for patching weak function. Signed-off-by: Li Bin --- kpatch-build/lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c index 39125c6..5a43dd1 100644 --- a/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c @@ -185,7 +185,7 @@ int lookup_global_symbol(struct lookup_table *table, char *name, memset(result, 0, sizeof(*result)); for_each_symbol(i, sym, table) - if (!sym->skip && sym->bind == STB_GLOBAL && + if (!sym->skip && (sym->bind == STB_GLOBAL || sym->bind == STB_WEAK) && !strcmp(sym->name, name)) { result->value = sym->value; result->size = sym->size;