Compare commits
10 Commits
785920d783
...
94f20fc7d8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94f20fc7d8 | ||
|
|
c209c96188 | ||
|
|
862a1ba630 | ||
|
|
3279328c3e | ||
|
|
e77fa8f9a3 | ||
|
|
b755f62f05 | ||
|
|
e4460b8c17 | ||
|
|
f9026db701 | ||
|
|
9a929dde86 | ||
|
|
7b6889f0a0 |
31
0000-gensrc-skip-vector-instruction-in-str_do_gotpcrel.patch
Normal file
31
0000-gensrc-skip-vector-instruction-in-str_do_gotpcrel.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From ca5e000a30eae58e84c98fef9c511ef61ec00fbe Mon Sep 17 00:00:00 2001
|
||||
From: Chuan Zheng <zhengchuan@huawei.com>
|
||||
Date: Mon, 26 Apr 2021 14:48:34 +0800
|
||||
Subject: [PATCH] gensrc: skip vector instruction in str_do_gotpcrel
|
||||
|
||||
We might have "move (%rip) %0xmm0" in qemu hotpatch, which causes
|
||||
gensrc failure in str_do_gotpcrel.
|
||||
Fix it by skipping it because we do not need anything for vector command.
|
||||
---
|
||||
src/kpatch_gensrc.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/kpatch_gensrc.c b/src/kpatch_gensrc.c
|
||||
index a16b652..4f978f8 100644
|
||||
--- a/src/kpatch_gensrc.c
|
||||
+++ b/src/kpatch_gensrc.c
|
||||
@@ -291,6 +291,11 @@ void str_do_gotpcrel(struct kp_file *f, char *dst, char *src)
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ if (strstr(movdst.s, "%xmm") != NULL) {
|
||||
+ /* Is SSE (%xmm0, etc), bail out */
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
/* Use full 64-bit counterpart of the destination register
|
||||
* as the auxiliary register */
|
||||
get_full_reg(&movdst, auxreg);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -4,7 +4,7 @@ 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:
|
||||
The 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
|
||||
38
0012-libcare-dump-change-the-return-value.patch
Normal file
38
0012-libcare-dump-change-the-return-value.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From 037c9ac7e9d3eaa072ae1edaad2bc22e18f4333a Mon Sep 17 00:00:00 2001
|
||||
From: jiang-dawei15 <jiangdawei15@huawei.com>
|
||||
Date: Thu, 5 May 2022 10:39:47 +0800
|
||||
Subject: [PATCH] libcare-dump:change the return value
|
||||
|
||||
---
|
||||
src/libcare-dump.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libcare-dump.c b/src/libcare-dump.c
|
||||
index 8736452..b712709 100644
|
||||
--- a/src/libcare-dump.c
|
||||
+++ b/src/libcare-dump.c
|
||||
@@ -45,6 +45,7 @@ void usage()
|
||||
|
||||
int kpatch_dump_kpatch_header(const char *input_file)
|
||||
{
|
||||
+ int rv;
|
||||
int fdi = -1;
|
||||
int ret = -1;
|
||||
int elf_size;
|
||||
@@ -67,7 +68,12 @@ int kpatch_dump_kpatch_header(const char *input_file)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- ret = read(fdi, &kp, sizeof(struct kpatch_file));
|
||||
+ rv = read(fdi, &kp, sizeof(struct kpatch_file));
|
||||
+ if (rv <= 0) {
|
||||
+ printf("Read kpatch file '%s' failed.\n", input_file);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ ret = 0;
|
||||
printf("%-25s %s\n", "Patch Name:", input_file);
|
||||
printf("%-25s %s\n", "Magic:", kp.magic);
|
||||
printf("%-25s %s\n", "Patch id:", kp.id);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
459
0013-modify-pkgbuild-to-make-kpatch-for-RPM-based-packages.patch
Normal file
459
0013-modify-pkgbuild-to-make-kpatch-for-RPM-based-packages.patch
Normal file
@ -0,0 +1,459 @@
|
||||
From 0c414638168e0c1a006827daaae10c2ea4a8fc08 Mon Sep 17 00:00:00 2001
|
||||
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||
Date: Mon, 9 May 2022 16:27:09 +0800
|
||||
Subject: [PATCH] modify scripts/pkgbuild to make kpatch'es for the RPM-based
|
||||
packages
|
||||
|
||||
1.support specify patch-id, build-id and sanity check
|
||||
2.simplify script and put it into libcare devel package
|
||||
---
|
||||
scripts/example_info | 59 ++++++++++++++
|
||||
scripts/pkgbuild | 179 ++++++++++++++++++++++++-------------------
|
||||
2 files changed, 161 insertions(+), 77 deletions(-)
|
||||
create mode 100644 scripts/example_info
|
||||
|
||||
diff --git a/scripts/example_info b/scripts/example_info
|
||||
new file mode 100644
|
||||
index 0000000..d848e33
|
||||
--- /dev/null
|
||||
+++ b/scripts/example_info
|
||||
@@ -0,0 +1,59 @@
|
||||
+#!/bin/bash
|
||||
+
|
||||
+KP_PROJECT=qemu
|
||||
+KP_PROJECT_FORMAT=rpm
|
||||
+KP_PROJECT_BUILD_ROOT=/var/libcareplus/qemu/rpmbuild
|
||||
+KP_PROJECT_ORIG_RPMS=/var/libcareplus/qemu/qemu-6.2.0-29.oe2203
|
||||
+KP_PROJECT_SPEC=qemu.spec
|
||||
+
|
||||
+# we choose plist filename as patch-id, eg: 220411 here
|
||||
+KP_PROJECT_PLIST_FILE=/var/libcareplus/qemu/patch001/220506.plist
|
||||
+KP_PROJECT_DIR=$KP_PROJECT_BUILD_ROOT/BUILD/qemu-6.2.0
|
||||
+KP_PROJECT_BUILD_DIR=$KP_PROJECT_DIR/build/x86_64-softmmu
|
||||
+KP_PROJECT_BUILD_ID=61fcf129b23f05a623e0bf696a03d3348f366348
|
||||
+KP_SANITY_CHECK_STRICTLY=no
|
||||
+KP_PROJECT_SOURCE_URL=
|
||||
+KP_PROJECT_SOURCE=qemu-6.2.0-29.oe2203.src.rpm
|
||||
+KP_PROJECT_BINARY=qemu-6.2.0-29.oe2203.x86_64.rpm
|
||||
+
|
||||
+KP_PROJECT_PREBUILT=build.orig-$KP_PROJECT_BINARY.tgz
|
||||
+KP_PROJECT_PATCH=kpatch-${KP_PROJECT_BINARY%.*}.tgz
|
||||
+KP_RPMBUILD_FLAGS="'--define=dist .oe2203'"
|
||||
+#KP_RPM_REPOS="--enablerepo=base"
|
||||
+
|
||||
+
|
||||
+KP_INSTALL_FILES="
|
||||
+/qemu-system-x86_64 /usr/libexec/qemu-kvm
|
||||
+"
|
||||
+
|
||||
+KPATCH_ASM_DIR=$KP_PROJECT_BUILD_ROOT/asmdir
|
||||
+export KPATCH_ASM_DIR
|
||||
+
|
||||
+KPCC_PATCH_ARGS="--force-gotpcrel;--os=rhel6;--ignore-changes=banner,compilation"
|
||||
+export KPCC_PATCH_ARGS
|
||||
+
|
||||
+KPCC_DBGFILTER_ARGS="--dbg-filter;--dbg-filter-eh-frame;--dbg-filter-gcc-except-table;--os=rhel6"
|
||||
+export KPCC_DBGFILTER_ARGS
|
||||
+
|
||||
+kp_prebuild_hook() {
|
||||
+ if test -z "$(command -v tar)"; then
|
||||
+ echo "No tar command, Please install it first"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ if test -z "$(command -v rpmbuild)"; then
|
||||
+ echo "No rpmbuild command, Please install it first"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
+kp_build_hook() {
|
||||
+ :
|
||||
+}
|
||||
+
|
||||
+kp_prepare_test_binaries() {
|
||||
+ :
|
||||
+}
|
||||
+
|
||||
+kp_patch_test() {
|
||||
+ :
|
||||
+}
|
||||
diff --git a/scripts/pkgbuild b/scripts/pkgbuild
|
||||
index f91af57..1185cd9 100755
|
||||
--- a/scripts/pkgbuild
|
||||
+++ b/scripts/pkgbuild
|
||||
@@ -1,4 +1,8 @@
|
||||
#!/bin/bash
|
||||
+# make kpatch'es for the RPM-based packages using spec file.
|
||||
+# Each package contains the config file: info in their project directory,
|
||||
+# like /var/libcareplus/qemu/info
|
||||
+#
|
||||
|
||||
echo '+ set -x'
|
||||
set -x
|
||||
@@ -15,10 +19,10 @@ die() {
|
||||
}
|
||||
|
||||
usage() {
|
||||
- echo "Usage: build [--prebuild] [--help] [--arch ARCH] DIR"
|
||||
+ echo "Makes kpatch'es for the RPM-based packages using spec file."
|
||||
+ echo "Usage: libcare-pkgbuild [--prebuild] [--test] [--help] DIR"
|
||||
echo " -p|--prebuild prebuild project for further use"
|
||||
echo " -t|--test run unit and stress tests"
|
||||
- echo " -a|--arch ARCH target architecture(x86_64 by default)"
|
||||
echo " -h|--help print this message"
|
||||
echo " DIR directory with project's info file and other resources"
|
||||
}
|
||||
@@ -26,7 +30,6 @@ usage() {
|
||||
prepare() {
|
||||
# Parse cmdline args
|
||||
ACTION=build
|
||||
- ARCH=x86_64
|
||||
PDIR=
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
@@ -36,10 +39,6 @@ prepare() {
|
||||
-t|--test)
|
||||
ACTION=test
|
||||
;;
|
||||
- -a|--arch)
|
||||
- shift
|
||||
- ARCH=$1
|
||||
- ;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -56,11 +55,8 @@ prepare() {
|
||||
shift
|
||||
done
|
||||
|
||||
- # Export env vars that are needed during the build
|
||||
- SCRIPTS="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
- LIBCARE_DIR="${LIBCARE_DIR:-$SCRIPTS/..}"
|
||||
- KPATCH_PATH="${KPATCH_PATH:-$LIBCARE_DIR/src}"
|
||||
- export LIBCARE_DIR KPATCH_PATH
|
||||
+ KPATCH_PATH="$(dirname "$( which libcare-cc )" )"
|
||||
+ export KPATCH_PATH
|
||||
export OLDPATH=$PATH
|
||||
export KPATCH_PASSTHROUGH_ASM=1
|
||||
CPUS=`cat /proc/cpuinfo | grep ^processor | wc -l`
|
||||
@@ -70,12 +66,13 @@ prepare() {
|
||||
# Obtain information about the project
|
||||
source $PDIR/info
|
||||
|
||||
- mkdir -p /kcdata
|
||||
+ ROOT_ORIGINAL=$PDIR/root.original
|
||||
+ ROOT_PATCHED=$PDIR/root.patched
|
||||
}
|
||||
|
||||
clean_dirs() {
|
||||
echo " cleaning up"
|
||||
- rm -rf $KP_PROJECT_BUILD_ROOT /root/root.original /root/root.patched
|
||||
+ rm -rf $KP_PROJECT_BUILD_ROOT $ROOT_ORIGINAL $ROOT_PATCHED
|
||||
}
|
||||
|
||||
kp_prepare_env_hook() {
|
||||
@@ -86,17 +83,15 @@ kp_prepare_env_hook() {
|
||||
kp_pack_prebuilt() {
|
||||
echo " packing prebuilt $KP_PROJECT into $KP_PROJECT_PREBUILT"
|
||||
pushd $KP_PROJECT_BUILD_ROOT
|
||||
- tar -zcf /kcdata/$KP_PROJECT_PREBUILT \
|
||||
+ tar -zcf $PDIR/$KP_PROJECT_PREBUILT \
|
||||
$KP_PROJECT_BUILD_ROOT \
|
||||
- /root/root.original
|
||||
+ $ROOT_ORIGINAL
|
||||
popd
|
||||
}
|
||||
|
||||
kp_unpack_prebuilt() {
|
||||
echo " unpacking prebuilt $KP_PROJECT into $KP_PROJECT_PREBUILT"
|
||||
- tar -xf /kcdata/$KP_PROJECT_PREBUILT -C /
|
||||
-
|
||||
- yum-builddep -d 1 -y $KP_PROJECT_BUILD_ROOT/SPECS/$KP_PROJECT_SPEC
|
||||
+ tar -xf $PDIR/$KP_PROJECT_PREBUILT -C /
|
||||
}
|
||||
|
||||
kp_prepare_source_raw() {
|
||||
@@ -108,38 +103,32 @@ kp_prepare_source_raw() {
|
||||
}
|
||||
|
||||
kp_download_source_rpm() {
|
||||
- mkdir -p /kcdata
|
||||
if test -n "$KP_PROJECT_SOURCE_URL"; then
|
||||
- curl $KP_PROJECT_SOURCE_URL -o /kcdata/$KP_PROJECT_SOURCE
|
||||
+ curl $KP_PROJECT_SOURCE_URL -o $KP_PROJECT_ORIG_RPMS/$KP_PROJECT_SOURCE
|
||||
else
|
||||
- yumdownloader --source --destdir /kcdata ${KP_PROJECT_SOURCE%.src.rpm}
|
||||
+ yumdownloader --source --destdir $KP_PROJECT_ORIG_RPMS ${KP_PROJECT_SOURCE%.src.rpm}
|
||||
fi
|
||||
}
|
||||
|
||||
kp_prepare_source_rpm() {
|
||||
- rm -rf $HOME/deps
|
||||
+ rm -rf $PDIR/deps
|
||||
eval yum-builddep -d 1 -y $KP_RPM_REPOS \
|
||||
- --downloadonly --downloaddir=$HOME/deps \
|
||||
- /kcdata/$KP_PROJECT_SOURCE
|
||||
+ --downloadonly --downloaddir=$PDIR/deps \
|
||||
+ $KP_PROJECT_ORIG_RPMS/$KP_PROJECT_SOURCE
|
||||
mkdir -p $KP_PROJECT_BUILD_ROOT
|
||||
rpm -qa > $KP_PROJECT_BUILD_ROOT/all-packages.txt
|
||||
- ls $HOME/deps > $KP_PROJECT_BUILD_ROOT/dependencies.txt
|
||||
- eval yum-builddep -d 1 -y $KP_RPM_REPOS \
|
||||
- /kcdata/$KP_PROJECT_SOURCE
|
||||
+ ls $PDIR/deps > $KP_PROJECT_BUILD_ROOT/dependencies.txt
|
||||
+ eval yum-builddep -d 1 -y $KP_RPM_REPOS \
|
||||
+ $KP_PROJECT_ORIG_RPMS/$KP_PROJECT_SOURCE
|
||||
|
||||
sed -i 's/.rpm$//g' $KP_PROJECT_BUILD_ROOT/dependencies.txt
|
||||
|
||||
- rpm -ivh /kcdata/$KP_PROJECT_SOURCE \
|
||||
+ rpm -ivh $KP_PROJECT_ORIG_RPMS/$KP_PROJECT_SOURCE \
|
||||
--define "_topdir $KP_PROJECT_BUILD_ROOT"
|
||||
}
|
||||
|
||||
-kp_prepare_source_deb() {
|
||||
- echo "deb support is not implemented yet"
|
||||
- exit 1
|
||||
-}
|
||||
-
|
||||
kp_prepare_source() {
|
||||
- if ! test -f /kcdata/$KP_PROJECT_SOURCE; then
|
||||
+ if ! test -f $KP_PROJECT_ORIG_RPMS/$KP_PROJECT_SOURCE; then
|
||||
echo " downloading source for $KP_PROJECT"
|
||||
kp_download_source_$KP_PROJECT_FORMAT
|
||||
fi
|
||||
@@ -147,12 +136,60 @@ kp_prepare_source() {
|
||||
kp_prepare_source_$KP_PROJECT_FORMAT
|
||||
}
|
||||
|
||||
+patch_list_apply() {
|
||||
+ SRC_DIR=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
|
||||
+ PATCH_DIR=$(cd "$(dirname "$KP_PROJECT_PLIST_FILE")" && pwd)
|
||||
+ PLIST=$PATCH_DIR/$(basename "$KP_PROJECT_PLIST_FILE")
|
||||
+ PATCH_ID=$(echo $(basename "$KP_PROJECT_PLIST_FILE") | awk -F. '{print $1}')
|
||||
+ if test -z "$PATCH_ID"; then
|
||||
+ echo "Failed to get patch-id. Please check plist filename: $KP_PROJECT_PLIST_FILE"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ TEMP_PLIST=/tmp/build.kpatch/tmpplist
|
||||
+
|
||||
+ if [ ! -f $PLIST ]; then
|
||||
+ echo "File $PLIST not found"
|
||||
+ exit 1;
|
||||
+ fi
|
||||
+
|
||||
+ echo "patching $PWD with patches from $PLIST"
|
||||
+
|
||||
+ pushd $SRC_DIR # go to the directory with sources to be patched
|
||||
+
|
||||
+ #in case we don't have a newline in plist
|
||||
+ cat $PLIST > $TEMP_PLIST
|
||||
+ echo -e "\n" >> $TEMP_PLIST
|
||||
+
|
||||
+ # iterate through patches in PLIST
|
||||
+ while read NAME
|
||||
+ do
|
||||
+ COMMENT=`echo $NAME | cut -c1`
|
||||
+ if [ "$COMMENT" == "#" ]; then
|
||||
+ continue;
|
||||
+ fi
|
||||
+
|
||||
+ if [ -z "${NAME}" ]; then
|
||||
+ continue;
|
||||
+ fi
|
||||
+
|
||||
+ echo "Applying patch $NAME"
|
||||
+ patch -p1 -u --fuzz=0 --batch < $PATCH_DIR/$NAME
|
||||
+ if [ $? != 0 ]; then
|
||||
+ echo "Failed applying patch $NAME"; popd; rm $TEMP_PLIST; exit 1
|
||||
+ else
|
||||
+ echo "Successfully applied patch $NAME"
|
||||
+ fi
|
||||
+ done < $TEMP_PLIST
|
||||
+ rm $TEMP_PLIST
|
||||
+
|
||||
+ popd
|
||||
+}
|
||||
+
|
||||
kp_patch_source() {
|
||||
echo " patching project"
|
||||
- PATCH_DIR=$LIBCARE_DIR/patches
|
||||
#patch_list_apply requires this dir
|
||||
mkdir -p /tmp/build.kpatch
|
||||
- $SCRIPTS/patch_list_apply $KP_PROJECT_DIR $PDIR/plist $PATCH_DIR
|
||||
+ patch_list_apply $KP_PROJECT_DIR
|
||||
}
|
||||
|
||||
kp_prebuild_rpm() {
|
||||
@@ -170,25 +207,17 @@ kp_prebuild_rpm() {
|
||||
}
|
||||
|
||||
_kp_install_orig_rpm() {
|
||||
- for rpmfile in $KP_ORIG_RPMS; do
|
||||
- pkgname="$(basename $rpmfile)"
|
||||
- pkgname="${pkgname%%.rpm}"
|
||||
- eval yumdownloader --enablerepo=base-debuginfo $KP_RPM_REPOS \
|
||||
- --destdir=$HOME/rpms.orig $pkgname
|
||||
- done
|
||||
-
|
||||
- rpm --force -i $HOME/rpms.orig/*.rpm \
|
||||
- --root=$HOME/root.original \
|
||||
+ rpm --force -i $1 \
|
||||
+ --root=$ROOT_ORIGINAL \
|
||||
--nodeps --noscripts
|
||||
}
|
||||
|
||||
kp_install_orig_rpm() {
|
||||
- _kp_install_orig_rpm
|
||||
+ for orig_rpm in $(ls $KP_PROJECT_ORIG_RPMS | grep -v $KP_PROJECT_SOURCE); do
|
||||
+ _kp_install_orig_rpm $KP_PROJECT_ORIG_RPMS/$orig_rpm
|
||||
+ done
|
||||
}
|
||||
|
||||
-kp_prebuild_hook() {
|
||||
- :
|
||||
-}
|
||||
|
||||
kp_prebuild() {
|
||||
echo " prebuilding $KP_PROJECT"
|
||||
@@ -200,25 +229,25 @@ de_offset_syms() {
|
||||
local binary=$1
|
||||
|
||||
readelf -WSs $binary > $binary.symlist 2>/dev/null
|
||||
- $SCRIPTS/de-offset-syms.awk $binary.symlist > $binary.symlist.tmp
|
||||
+ de-offset-syms.awk $binary.symlist > $binary.symlist.tmp
|
||||
sort $binary.symlist.tmp > $binary.symlist
|
||||
rm -f $binary.symlist.tmp
|
||||
}
|
||||
|
||||
kp_sanity_check() {
|
||||
- pushd $HOME/root.patched
|
||||
+ pushd $ROOT_PATCHED
|
||||
local targets="$(find . -perm /0111 -type f)"
|
||||
popd
|
||||
|
||||
local failed=""
|
||||
for target in $targets; do
|
||||
- local original="$HOME/root.original/usr/lib/debug/$target.debug"
|
||||
- local patched="$HOME/root.patched/$target"
|
||||
+ local original=`ls $ROOT_ORIGINAL/usr/lib/debug/${target}*.debug`
|
||||
+ local patched="$ROOT_PATCHED/$target"
|
||||
local alloweddiff="$PDIR/$(basename "$target").symlist.diff"
|
||||
|
||||
de_offset_syms $original
|
||||
if test ! -s $original.symlist; then
|
||||
- original="$HOME/root.original/$target"
|
||||
+ original="$ROOT_ORIGINAL/$target"
|
||||
de_offset_syms $original
|
||||
fi
|
||||
|
||||
@@ -241,7 +270,11 @@ kp_sanity_check() {
|
||||
done
|
||||
|
||||
if test -n "$failed"; then
|
||||
- die "Failed sanity check for $failed"
|
||||
+ if test "$KP_SANITY_CHECK_STRICTLY" == "yes"; then
|
||||
+ die "Failed sanity check for $failed"
|
||||
+ else
|
||||
+ echo "[Warning] Failed sanity check for $failed"
|
||||
+ fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -308,7 +341,7 @@ kp_check_missing_files() {
|
||||
}
|
||||
|
||||
kp_install_generic() {
|
||||
- local root_patched="$HOME/root.patched"
|
||||
+ local root_patched="$ROOT_PATCHED"
|
||||
|
||||
kp_install_files $KP_PROJECT_BUILD_DIR \
|
||||
$root_patched \
|
||||
@@ -318,13 +351,9 @@ kp_install_generic() {
|
||||
}
|
||||
|
||||
kp_install_rpm() {
|
||||
- kp_install_orig_rpm
|
||||
kp_install_generic
|
||||
}
|
||||
|
||||
-kp_build_hook() {
|
||||
- :
|
||||
-}
|
||||
|
||||
kp_build() {
|
||||
echo " building $KP_PROJECT"
|
||||
@@ -340,19 +369,22 @@ kp_build() {
|
||||
kp_gen_kpatch() {
|
||||
echo " generating kpatches"
|
||||
|
||||
- pushd $HOME/root.patched
|
||||
+ pushd $ROOT_PATCHED
|
||||
targets=$(find . -perm /0111 -type f)
|
||||
popd
|
||||
|
||||
- rm -rf $HOME/${KP_PROJECT_PATCH%.*}
|
||||
- mkdir $HOME/${KP_PROJECT_PATCH%.*}
|
||||
+ rm -rf $PDIR/${KP_PROJECT_PATCH%.*}
|
||||
+ mkdir $PDIR/${KP_PROJECT_PATCH%.*}
|
||||
|
||||
local no_patches=1
|
||||
|
||||
for t in $targets; do
|
||||
- local debug="$HOME/root.original/usr/lib/debug/$t.debug"
|
||||
- local patched="$HOME/root.patched/$t"
|
||||
+ local debug=`ls $ROOT_ORIGINAL/usr/lib/debug/${t}*.debug`
|
||||
+ local patched="$ROOT_PATCHED/$t"
|
||||
local buildid=$(eu-readelf -n $debug | sed -n '/Build ID:/ { s/.* //; p }')
|
||||
+ if test -n "$KP_PROJECT_BUILD_ID"; then
|
||||
+ buildid=$KP_PROJECT_BUILD_ID
|
||||
+ fi
|
||||
if test -z "$buildid"; then
|
||||
continue
|
||||
fi
|
||||
@@ -363,7 +395,7 @@ kp_gen_kpatch() {
|
||||
|
||||
chmod u+w $debug $patched
|
||||
|
||||
- eu-unstrip "$HOME/root.original/$t" "$debug"
|
||||
+ eu-unstrip "$ROOT_ORIGINAL/$t" "$debug"
|
||||
|
||||
$KPATCH_PATH/kpatch_strip --strip $patched $patched.kpstripped
|
||||
cp $patched.kpstripped $patched.relfixup
|
||||
@@ -372,8 +404,8 @@ kp_gen_kpatch() {
|
||||
/usr/bin/strip --strip-unneeded $patched.stripped
|
||||
cp $patched.stripped $patched.undolink
|
||||
$KPATCH_PATH/kpatch_strip --undo-link $debug $patched.undolink
|
||||
- $KPATCH_PATH/kpatch_make -b "$buildid" $patched.undolink -o $patched.kpatch
|
||||
- cp $patched.kpatch $HOME/${KP_PROJECT_PATCH%.*}/$buildid.kpatch
|
||||
+ $KPATCH_PATH/kpatch_make -b "$buildid" -i "$PATCH_ID" $patched.undolink -o $patched.kpatch
|
||||
+ cp $patched.kpatch $PDIR/${KP_PROJECT_PATCH%.*}/$buildid.kpatch
|
||||
no_patches=0
|
||||
done
|
||||
|
||||
@@ -384,9 +416,7 @@ kp_gen_kpatch() {
|
||||
|
||||
kp_pack_patch() {
|
||||
echo " packing patch for $KP_PROJECT into $KP_PROJECT_PATCH"
|
||||
- pushd $KP_PROJECT_BUILD_DIR
|
||||
- tar -zcf /kcdata/$KP_PROJECT_PATCH $HOME/${KP_PROJECT_PATCH%.*}
|
||||
- popd
|
||||
+ tar -zcf $PDIR/$KP_PROJECT_PATCH $PDIR/${KP_PROJECT_PATCH%.*}
|
||||
}
|
||||
|
||||
kp_unpack_patch() {
|
||||
@@ -411,11 +441,6 @@ kp_unpack_patch() {
|
||||
|
||||
rm -fr $tmpdir
|
||||
}
|
||||
-
|
||||
-kp_mark_tests_fail() {
|
||||
- touch /kcdata/Tests-FAIL
|
||||
-}
|
||||
-
|
||||
overwrite_utils() {
|
||||
TMPBIN=$(mktemp -d --tmpdir)
|
||||
|
||||
--
|
||||
2.24.1.windows.2
|
||||
|
||||
24
0014-kpatch_process-fix-possible-double-free.patch
Normal file
24
0014-kpatch_process-fix-possible-double-free.patch
Normal file
@ -0,0 +1,24 @@
|
||||
From fdf172f68f2270306effda39211a4be5ca7e437e Mon Sep 17 00:00:00 2001
|
||||
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||
Date: Tue, 17 May 2022 16:40:26 +0800
|
||||
Subject: [PATCH 1/5] kpatch_process: fix possible double free.
|
||||
|
||||
---
|
||||
src/kpatch_process.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/src/kpatch_process.c b/src/kpatch_process.c
|
||||
index 9d6daa4..a31f70c 100644
|
||||
--- a/src/kpatch_process.c
|
||||
+++ b/src/kpatch_process.c
|
||||
@@ -682,7 +682,6 @@ process_list_threads(kpatch_process_t *proc,
|
||||
t = realloc(pids, *alloc * sizeof(*pids));
|
||||
if (t == NULL) {
|
||||
kplogerror("Failed to (re)allocate memory for pids\n");
|
||||
- closedir(dir);
|
||||
goto dealloc;
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
39
0015-ptrace-fix-NULL-pointer-access-problem.patch
Normal file
39
0015-ptrace-fix-NULL-pointer-access-problem.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From a45b9424cb7258c00211115191f74fbaf8f74285 Mon Sep 17 00:00:00 2001
|
||||
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||
Date: Mon, 23 May 2022 10:18:57 +0800
|
||||
Subject: [PATCH 2/5] ptrace: fix NULL pointer access problem
|
||||
|
||||
---
|
||||
src/arch/aarch64/arch_ptrace.c | 2 --
|
||||
src/arch/x86/arch_ptrace.c | 2 --
|
||||
2 files changed, 4 deletions(-)
|
||||
|
||||
diff --git a/src/arch/aarch64/arch_ptrace.c b/src/arch/aarch64/arch_ptrace.c
|
||||
index 774dc21..2227e95 100644
|
||||
--- a/src/arch/aarch64/arch_ptrace.c
|
||||
+++ b/src/arch/aarch64/arch_ptrace.c
|
||||
@@ -465,8 +465,6 @@ kpatch_arch_ptrace_waitpid(kpatch_process_t *proc,
|
||||
|
||||
/* TODO: fix the latter by SINGLESTEPping such a thread with
|
||||
* the original instruction in place */
|
||||
- kperr("the thread ran out: %d, pc= %llx, expected = %lx\n", pid,
|
||||
- regs.pc, pctx->execute_until);
|
||||
errno = ESRCH;
|
||||
return -1;
|
||||
}
|
||||
diff --git a/src/arch/x86/arch_ptrace.c b/src/arch/x86/arch_ptrace.c
|
||||
index 9069484..9dede71 100644
|
||||
--- a/src/arch/x86/arch_ptrace.c
|
||||
+++ b/src/arch/x86/arch_ptrace.c
|
||||
@@ -492,8 +492,6 @@ int kpatch_arch_ptrace_waitpid(kpatch_process_t *proc,
|
||||
|
||||
/* TODO: fix the latter by SINGLESTEPping such a thread with
|
||||
* the original instruction in place */
|
||||
- kperr("the thread ran out: %d, rip = %llx, expected = %lx\n", pid,
|
||||
- regs.rip, pctx->execute_until);
|
||||
errno = ESRCH;
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
156
0016-fix-patched-process-crashing-when-acccess-the-global.patch
Normal file
156
0016-fix-patched-process-crashing-when-acccess-the-global.patch
Normal file
@ -0,0 +1,156 @@
|
||||
From add4a57f47eb89acf4a471253654cc806aedaaf8 Mon Sep 17 00:00:00 2001
|
||||
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||
Date: Wed, 11 May 2022 10:20:26 +0800
|
||||
Subject: [PATCH 3/5] fix patched process crashing when acccess the global var
|
||||
which newly added
|
||||
|
||||
---
|
||||
src/kpatch_gensrc.c | 20 +++++++++++++++++---
|
||||
src/kpatch_patch.c | 6 +++---
|
||||
tests/new_var/Makefile | 2 ++
|
||||
tests/new_var/desc | 1 +
|
||||
tests/new_var/new_var.c | 23 +++++++++++++++++++++++
|
||||
tests/new_var/new_var.diff | 15 +++++++++++++++
|
||||
6 files changed, 61 insertions(+), 6 deletions(-)
|
||||
create mode 100644 tests/new_var/Makefile
|
||||
create mode 100644 tests/new_var/desc
|
||||
create mode 100644 tests/new_var/new_var.c
|
||||
create mode 100644 tests/new_var/new_var.diff
|
||||
|
||||
diff --git a/src/kpatch_gensrc.c b/src/kpatch_gensrc.c
|
||||
index bf1832a..67254d7 100644
|
||||
--- a/src/kpatch_gensrc.c
|
||||
+++ b/src/kpatch_gensrc.c
|
||||
@@ -432,6 +432,20 @@ out:
|
||||
|
||||
/* ------------------------------------------ helpers -------------------------------------------- */
|
||||
|
||||
+static inline int page_shift(int n) {
|
||||
+ int res = -1;
|
||||
+
|
||||
+ while(n) {
|
||||
+ res++;
|
||||
+ n >>= 1;
|
||||
+ }
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+#define PAGE_SIZE getpagesize()
|
||||
+#define PAGE_SHIFT page_shift(PAGE_SIZE)
|
||||
+
|
||||
static void change_section(struct kp_file *fout, struct section_desc *sect, int flags)
|
||||
{
|
||||
static int init_data_section = 0;
|
||||
@@ -448,15 +462,15 @@ 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) {
|
||||
init_data_section = 1;
|
||||
- align = ".p2align\t12";
|
||||
+ align = ".p2align";
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fout->f, "\t.%ssection %s\n", (flags & FLAG_PUSH_SECTION) ? "push" : "", s);
|
||||
if (align)
|
||||
- fprintf(fout->f, "\t%s\n", align);
|
||||
+ fprintf(fout->f, "\t%s\t%d\n", align, PAGE_SHIFT);
|
||||
}
|
||||
|
||||
void get_comm_args(struct kp_file *f, int l, kpstr_t *xname, int *sz, int *align)
|
||||
diff --git a/src/kpatch_patch.c b/src/kpatch_patch.c
|
||||
index d74299d..3b53a5a 100644
|
||||
--- a/src/kpatch_patch.c
|
||||
+++ b/src/kpatch_patch.c
|
||||
@@ -372,9 +372,9 @@ object_apply_patch(struct object_file *o)
|
||||
kp->jmp_offset = sz;
|
||||
kpdebug("Jump table %d bytes for %d syms at offset 0x%x\n",
|
||||
o->jmp_table->size, undef, kp->jmp_offset);
|
||||
- sz = ROUND_UP(sz + o->jmp_table->size, 4096);
|
||||
+ sz = ROUND_UP(sz + o->jmp_table->size, PAGE_SIZE);
|
||||
}
|
||||
- sz = ROUND_UP(sz, 4096);
|
||||
+ sz = ROUND_UP(sz, PAGE_SIZE);
|
||||
|
||||
/* kpatch elf */
|
||||
kp->elf_offset = sz;
|
||||
@@ -386,7 +386,7 @@ object_apply_patch(struct object_file *o)
|
||||
kp->user_undo = sz;
|
||||
sz = ROUND_UP(sz + HUNK_SIZE * o->ninfo, 16);
|
||||
|
||||
- sz = ROUND_UP(sz, 4096);
|
||||
+ sz = ROUND_UP(sz, PAGE_SIZE);
|
||||
kp->kpatch_total_mem_sz = sz;
|
||||
|
||||
/*
|
||||
diff --git a/tests/new_var/Makefile b/tests/new_var/Makefile
|
||||
new file mode 100644
|
||||
index 0000000..6dd4b69
|
||||
--- /dev/null
|
||||
+++ b/tests/new_var/Makefile
|
||||
@@ -0,0 +1,2 @@
|
||||
+
|
||||
+include ../makefile.inc
|
||||
diff --git a/tests/new_var/desc b/tests/new_var/desc
|
||||
new file mode 100644
|
||||
index 0000000..4f8cd31
|
||||
--- /dev/null
|
||||
+++ b/tests/new_var/desc
|
||||
@@ -0,0 +1 @@
|
||||
+patch adds a new var
|
||||
diff --git a/tests/new_var/new_var.c b/tests/new_var/new_var.c
|
||||
new file mode 100644
|
||||
index 0000000..3ed116a
|
||||
--- /dev/null
|
||||
+++ b/tests/new_var/new_var.c
|
||||
@@ -0,0 +1,23 @@
|
||||
+#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+void print_greetings_patched(int var)
|
||||
+{
|
||||
+ printf("Hello. This is a PATCHED version\n");
|
||||
+ printf("Hello. <newly_added_var=0x%08x>\n", var);
|
||||
+}
|
||||
+
|
||||
+void print_greetings(void)
|
||||
+{
|
||||
+ printf("Hello. This is an UNPATCHED version\n");
|
||||
+}
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ while (1) {
|
||||
+ print_greetings();
|
||||
+ sleep(1);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/tests/new_var/new_var.diff b/tests/new_var/new_var.diff
|
||||
new file mode 100644
|
||||
index 0000000..c617535
|
||||
--- /dev/null
|
||||
+++ b/tests/new_var/new_var.diff
|
||||
@@ -0,0 +1,15 @@
|
||||
+--- ./new_var.c 2022-02-10 19:40:17.948981115 +0800
|
||||
++++ ./new_var.c 2022-02-10 20:02:38.774536002 +0800
|
||||
+@@ -7,9 +7,11 @@
|
||||
+ printf("Hello. <newly_added_var=0x%08x>\n", var);
|
||||
+ }
|
||||
+
|
||||
++int newly_added_var = 0x20220210;
|
||||
+ void print_greetings(void)
|
||||
+ {
|
||||
+- printf("Hello. This is an UNPATCHED version\n");
|
||||
++ newly_added_var = 0x2022 << 16 | 0x2202;
|
||||
++ print_greetings_patched(newly_added_var);
|
||||
+ }
|
||||
+
|
||||
+ int main()
|
||||
--
|
||||
2.27.0
|
||||
|
||||
100
0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
Normal file
100
0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
Normal file
@ -0,0 +1,100 @@
|
||||
From c4f9d59c62454d255af4a5c3933eebf6942dbd99 Mon Sep 17 00:00:00 2001
|
||||
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||
Date: Wed, 11 May 2022 10:32:45 +0800
|
||||
Subject: [PATCH 4/5] fix probably restore cc symbol link fail when kill patch
|
||||
building uncourteous
|
||||
|
||||
---
|
||||
src/libcare-patch-make | 45 ++++--------------------------------------
|
||||
1 file changed, 4 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||
index 03aa1d6..41e5926 100755
|
||||
--- a/src/libcare-patch-make
|
||||
+++ b/src/libcare-patch-make
|
||||
@@ -83,32 +83,6 @@ restore_origs() {
|
||||
|
||||
trap "restore_origs" 0
|
||||
|
||||
-replace_qemu_ld_flags() {
|
||||
- local qemu_ld_flags_old=$1
|
||||
- ret=$(echo $qemu_ld_flags_old | grep "\-Wl,-q")
|
||||
- if [[ "$ret" == "" ]]; then
|
||||
- local qemu_ld_flags="${qemu_ld_flags_old} -Wl,-q"
|
||||
- echo "replace QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||
- sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||
- fi
|
||||
-}
|
||||
-
|
||||
-recover_qemu_ld_flags() {
|
||||
- local qemu_ld_flags=$1
|
||||
- echo "recover QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||
- sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||
-}
|
||||
-
|
||||
-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
|
||||
|
||||
@@ -124,7 +98,8 @@ build_objects() {
|
||||
export KPCC_DBGFILTER_ARGS=""
|
||||
|
||||
echo "${green}BUILDING ORIGINAL CODE${reset}"
|
||||
- make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||
+ local lp_make_env_original="CC=${CC}"
|
||||
+ make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_original} >$MAKE_OUTPUT 2>&1
|
||||
|
||||
echo "${green}INSTALLING ORIGINAL OBJECTS INTO $LPMAKE_ORIGINAL_DIR${reset}"
|
||||
make $LPMAKEFILE $JOBS_MAKE install \
|
||||
@@ -149,20 +124,14 @@ build_objects() {
|
||||
export KPATCH_STAGE=patched
|
||||
export KPCC_APPEND_ARGS="-Wl,-q"
|
||||
|
||||
- qemu_ld_flags_bak=$(grep "^QEMU_LDFLAGS=" config-host.mak)
|
||||
- #add '-Wl,-q' to LD_FLAGS
|
||||
- replace_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||
-
|
||||
echo "${green}BUILDING PATCHED CODE${reset}"
|
||||
- make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||
+ local lp_make_env_patched="CC=${CC}"
|
||||
+ make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_patched} >$MAKE_OUTPUT 2>&1
|
||||
|
||||
echo "${green}INSTALLING PATCHED OBJECTS INTO $LPMAKE_PATCHED_DIR${reset}"
|
||||
make $LPMAKEFILE $JOBS_MAKE install \
|
||||
"$destdir=$LPMAKE_PATCHED_DIR" \
|
||||
>$MAKE_OUTPUT 2>&1
|
||||
-
|
||||
- # recover LD_FLAGS
|
||||
- recover_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||
}
|
||||
|
||||
build_kpatches() {
|
||||
@@ -274,16 +243,10 @@ 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.27.0
|
||||
|
||||
39
0018-optimize-Remove-unnecessary-comparison-code.patch
Normal file
39
0018-optimize-Remove-unnecessary-comparison-code.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From 5667441f87ef702ed537aba7c677eee1b36f1ead Mon Sep 17 00:00:00 2001
|
||||
From: wangcichen <wangcichen_yewu@cmss.chinamobile.com>
|
||||
Date: Fri, 27 May 2022 17:08:28 +0800
|
||||
Subject: [PATCH 5/5] optimize: Remove unnecessary comparison code
|
||||
|
||||
---
|
||||
src/arch/aarch64/arch_elf.c | 2 +-
|
||||
src/arch/x86/arch_elf.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/arch/aarch64/arch_elf.c b/src/arch/aarch64/arch_elf.c
|
||||
index 9ce586d..10399ee 100644
|
||||
--- a/src/arch/aarch64/arch_elf.c
|
||||
+++ b/src/arch/aarch64/arch_elf.c
|
||||
@@ -202,7 +202,7 @@ int kpatch_arch_apply_relocate_add(struct object_file *o, GElf_Shdr *relsec)
|
||||
unsigned long val;
|
||||
void *loc, *loc2;
|
||||
|
||||
- if (r->r_offset < 0 || r->r_offset >= tshdr->sh_size) {
|
||||
+ if (r->r_offset >= tshdr->sh_size) {
|
||||
kperr("Relocation offset for section '%s'"
|
||||
" is at 0x%lx beyond the section size 0x%lx\n",
|
||||
scnname, r->r_offset, tshdr->sh_size);
|
||||
diff --git a/src/arch/x86/arch_elf.c b/src/arch/x86/arch_elf.c
|
||||
index 265fd37..f79a996 100644
|
||||
--- a/src/arch/x86/arch_elf.c
|
||||
+++ b/src/arch/x86/arch_elf.c
|
||||
@@ -56,7 +56,7 @@ int kpatch_arch_apply_relocate_add(struct object_file *o, GElf_Shdr *relsec)
|
||||
unsigned long val;
|
||||
void *loc, *loc2;
|
||||
|
||||
- if (r->r_offset < 0 || r->r_offset >= tshdr->sh_size) {
|
||||
+ if (r->r_offset >= tshdr->sh_size) {
|
||||
kperr("Relocation offset for section '%s'"
|
||||
" is at 0x%lx beyond the section size 0x%lx\n",
|
||||
scnname, r->r_offset, tshdr->sh_size);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
101
0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
Normal file
101
0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From d86044aa709617186fa4eeb2dff9540395f77c8e Mon Sep 17 00:00:00 2001
|
||||
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||
Date: Tue, 5 Jul 2022 10:13:15 +0800
|
||||
Subject: [PATCH 1/2] Revert "fix probably restore cc symbol link fail when
|
||||
kill patch building uncourteous" ==> Revert "libcare-patch-make: fix some
|
||||
bugs"
|
||||
|
||||
---
|
||||
src/libcare-patch-make | 45 ++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 41 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||
index 41e5926..03aa1d6 100755
|
||||
--- a/src/libcare-patch-make
|
||||
+++ b/src/libcare-patch-make
|
||||
@@ -83,6 +83,32 @@ restore_origs() {
|
||||
|
||||
trap "restore_origs" 0
|
||||
|
||||
+replace_qemu_ld_flags() {
|
||||
+ local qemu_ld_flags_old=$1
|
||||
+ ret=$(echo $qemu_ld_flags_old | grep "\-Wl,-q")
|
||||
+ if [[ "$ret" == "" ]]; then
|
||||
+ local qemu_ld_flags="${qemu_ld_flags_old} -Wl,-q"
|
||||
+ echo "replace QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||
+ sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
+recover_qemu_ld_flags() {
|
||||
+ local qemu_ld_flags=$1
|
||||
+ echo "recover QEMU_LDFLAGS to '${qemu_ld_flags}'"
|
||||
+ sed -i "/^QEMU_LDFLAGS=/c\\${qemu_ld_flags}" config-host.mak
|
||||
+}
|
||||
+
|
||||
+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
|
||||
|
||||
@@ -98,8 +124,7 @@ build_objects() {
|
||||
export KPCC_DBGFILTER_ARGS=""
|
||||
|
||||
echo "${green}BUILDING ORIGINAL CODE${reset}"
|
||||
- local lp_make_env_original="CC=${CC}"
|
||||
- make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_original} >$MAKE_OUTPUT 2>&1
|
||||
+ make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||
|
||||
echo "${green}INSTALLING ORIGINAL OBJECTS INTO $LPMAKE_ORIGINAL_DIR${reset}"
|
||||
make $LPMAKEFILE $JOBS_MAKE install \
|
||||
@@ -124,14 +149,20 @@ build_objects() {
|
||||
export KPATCH_STAGE=patched
|
||||
export KPCC_APPEND_ARGS="-Wl,-q"
|
||||
|
||||
+ qemu_ld_flags_bak=$(grep "^QEMU_LDFLAGS=" config-host.mak)
|
||||
+ #add '-Wl,-q' to LD_FLAGS
|
||||
+ replace_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||
+
|
||||
echo "${green}BUILDING PATCHED CODE${reset}"
|
||||
- local lp_make_env_patched="CC=${CC}"
|
||||
- make $LPMAKEFILE $JOBS_MAKE ${lp_make_env_patched} >$MAKE_OUTPUT 2>&1
|
||||
+ make $LPMAKEFILE $JOBS_MAKE >$MAKE_OUTPUT 2>&1
|
||||
|
||||
echo "${green}INSTALLING PATCHED OBJECTS INTO $LPMAKE_PATCHED_DIR${reset}"
|
||||
make $LPMAKEFILE $JOBS_MAKE install \
|
||||
"$destdir=$LPMAKE_PATCHED_DIR" \
|
||||
>$MAKE_OUTPUT 2>&1
|
||||
+
|
||||
+ # recover LD_FLAGS
|
||||
+ recover_qemu_ld_flags "$qemu_ld_flags_bak"
|
||||
}
|
||||
|
||||
build_kpatches() {
|
||||
@@ -243,10 +274,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.27.0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From 96362b54e9c2162fe10fd1cfe029bcc8e203b135 Mon Sep 17 00:00:00 2001
|
||||
From: ctyunsystem <ctyuncommiter05@chinatelecom.cn>
|
||||
Date: Tue, 5 Jul 2022 10:13:58 +0800
|
||||
Subject: [PATCH 2/2] fix probably restore cc symbol link fail when kill patch
|
||||
building uncourteous
|
||||
|
||||
---
|
||||
src/libcare-patch-make | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||
index 03aa1d6..3cd2fe9 100755
|
||||
--- a/src/libcare-patch-make
|
||||
+++ b/src/libcare-patch-make
|
||||
@@ -109,6 +109,8 @@ recover_cc_symbolink() {
|
||||
ln -s $REAL_CC $SYMBOLINK_CC
|
||||
}
|
||||
|
||||
+trap "recover_cc_symbolink" SIGINT SIGTERM SIGQUIT
|
||||
+
|
||||
build_objects() {
|
||||
restore_origs
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
25
0021-do-not-print-awk-warning-in-libcare-patch-make.patch
Normal file
25
0021-do-not-print-awk-warning-in-libcare-patch-make.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From fce7fbc7ad2e830c5efc817e31da45f0e6a48a47 Mon Sep 17 00:00:00 2001
|
||||
From: jiang-dawei15 <jiangdawei15@huawei.com>
|
||||
Date: Fri, 16 Sep 2022 19:31:28 +0800
|
||||
Subject: [PATCH] do not print awk warning in libcare-patch-make
|
||||
|
||||
---
|
||||
src/libcare-patch-make | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libcare-patch-make b/src/libcare-patch-make
|
||||
index 3cd2fe9..9476063 100755
|
||||
--- a/src/libcare-patch-make
|
||||
+++ b/src/libcare-patch-make
|
||||
@@ -78,7 +78,7 @@ restore_origs() {
|
||||
{ vers[fname] = origfname; }
|
||||
}
|
||||
END { for (f in vers) system("mv " vers[f] " " f); }
|
||||
-'
|
||||
+' > /dev/null 2>&1
|
||||
}
|
||||
|
||||
trap "restore_origs" 0
|
||||
--
|
||||
2.27.0
|
||||
|
||||
108
libcareplus.spec
108
libcareplus.spec
@ -3,25 +3,37 @@
|
||||
Version: 1.0.0
|
||||
Name: libcareplus
|
||||
Summary: LibcarePlus tools
|
||||
Release: 8
|
||||
Release: 14
|
||||
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
|
||||
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
|
||||
Patch0009: help-modify-some-help-information.patch
|
||||
Patch0010: libcare-patch-make-fix-some-bugs.patch
|
||||
Patch0011: selinux-enable-libcare-ctl-to-mprotect-qemu-process.patch
|
||||
Patch0000: 0000-gensrc-skip-vector-instruction-in-str_do_gotpcrel.patch
|
||||
Patch0001: 0001-gensrc-we-should-add-align-while-FLAGS_PUSH_SECTION-.patch
|
||||
Patch0002: 0002-fix-cblock-parse-for-LCOLD-LHOT-.cold.NUM-.init_arra.patch
|
||||
Patch0003: 0003-elf-add-section-adderss-for-STT_NOTYPE-type-of-symbo.patch
|
||||
Patch0004: 0004-elf-strip-adapt-to-new-gcc-version-10.3.1.patch
|
||||
Patch0005: 0005-gitignore-ignore-some-tests-and-binary.patch
|
||||
Patch0006: 0006-libcare-patch-make-adapt-libcare-patch-make-to-meson.patch
|
||||
Patch0007: 0007-kpatch_elf-compatible-with-older-versions-of-the-so-.patch
|
||||
Patch0008: 0008-kpatch_parse-fix-failed-to-recognize-.cold.patch
|
||||
Patch0009: 0009-help-modify-some-help-information.patch
|
||||
Patch0010: 0010-libcare-patch-make-fix-some-bugs.patch
|
||||
Patch0011: 0011-selinux-enable-libcare-ctl-to-mprotect-qemu-process.patch
|
||||
Patch0012: 0012-libcare-dump-change-the-return-value.patch
|
||||
Patch0013: 0013-modify-pkgbuild-to-make-kpatch-for-RPM-based-packages.patch
|
||||
Patch0014: 0014-kpatch_process-fix-possible-double-free.patch
|
||||
Patch0015: 0015-ptrace-fix-NULL-pointer-access-problem.patch
|
||||
Patch0016: 0016-fix-patched-process-crashing-when-acccess-the-global.patch
|
||||
Patch0017: 0017-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
|
||||
Patch0018: 0018-optimize-Remove-unnecessary-comparison-code.patch
|
||||
Patch0019: 0019-Revert-fix-probably-restore-cc-symbol-link-fail-when.patch
|
||||
Patch0020: 0020-fix-probably-restore-cc-symbol-link-fail-when-kill-p.patch
|
||||
Patch0021: 0021-do-not-print-awk-warning-in-libcare-patch-make.patch
|
||||
|
||||
BuildRequires: elfutils-libelf-devel libunwind-devel gcc systemd
|
||||
Requires: binutils elfutils elfutils-libelf-devel libunwind-devel
|
||||
|
||||
%if 0%{with selinux}
|
||||
BuildRequires: checkpolicy
|
||||
@ -86,6 +98,9 @@ make -C dist/selinux install \
|
||||
|
||||
|
||||
install -m 0644 -D dist/libcare.preset %{buildroot}%{_presetdir}/90-libcare.preset
|
||||
install -m 0500 scripts/pkgbuild %{buildroot}%{_bindir}/libcare-pkgbuild
|
||||
install -m 0500 scripts/de-offset-syms.awk %{buildroot}%{_bindir}/de-offset-syms.awk
|
||||
install -m 0644 -D scripts/example_info %{buildroot}/usr/share/libcareplus/qemu_example_info
|
||||
|
||||
%pre
|
||||
/usr/sbin/groupadd libcare -r 2>/dev/null || :
|
||||
@ -109,6 +124,9 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_bindir}/kpatch_make
|
||||
%{_bindir}/libcare-server
|
||||
%{_bindir}/libcare-client
|
||||
%{_bindir}/libcare-pkgbuild
|
||||
%{_bindir}/de-offset-syms.awk
|
||||
/usr/share/libcareplus/qemu_example_info
|
||||
|
||||
%if 0%{with selinux}
|
||||
|
||||
@ -151,50 +169,74 @@ exit 0
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Mar 29 2022 yezengruan <yezengruan@huawei.com> 1.0.0.8
|
||||
* Fri Jan 6 2023 lvgenggeng <lvgenggeng@uniontech.com> 1.0.0-14
|
||||
* fix runtime dependencies
|
||||
|
||||
* Fri Sep 16 2022 yezengruan <yezengruan@huawei.com> 1.0.0-13
|
||||
- do not print awk warning in libcare-patch-make
|
||||
|
||||
* Wed Jun 15 2022 yezengruan <yezengruan@huawei.com> 1.0.0-12
|
||||
- kpatch_process: fix possible double free.
|
||||
- ptrace: fix NULL pointer access problem
|
||||
- fix patched process crashing when acccess the global var
|
||||
- fix probably restore cc symbol link fail when kill patch building uncourteous
|
||||
- optimize: Remove unnecessary comparison code
|
||||
|
||||
* Wed May 11 2022 Cichen Wang <wangcichen_yewu@cmss.chinamobile.com> 1.0.0-11
|
||||
- modify scripts/pkgbuild to make kpatch'es for the RPM-based packages
|
||||
|
||||
* Tue May 10 2022 yezengruan <yezengruan@huawei.com> 1.0.0-10
|
||||
- libcare-dump: change the return value
|
||||
- gensrc: skip vector instruction in str_do_gotpcrel
|
||||
|
||||
* Wed Apr 27 2022 yezengruan <yezengruan@huawei.com> 1.0.0-9
|
||||
- update the format of changelog
|
||||
|
||||
* Tue Mar 29 2022 yezengruan <yezengruan@huawei.com> 1.0.0-8
|
||||
- selinux: enable libcare-ctl to mprotect qemu process
|
||||
|
||||
* Mon Mar 21 2022 yezengruan <yezengruan@huawei.com> 1.0.0.7
|
||||
* Mon Mar 21 2022 yezengruan <yezengruan@huawei.com> 1.0.0-7
|
||||
- libcare-patch-make: fix some bugs
|
||||
|
||||
* Tue Mar 15 2022 yezengruan <yezengruan@huawei.com> 1.0.0.6
|
||||
* Tue Mar 15 2022 yezengruan <yezengruan@huawei.com> 1.0.0-6
|
||||
- help: modify some help information
|
||||
|
||||
* Wed Mar 02 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.5
|
||||
* Wed Mar 02 2022 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
|
||||
* 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
|
||||
- elf/strip: adapt to new gcc version(10.3.1)
|
||||
|
||||
* Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.3
|
||||
* Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0-3
|
||||
- libcareplus.spec:remove libcare.service and libcare.socket
|
||||
|
||||
* Tue Feb 22 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.2
|
||||
* 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
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 1.0.0.0
|
||||
- package init 1.0.0
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 1.0.0-0
|
||||
- package init 1.0.0-0
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.15
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-15
|
||||
- kpatch_user: init pid in cmd_info_user
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.14
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-14
|
||||
- some bugfix
|
||||
- support aarch64 UT
|
||||
- fix memory RWX problem
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.13
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-13
|
||||
- add libcare-dump tool
|
||||
- support test sets running on x86
|
||||
- some bugfixs
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.12
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-12
|
||||
- src/Makefile: execute config scripts before building
|
||||
- kpatch_gensrc.c: support ignoring functions which we don't need
|
||||
- arch/aarch64/arch_parse: modify is_variable_start for arm asm
|
||||
@ -207,23 +249,23 @@ exit 0
|
||||
- process: fix region start calculation
|
||||
- aarch64/arch_elf: Add ldr and ldrb relocation for aarch6
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.11
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-11
|
||||
- kpatch_cc: support gcc -MQ option
|
||||
- libcare-cc: add gcc iquote option support
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.10
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-10
|
||||
- kpatch_user.c: fix gcc warning
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.9
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-9
|
||||
- libcare-patch-make: add `-j|--jobs` option
|
||||
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4.8
|
||||
* Mon Feb 07 2022 imxcc <xingchaochao@huawei.com> - 0.1.4-8
|
||||
- updated the README.en.md file
|
||||
|
||||
* Wed Sep 08 2021 imxcc <xingchaochao@huawei.com> - 0.1.4.7
|
||||
* Wed Sep 08 2021 imxcc <xingchaochao@huawei.com> - 0.1.4-7
|
||||
- selinux: Allow init_t create lnk file
|
||||
|
||||
* Thu Sep 02 2021 imxcc <xingchaochao@huawei.com> - 0.1.4.6
|
||||
* Thu Sep 02 2021 imxcc <xingchaochao@huawei.com> - 0.1.4-6
|
||||
- enable selinux
|
||||
|
||||
* Sat Aug 21 2021 caodongxia <caodongxia@huawei.com> - 0.1.4-5
|
||||
@ -238,5 +280,5 @@ exit 0
|
||||
* Mon Dec 28 2020 sunguoshuai <sunguoshuai@huawei.com> - 0.1.4-2
|
||||
- Del the {dist} in release.
|
||||
|
||||
* Tue Dec 8 2020 Ying Fang <fangying1@huawei.com>
|
||||
* Tue Dec 8 2020 Ying Fang <fangying1@huawei.com> - 0.1.4-1
|
||||
- Init the libcareplus package spec
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user