From 3af07fd0f178a4c6e2ae68207c3fedfd10672e65 Mon Sep 17 00:00:00 2001 From: Zhipeng Xie Date: Tue, 25 Feb 2020 22:44:50 -0500 Subject: [PATCH 03/17] create-diff-object: new static var should be included Before this patch, only global variables(no referenced) will be included by kpatch-build. But some macros put some static varibles in the object file, and no function references it, so they won't be included by kpatch-build. Because they are changed, the kpatch will report an error. This patch includes all new static variables, and this method won't cause a problem even the new static variables are in unbundled section. Signed-off-by: Zhou Chengming Signed-off-by: Zhipeng Xie --- kpatch-build/create-diff-object.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 58789f1..93570df 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -1689,6 +1689,20 @@ static void kpatch_include_force_elements(struct kpatch_elf *kelf) sym->include = 0; } +int kpatch_include_new_static_var(struct kpatch_elf *kelf) +{ + struct symbol *sym; + + list_for_each_entry(sym, &kelf->symbols, list) { + if (sym->status == NEW && + sym->bind == STB_LOCAL && + (sym->type == STT_OBJECT || (sym->type == STT_NOTYPE && sym->name[0] != '$'))) + kpatch_include_symbol(sym); + } + + return 0; +} + static int kpatch_include_new_globals(struct kpatch_elf *kelf) { struct symbol *sym; @@ -3554,6 +3568,7 @@ int main(int argc, char *argv[]) callbacks_exist = kpatch_include_callback_elements(kelf_patched); kpatch_include_force_elements(kelf_patched); new_globals_exist = kpatch_include_new_globals(kelf_patched); + kpatch_include_new_static_var(kelf_patched); kpatch_process_special_sections(kelf_patched); -- 2.18.1