From: @openeuler-sync-bot Reviewed-by: @imxcc Signed-off-by: @imxcc
This commit is contained in:
commit
57f687555d
49
kpatch_elf-compatible-with-older-versions-of-the-so-.patch
Normal file
49
kpatch_elf-compatible-with-older-versions-of-the-so-.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From b316ee94be9e6bdcda30400511593550de1eb29b Mon Sep 17 00:00:00 2001
|
||||
From: jiang-dawei15 <jiangdawei15@huawei.com>
|
||||
Date: Tue, 1 Mar 2022 16:07:37 +0800
|
||||
Subject: [PATCH 1/2] kpatch_elf: compatible with older versions of the so
|
||||
naming rules
|
||||
|
||||
New openEuler so naming rules have been changed, such as:
|
||||
old so naming rules: libc-x.y.z.so
|
||||
<----->
|
||||
new so naming rules: libc.so.x.y.z
|
||||
|
||||
We need support this two version.
|
||||
fix commit: abfc33435c25e1515e35768c9a2d684aa72dc780
|
||||
|
||||
Signed-off-by: Bihong Yu <yubihong@huawei.com>
|
||||
---
|
||||
src/kpatch_elf.c | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/kpatch_elf.c b/src/kpatch_elf.c
|
||||
index 260209a..833f8e1 100644
|
||||
--- a/src/kpatch_elf.c
|
||||
+++ b/src/kpatch_elf.c
|
||||
@@ -180,13 +180,19 @@ static int
|
||||
elf_object_is_interp_exception(struct object_file *o)
|
||||
{
|
||||
/* libc */
|
||||
- if (!strncmp(o->name, "libc.", 5))
|
||||
+ if (!strncmp(o->name, "libc.so.", 8) ||
|
||||
+ (!strncmp(o->name, "libc-", 5) &&
|
||||
+ !strncmp(o->name + strlen(o->name) - 3, ".so", 3)))
|
||||
return 1;
|
||||
/* libpthread */
|
||||
- if (!strncmp(o->name, "libpthread.", 11))
|
||||
+ if (!strncmp(o->name, "libpthread.so.", 14) ||
|
||||
+ (!strncmp(o->name, "libpthread-", 11) &&
|
||||
+ !strncmp(o->name + strlen(o->name) - 3, ".so", 3)))
|
||||
return 1;
|
||||
/* libdl */
|
||||
- if (!strncmp(o->name, "libdl.", 6))
|
||||
+ if (!strncmp(o->name, "libdl.so.", 9) ||
|
||||
+ (!strncmp(o->name, "libdl-", 6) &&
|
||||
+ !strncmp(o->name + strlen(o->name) - 3, ".so", 3)))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
123
kpatch_parse-fix-failed-to-recognize-.cold.patch
Normal file
123
kpatch_parse-fix-failed-to-recognize-.cold.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From 6ebfe7d2af327dad9c9d4c5b2733ba55bd81571c Mon Sep 17 00:00:00 2001
|
||||
From: jiang-dawei15 <jiangdawei15@huawei.com>
|
||||
Date: Tue, 1 Mar 2022 20:00:58 +0800
|
||||
Subject: [PATCH 2/2] kpatch_parse: fix failed to recognize .cold
|
||||
|
||||
the .cold suffix have two forms of expression: func.cold or
|
||||
func.cold.NUM, we need to support recognizing both patterns.
|
||||
|
||||
Signed-off-by: Bihong Yu <yubihong@huawei.com>
|
||||
---
|
||||
src/arch/x86/arch_parse.c | 4 ++--
|
||||
src/include/kpatch_parse.h | 2 +-
|
||||
src/kpatch_parse.c | 14 ++++++--------
|
||||
tests/gcc_ge8_gensrc/run_gcc_ge8_gensrc_test.sh | 11 +++++++----
|
||||
4 files changed, 16 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/arch/x86/arch_parse.c b/src/arch/x86/arch_parse.c
|
||||
index 31caa46..aee82b8 100644
|
||||
--- a/src/arch/x86/arch_parse.c
|
||||
+++ b/src/arch/x86/arch_parse.c
|
||||
@@ -72,10 +72,10 @@ void recog_func_attr(struct kp_file *f, int i, kpstr_t *nm, int *cnt)
|
||||
get_type_args(cline(f, i), &func_nm, &func_attr);
|
||||
if(!kpstrcmpz(&func_attr, "@function")) {
|
||||
if(func_nm.l > nm->l)
|
||||
- remove_cold_hot_suffix(&func_nm); /* remove .cold. / .hot. */
|
||||
+ remove_cold_suffix(&func_nm); /* remove .cold */
|
||||
|
||||
if(!kpstrcmp(&func_nm, nm)) /* verify name matches */
|
||||
- ++(*cnt);
|
||||
+ ++(*cnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/include/kpatch_parse.h b/src/include/kpatch_parse.h
|
||||
index c52a1e3..d2225c5 100644
|
||||
--- a/src/include/kpatch_parse.h
|
||||
+++ b/src/include/kpatch_parse.h
|
||||
@@ -106,7 +106,7 @@ struct cblock {
|
||||
|
||||
void get_token(char **str, kpstr_t *x);
|
||||
void __get_token(char **str, kpstr_t *x, const char *delim);
|
||||
-void remove_cold_hot_suffix(kpstr_t *nm);
|
||||
+void remove_cold_suffix(kpstr_t *nm);
|
||||
|
||||
int is_function_start(struct kp_file *f, int l, kpstr_t *nm);
|
||||
int is_function_end(struct kp_file *f, int l, kpstr_t *nm);
|
||||
diff --git a/src/kpatch_parse.c b/src/kpatch_parse.c
|
||||
index 0885cbe..43c885c 100644
|
||||
--- a/src/kpatch_parse.c
|
||||
+++ b/src/kpatch_parse.c
|
||||
@@ -78,17 +78,15 @@ void get_token(char **str, kpstr_t *x)
|
||||
__get_token(str, x, delim);
|
||||
}
|
||||
|
||||
-/* remove .cold. / .hot. in function name */
|
||||
-void remove_cold_hot_suffix(kpstr_t *nm)
|
||||
+/* remove .cold in function name */
|
||||
+void remove_cold_suffix(kpstr_t *nm)
|
||||
{
|
||||
if(!nm->s)
|
||||
return;
|
||||
-
|
||||
- char *suffix_loc = strstr(nm->s, ".cold.");
|
||||
- if(!suffix_loc)
|
||||
- suffix_loc = strstr(nm->s, ".hot.");
|
||||
+
|
||||
+ char *suffix_loc = strstr(nm->s, ".cold");
|
||||
if(suffix_loc)
|
||||
- nm->l = suffix_loc - nm->s; /* remove .cold. / .hot. */
|
||||
+ nm->l = suffix_loc - nm->s; /* remove .cold */
|
||||
}
|
||||
|
||||
/* ------------------------------ as directives parsing ---------------------------------- */
|
||||
@@ -790,7 +788,7 @@ int is_function_end(struct kp_file *f, int l, kpstr_t *nm)
|
||||
get_token(&s, &nm2);
|
||||
|
||||
if(nm2.l > nm->l)
|
||||
- remove_cold_hot_suffix(&nm2); /* remove .cold. / .hot. */
|
||||
+ remove_cold_suffix(&nm2); /* remove .cold */
|
||||
|
||||
if (kpstrcmp(nm, &nm2)) /* verify name matches */
|
||||
return 0;
|
||||
diff --git a/tests/gcc_ge8_gensrc/run_gcc_ge8_gensrc_test.sh b/tests/gcc_ge8_gensrc/run_gcc_ge8_gensrc_test.sh
|
||||
index 4534038..b508e99 100755
|
||||
--- a/tests/gcc_ge8_gensrc/run_gcc_ge8_gensrc_test.sh
|
||||
+++ b/tests/gcc_ge8_gensrc/run_gcc_ge8_gensrc_test.sh
|
||||
@@ -22,12 +22,12 @@ for SOURCE in $SOURCE_SET; do
|
||||
FILENAME=${SOURCE##*/}
|
||||
CASENAME=${FILENAME%.orig.s}
|
||||
if [ $CASENAME == "cold_func_suffix" ]; then
|
||||
- KEY_WORD="\.cold."
|
||||
+ KEY_WORD="\.cold"
|
||||
else
|
||||
KEY_WORD=$CASENAME
|
||||
fi
|
||||
|
||||
- KEY_WORD_LINE=$(grep -c $KEY_WORD $SOURCE)
|
||||
+ KEY_WORD_LINE=$(grep -c "$KEY_WORD" $SOURCE)
|
||||
if [ $KEY_WORD_LINE -lt "2" ]; then
|
||||
echo "SKIP: $CASENAME, $KEY_WORD not found"
|
||||
SKIP_CNT=$(($SKIP_CNT+1))
|
||||
@@ -37,7 +37,7 @@ for SOURCE in $SOURCE_SET; do
|
||||
$KPATCH_GENSRC --os=rhel6 -i $SOURCE -i $SOURCE -o ${SOURCE/.orig/.o}
|
||||
sed -i '/^#/d' ${SOURCE/.orig/.o}
|
||||
|
||||
- DIFF_LINE=$(diff $SOURCE ${SOURCE/.orig/.o} | grep -c $KEY_WORD)
|
||||
+ DIFF_LINE=$(diff $SOURCE ${SOURCE/.orig/.o} | grep -c "$KEY_WORD")
|
||||
if [ $DIFF_LINE -gt "0" ]; then
|
||||
echo "TEST $CASENAME IS FAIL"
|
||||
FAIL_CNT=$(($FAIL_CNT+1))
|
||||
@@ -48,4 +48,7 @@ for SOURCE in $SOURCE_SET; do
|
||||
done
|
||||
|
||||
echo "OK $OK_CNT FAIL $FAIL_CNT SKIP $SKIP_CNT TOTAL $TOTAL_CASE"
|
||||
-exit 0
|
||||
\ No newline at end of file
|
||||
+if [ $FAIL_CNT -ne 0 ]; then
|
||||
+ exit 1
|
||||
+fi
|
||||
+exit 0
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Version: 1.0.0
|
||||
Name: libcareplus
|
||||
Summary: LibcarePlus tools
|
||||
Release: 4
|
||||
Release: 5
|
||||
Group: Applications/System
|
||||
License: GPLv2
|
||||
Url: https://gitee.com/openeuler/libcareplus
|
||||
@ -15,7 +15,8 @@ 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
|
||||
|
||||
Patch0007: kpatch_elf-compatible-with-older-versions-of-the-so-.patch
|
||||
Patch0008: kpatch_parse-fix-failed-to-recognize-.cold.patch
|
||||
|
||||
BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd
|
||||
|
||||
@ -147,6 +148,10 @@ exit 0
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Mar 02 2033 imxcc <xingchaochao@huawei.com> - 1.0.0.5
|
||||
- kpatch_elf: compatible with older versions of the so naming rules
|
||||
- kpatch_parse: fix failed to recognize .cold
|
||||
|
||||
* Mon Feb 28 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.4
|
||||
- libcare-patch-make: adapt libcare-patch-make to meson
|
||||
- gitignore: ignore some tests and binary
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user