From f257de7c772c00f167770eaaeaa20f99afdf7225 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 2 Sep 2014 09:59:22 -0500 Subject: [PATCH] support for calling a new function in another object If a patch adds a new function in foo.c, and calls that function from bar.c, currently it fails with something like: kpatch_create_dynamic_rela_sections: 2115: lookup_global_symbol failed for tpe_allow_file, needed for .text.do_mmap_pgoff This (crudely) fixes the issue by assuming that if we can't find the global symbol in the original vmlinux, that it will be provided by another object in the patch module. If that assumption is incorrect, the module will fail to load due to the missing symbol dependency. A (perhaps) better way to fix this is to search for the symbol in the patched version of the vmlinux. But I think this approach is good enough, for now at least. Fixes #388. --- kpatch-build/create-diff-object.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index cacdabe..d84e52c 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -2106,11 +2106,15 @@ void kpatch_create_dynamic_rela_sections(struct kpatch_elf *kelf, */ if (lookup_is_exported_symbol(table, rela->sym->name)) continue; + + /* + * If lookup_global_symbol() fails, assume the + * symbol is defined in another object in the + * patch module. + */ if (lookup_global_symbol(table, rela->sym->name, &result)) - ERROR("lookup_global_symbol failed for %s, needed for %s\n", - rela->sym->name, - sec->base->name); + continue; } else { /* * We have a patch to a module which references