update patch with openeuler !19

- gensrc: we should add align while FLAGS_PUSH_SECTION flag is set
- elf: add section adderss for STT_NOTYPE type of symbol

Signed-off-by: imxcc <xingchaochao@huawei.com>
(cherry picked from commit 70651236ba10ff7178f3969445ceccecbaba5831)
This commit is contained in:
imxcc 2022-02-22 20:57:17 +08:00 committed by openeuler-sync-bot
parent be2281c2a9
commit e3d89e9bf0
3 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From 55b659c0b52a7c5f3fc493dd9c19ac76f09d0ccb Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Sat, 22 Jan 2022 16:15:50 +0800
Subject: [PATCH] elf: add section adderss for STT_NOTYPE type of symbol
Sometimes, the symbol type of the new global static variable in the
patch may be STT_NOTYPE. We should add the section adderss to st_value
for this type symbol, otherwise, the calculated adderss for this type
symbol will be wrong, which may result in the patched process coredump.
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/kpatch_elf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/kpatch_elf.c b/src/kpatch_elf.c
index 3ac56d9..5acf370 100644
--- a/src/kpatch_elf.c
+++ b/src/kpatch_elf.c
@@ -789,6 +789,7 @@ symbol_resolve(struct object_file *o,
break;
case STT_NOTYPE: // for Systemtap symbol _.stapsdt.base.kpatch
+ s->st_value += shdr[s->st_shndx].sh_addr;
break;
default:
--
2.27.0

View File

@ -0,0 +1,32 @@
From 9d601f4c697a9b2d926d92025bb43dd6ebf36033 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Tue, 18 Jan 2022 19:29:12 +0800
Subject: [PATCH] gensrc: we should add align while FLAGS_PUSH_SECTION flag is
set
In order to ensure the .kpatch.text readable and executable and
the .kpatch.data readable and writeable, we should make sure the
.kpatch.data is page-align. So we should add align while the
.kpatch.data being pushed for the first time.
Signed-off-by: Bihong Yu <yubihong@huawei.com>
---
src/kpatch_gensrc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kpatch_gensrc.c b/src/kpatch_gensrc.c
index 32c7afc..bf1832a 100644
--- a/src/kpatch_gensrc.c
+++ b/src/kpatch_gensrc.c
@@ -448,7 +448,7 @@ static void change_section(struct kp_file *fout, struct section_desc *sect, int
s = ".kpatch.text,\"ax\",@progbits";
else {
s = ".kpatch.data,\"aw\",@progbits";
- if (!init_data_section && !(flags & FLAG_PUSH_SECTION)) {
+ if (!init_data_section && (flags & FLAG_PUSH_SECTION)) {
init_data_section = 1;
align = ".p2align\t12";
}
--
2.27.0

View File

@ -3,13 +3,15 @@
Version: 1.0.0 Version: 1.0.0
Name: libcareplus Name: libcareplus
Summary: LibcarePlus tools Summary: LibcarePlus tools
Release: 1 Release: 2
Group: Applications/System Group: Applications/System
License: GPLv2 License: GPLv2
Url: https://gitee.com/openeuler/libcareplus Url: https://gitee.com/openeuler/libcareplus
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
Patch0001: fix-cblock-parse-for-LCOLD-LHOT-.cold.NUM-.init_arra.patch Patch0001: fix-cblock-parse-for-LCOLD-LHOT-.cold.NUM-.init_arra.patch
Patch0002: gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch
Patch0003: elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch
BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd
@ -167,6 +169,10 @@ exit 0
%endif %endif
%changelog %changelog
* Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.2
- gensrc: we should add align while FLAGS_PUSH_SECTION flag is set
- elf: add section adderss for STT_NOTYPE type of symbol
* Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.1 * Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.1
- fix cblock parse for LCOLD/LHOT/.cold.NUM, .init_array and support gnu_unique_object - fix cblock parse for LCOLD/LHOT/.cold.NUM, .init_array and support gnu_unique_object