From e3d89e9bf0abcbc04176bff2b325c1af2040d4e1 Mon Sep 17 00:00:00 2001 From: imxcc Date: Tue, 22 Feb 2022 20:57:17 +0800 Subject: [PATCH] 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 (cherry picked from commit 70651236ba10ff7178f3969445ceccecbaba5831) --- ...adderss-for-STT_NOTYPE-type-of-symbo.patch | 30 +++++++++++++++++ ...-add-align-while-FLAGS_PUSH_SECTION-.patch | 32 +++++++++++++++++++ libcareplus.spec | 8 ++++- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch create mode 100644 gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch diff --git a/elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch b/elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch new file mode 100644 index 0000000..4b05341 --- /dev/null +++ b/elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch @@ -0,0 +1,30 @@ +From 55b659c0b52a7c5f3fc493dd9c19ac76f09d0ccb Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +--- + 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 + diff --git a/gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch b/gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch new file mode 100644 index 0000000..be5d8c0 --- /dev/null +++ b/gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch @@ -0,0 +1,32 @@ +From 9d601f4c697a9b2d926d92025bb43dd6ebf36033 Mon Sep 17 00:00:00 2001 +From: Bihong Yu +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 +--- + 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 + diff --git a/libcareplus.spec b/libcareplus.spec index eb39baf..95d5992 100644 --- a/libcareplus.spec +++ b/libcareplus.spec @@ -3,13 +3,15 @@ Version: 1.0.0 Name: libcareplus Summary: LibcarePlus tools -Release: 1 +Release: 2 Group: Applications/System License: GPLv2 Url: https://gitee.com/openeuler/libcareplus Source0: %{name}-%{version}.tar.gz 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 @@ -167,6 +169,10 @@ exit 0 %endif %changelog +* Tue Feb 22 2022 imxcc - 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 - 1.0.0.1 - fix cblock parse for LCOLD/LHOT/.cold.NUM, .init_array and support gnu_unique_object