kpatch/9004-create-diff-object-new-static-var-should-be-included.patch
Zhipeng Xie 428b311440 sync code to openeuler
sync latest code to openeuler

Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
2019-12-30 15:59:18 +08:00

57 lines
2.0 KiB
Diff

From fc6b9c5b1b3eb5d59186fe35cc90d3c06b07c537 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Fri, 2 Nov 2018 17:24:36 +0000
Subject: [PATCH 1004/1015] 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 <zhouchengming1@huawei.com>
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
kpatch-build/create-diff-object.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index d242d01..6e23295 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -1536,6 +1536,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->type == STT_OBJECT &&
+ sym->bind == STB_LOCAL)
+ kpatch_include_symbol(sym);
+ }
+
+ return 0;
+}
+
static int kpatch_include_new_globals(struct kpatch_elf *kelf)
{
struct symbol *sym;
@@ -3211,6 +3225,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_print_changes(kelf_patched);
kpatch_dump_kelf(kelf_patched);
--
1.7.5.4