From 693d5a27abc3629b64beeae190dc5e9214dee8d1 Mon Sep 17 00:00:00 2001 From: imxcc Date: Mon, 28 Feb 2022 21:45:59 +0800 Subject: [PATCH 1/4] elf/strip: adapt to new gcc version(10.3.1) This patch fix the following problems: 1. new libc so use new naming method,such as: libc.6.so -> libc.so.6; 2. destroy .rela section sh_flags INFO property; Signed-off-by: Bihong Yu Signed-off-by: imxcc (cherry picked from commit 62ba2da90ad7989b71d9ca869afa8d5bfdbf8805) --- ...trip-adapt-to-new-gcc-version-10.3.1.patch | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 elf-strip-adapt-to-new-gcc-version-10.3.1.patch diff --git a/elf-strip-adapt-to-new-gcc-version-10.3.1.patch b/elf-strip-adapt-to-new-gcc-version-10.3.1.patch new file mode 100644 index 0000000..9e18e79 --- /dev/null +++ b/elf-strip-adapt-to-new-gcc-version-10.3.1.patch @@ -0,0 +1,58 @@ +From abfc33435c25e1515e35768c9a2d684aa72dc780 Mon Sep 17 00:00:00 2001 +From: jiang-dawei15 +Date: Mon, 28 Feb 2022 15:34:11 +0800 +Subject: [PATCH 1/3] elf/strip: adapt to new gcc version(10.3.1) + +This patch fix the following problems: + 1. new libc so use new naming method,such as: libc.6.so -> libc.so.6; + 2. destroy .rela section sh_flags INFO property; + +Signed-off-by: Bihong Yu +--- + src/kpatch_elf.c | 9 +++------ + src/kpatch_strip.c | 5 +++-- + 2 files changed, 6 insertions(+), 8 deletions(-) + +diff --git a/src/kpatch_elf.c b/src/kpatch_elf.c +index 5acf370..260209a 100644 +--- a/src/kpatch_elf.c ++++ b/src/kpatch_elf.c +@@ -180,16 +180,13 @@ static int + elf_object_is_interp_exception(struct object_file *o) + { + /* libc */ +- if (!strncmp(o->name, "libc", 4) && +- !strncmp(o->name + strlen(o->name) - 3, ".so", 3)) ++ if (!strncmp(o->name, "libc.", 5)) + return 1; + /* libpthread */ +- if (!strncmp(o->name, "libpthread", 10) && +- !strncmp(o->name + strlen(o->name) - 3, ".so", 3)) ++ if (!strncmp(o->name, "libpthread.", 11)) + return 1; + /* libdl */ +- if (!strncmp(o->name, "libdl", 5) && +- !strncmp(o->name + strlen(o->name) - 3, ".so", 3)) ++ if (!strncmp(o->name, "libdl.", 6)) + return 1; + return 0; + } +diff --git a/src/kpatch_strip.c b/src/kpatch_strip.c +index 5717e5a..6420af9 100644 +--- a/src/kpatch_strip.c ++++ b/src/kpatch_strip.c +@@ -220,8 +220,9 @@ static int kpatch_strip(Elf *elfin, Elf *elfout) + } else { + kpinfo("don't need it\n"); + shout.sh_type = SHT_NOBITS; +- shout.sh_link = 0; +- shout.sh_info = 0; ++ /* destroy the .rela section sh_flags INFO property */ ++ if (!strncmp(scnname, ".rela", 5)) ++ shout.sh_flags = SHF_ALLOC; + } + if (!gelf_update_shdr(scnout, &shout)) { + kperr("Failed to do gelf_update_shdr need"); +-- +2.23.0.windows.1 + -- Gitee From 4af75c1da884ab9a0849d3690447937e5b998be8 Mon Sep 17 00:00:00 2001 From: imxcc Date: Mon, 28 Feb 2022 21:50:03 +0800 Subject: [PATCH 2/4] gitignore: ignore some tests and binary Signed-off-by: Bihong Yu Signed-off-by: imxcc (cherry picked from commit 8b312e4918658a30b32a882b6fe53ea65e716c0d) --- gitignore-ignore-some-tests-and-binary.patch | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gitignore-ignore-some-tests-and-binary.patch diff --git a/gitignore-ignore-some-tests-and-binary.patch b/gitignore-ignore-some-tests-and-binary.patch new file mode 100644 index 0000000..b636c5e --- /dev/null +++ b/gitignore-ignore-some-tests-and-binary.patch @@ -0,0 +1,26 @@ +From 04c295b9ca272dbd3525a6fa4be4869fe65d59aa Mon Sep 17 00:00:00 2001 +From: jiang-dawei15 +Date: Mon, 28 Feb 2022 15:56:54 +0800 +Subject: [PATCH 2/3] gitignore: ignore some tests and binary + +Signed-off-by: Bihong Yu +--- + .gitignore | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/.gitignore b/.gitignore +index 065f093..696dfee 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -7,4 +7,8 @@ src/libcare-cc + src/libcare-client + src/libcare-ctl + src/libcare-stresstest ++src/libcare-server ++src/libcare-dump ++src/arch.desc + tags ++tests/* +-- +2.23.0.windows.1 + -- Gitee From 708ab5f9734923d47a508d874ce90adab8ea17f4 Mon Sep 17 00:00:00 2001 From: imxcc Date: Mon, 28 Feb 2022 21:50:56 +0800 Subject: [PATCH 3/4] libcare-patch-make: adapt libcare-patch-make to meson Signed-off-by: Bihong Yu Signed-off-by: imxcc (cherry picked from commit ddb454facd88d9c8b694ce48070da9eb7303936b) --- ...ke-adapt-libcare-patch-make-to-meson.patch | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 libcare-patch-make-adapt-libcare-patch-make-to-meson.patch diff --git a/libcare-patch-make-adapt-libcare-patch-make-to-meson.patch b/libcare-patch-make-adapt-libcare-patch-make-to-meson.patch new file mode 100644 index 0000000..671ed68 --- /dev/null +++ b/libcare-patch-make-adapt-libcare-patch-make-to-meson.patch @@ -0,0 +1,82 @@ +From 7b84765925c8b08f6bb061e66aabebdc814f0168 Mon Sep 17 00:00:00 2001 +From: jiang-dawei15 +Date: Mon, 28 Feb 2022 16:27:22 +0800 +Subject: [PATCH 3/3] libcare-patch-make: adapt libcare-patch-make to meson + +Signed-off-by: Bihong Yu +--- + src/libcare-patch-make | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +diff --git a/src/libcare-patch-make b/src/libcare-patch-make +index 320ab88..ad1b566 100755 +--- a/src/libcare-patch-make ++++ b/src/libcare-patch-make +@@ -53,6 +53,10 @@ prepare_env() { + LPMAKE_PATCHED_DIR="${LPMAKE_PATCHED_DIR-$PWD/.lpmaketmp/patched}" + LPMAKE_PATCHROOT="${LPMAKE_PATCHROOT-$PWD/patchroot}" + ++ LIBCARE_CC=$CC ++ SYMBOLINK_CC=$(which cc) ++ REAL_CC=$(realpath $SYMBOLINK_CC) ++ + export LPMAKE_ORIGINAL_DIR LPMAKE_PATCHED_DIR LPMAKE_PATCHROOT + mkdir -p "$LPMAKE_ORIGINAL_DIR" "$LPMAKE_PATCHED_DIR" "$LPMAKE_PATCHROOT" + +@@ -79,6 +83,26 @@ restore_origs() { + + trap "restore_origs" 0 + ++change_qemu_ld_flags() { ++ qemu_ld_flags=$(grep "^QEMU_LDFLAGS=" config-host.mak) ++ ret=$(echo $qemu_ld_flags | grep "\-Wl,-q") ++ if [[ "$ret" == "" ]];then ++ qemu_ld_flags="${qemu_ld_flags} -Wl,-q" ++ echo "change QEMU_LDFLAGS to '${qemu_ld_flags}'" ++ sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak ++ fi ++} ++ ++replace_cc_symbolink() { ++ unlink $SYMBOLINK_CC ++ ln -s $LIBCARE_CC $SYMBOLINK_CC ++} ++ ++recover_cc_symbolink() { ++ unlink $SYMBOLINK_CC ++ ln -s $REAL_CC $SYMBOLINK_CC ++} ++ + build_objects() { + restore_origs + +@@ -93,6 +117,9 @@ build_objects() { + export KPATCH_STAGE=original + export KPCC_DBGFILTER_ARGS="" + ++ #add '-Wl,-q' to LD_FLAGS ++ change_qemu_ld_flags ++ + echo "${green}BUILDING ORIGINAL CODE${reset}" + make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1 + +@@ -237,10 +264,16 @@ main() { + + prepare_env + ++ # replace cc ++ replace_cc_symbolink ++ + if test -z "$only_update"; then + build_objects "$@" + fi + build_kpatches ++ ++ # recover cc ++ recover_cc_symbolink + } + + main "$@" +-- +2.23.0.windows.1 + -- Gitee From 67bec4a57ce6d00bde9ef7076e78946df6b60759 Mon Sep 17 00:00:00 2001 From: imxcc Date: Mon, 28 Feb 2022 21:51:41 +0800 Subject: [PATCH 4/4] Update spec with openeuler !24 Signed-off-by: imxcc (cherry picked from commit 4db303b3e59b29f89dab50d7198702308a8356d1) --- libcareplus.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libcareplus.spec b/libcareplus.spec index 7f2afcf..6552a28 100644 --- a/libcareplus.spec +++ b/libcareplus.spec @@ -3,7 +3,7 @@ Version: 1.0.0 Name: libcareplus Summary: LibcarePlus tools -Release: 3 +Release: 4 Group: Applications/System License: GPLv2 Url: https://gitee.com/openeuler/libcareplus @@ -12,6 +12,10 @@ 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 +Patch0004: elf-strip-adapt-to-new-gcc-version-10.3.1.patch +Patch0005: gitignore-ignore-some-tests-and-binary.patch +Patch0006: libcare-patch-make-adapt-libcare-patch-make-to-meson.patch + BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd @@ -143,6 +147,11 @@ exit 0 %endif %changelog +* Mon Feb 28 2022 imxcc - 1.0.0.4 +- libcare-patch-make: adapt libcare-patch-make to meson +- gitignore: ignore some tests and binary +- elf/strip: adapt to new gcc version(10.3.1) + * Tue Feb 22 2022 imxcc - 1.0.0.3 - libcareplus.spec:remove libcare.service and libcare.socket -- Gitee