1 Star 0 Fork 44

沈仲伟/kpatch

forked from src-openEuler/kpatch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0003-create-diff-object-support-kpatch_line_macro_change_.patch 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
HuBin95 提交于 2024-03-02 00:18 . kpatch: upgrade to 0.9.9
From c04bfe41ccf06cafac28f4037380131441044556 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Sun, 14 Nov 2021 17:26:59 +0800
Subject: [PATCH 03/38] create-diff-object:support
kpatch_line_macro_change_only on aarch64
implement kpatch_line_macro_change_only on aarch64
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 4a5a180..f854eca 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -691,6 +691,17 @@ static bool insn_is_load_immediate(struct kpatch_elf *kelf, void *addr)
break;
+ case ARM64:
+ /*
+ * aarch64 immediate move insns is Little-Endian:
+ *
+ * 52 80 00 41 mov w1, #0x2
+ */
+ if ((insn[3] & 0x7f) == 0x52 && (insn[2] & 0x80) == 0x80)
+ return true;
+
+ break;
+
case S390:
/* arg2: lghi %r3, imm */
if (insn[0] == 0xa7 && insn[1] == 0x39)
@@ -742,6 +753,7 @@ static bool kpatch_line_macro_change_only(struct kpatch_elf *kelf,
void *data1, *data2, *insn1, *insn2;
struct rela *r, *rela;
bool found, found_any = false;
+ unsigned int mov_imm_mask = ((1<<16) - 1)<<5;
if (sec->status != CHANGED ||
is_rela_section(sec) ||
@@ -787,6 +799,10 @@ static bool kpatch_line_macro_change_only(struct kpatch_elf *kelf,
!insn_is_load_immediate(kelf, insn2))
return false;
+ if ((*(int *)(insn1) & ~mov_imm_mask) !=
+ (*(int *)(insn2) & ~mov_imm_mask))
+ return false;
+
found = false;
list_for_each_entry(r, &sec->rela->relas, list) {
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhong-wei-shen/kpatch.git
git@gitee.com:zhong-wei-shen/kpatch.git
zhong-wei-shen
kpatch
kpatch
master

搜索帮助