20 Star 0 Fork 43

openEuler-RISC-V / kpatch

forked from src-openEuler / kpatch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0005-create-diff-object-new-static-var-should-be-included.patch 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
HuBin95 提交于 2023-01-30 16:10 . upgrade kpatch to version 0.9.7
From dbecda6959a2e0468aa75dbf647efa396a0359f7 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Tue, 25 Feb 2020 22:44:50 -0500
Subject: [PATCH 05/37] 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 | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 02a722d..c9ebb05 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -1870,6 +1870,21 @@ 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;
@@ -3985,6 +4000,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_include_debug_sections(kelf_patched);
kpatch_process_special_sections(kelf_patched, lookup);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler-risc-v/kpatch.git
git@gitee.com:openeuler-risc-v/kpatch.git
openeuler-risc-v
kpatch
kpatch
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891