1 Star 0 Fork 43

SaltyFruit / kpatch

forked from openEuler-RISC-V / kpatch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0021-create-diff-object-create-dynamic-relocs-for-changed.patch 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
HuBin95 提交于 2023-01-30 16:10 . upgrade kpatch to version 0.9.7
From 2de1633802ae3bc2c4f91e536dbba830da6ad932 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Fri, 2 Nov 2018 17:25:38 +0000
Subject: [PATCH 21/37] create-diff-object: create dynamic relocs for changed
functions in this object
Currently, we only create dynamic relocs for changed functions of
other objects, but not this object. It will cause a problem like:
original: funcA and funcB (funcA calls funcB)
patch-1: funcA-1 and funcB-1 (funcA-1 calls funcB-1)
patch-2: funcB-2 (funcA-1 should call funcB-2)
But as we don't create dynamic relocs for funcA-1, it will call
funcB-1 directly (not by jumping from funcB). So the new funcB-2
will not get called. This patch will create dynamic relocs for
all the changed functions, including changed ones in this object.
Reported-by: Xie Zhipeng <xiezhipeng1@huawei.com>
Tested-by: Zhou Chengming <zhouchengming1@huawei.com>
Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>
Signed-off-by: Li Bin <huawei.libin@huawei.com>
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
kpatch-build/create-diff-object.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index deddde9..5e216d1 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -3309,6 +3309,12 @@ static bool need_dynrela(struct kpatch_elf *kelf, struct lookup_table *table,
return false;
if (rela->sym->sec) {
+ if (rela->sym->type == STT_FUNC &&
+ rela->sym->status == CHANGED &&
+ rela->sym->sec != relasec->base &&
+ relasec->base->sym &&
+ relasec->base->sym->type == STT_FUNC)
+ return true;
/*
* Internal symbols usually don't need dynrelas, because they
* live in the patch module and can be relocated normally.
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SaltyFruit/kpatch.git
git@gitee.com:SaltyFruit/kpatch.git
SaltyFruit
kpatch
kpatch
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891