From 9a2f8c5c443583790e5e3d95d6c73d9631424db3 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Wed, 23 Jul 2014 10:03:00 -0500 Subject: [PATCH 1/2] remove build pass from kpatch-build Now that we use the vmlinux from the distro debug package we don't need to do any build runs without -ffunction-sections -fdata-sections. Old: Build orig in objdir Build patched in objdir Build orig w/ flags in objdir2 Copy orig .o's into orig Build patched w/ flags in objdir2 Copy patched .o's into patched New: Build orig w/ flags in objdir Build patched w/ flags in objdir Copy patched .o's into patched Build orig w/ flags in objdir Copy orig .o's into orig This commit also does try to build each change object singularly since there are cases in the kernel tree where the Makefile does not reside in the same directory as the changed object. Signed-off-by: Seth Jennings --- kpatch-build/kpatch-build | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 47cd309..3f3851c 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -44,7 +44,6 @@ CPUS="$(getconf _NPROCESSORS_ONLN)" CACHEDIR="$HOME/.kpatch" SRCDIR="$CACHEDIR/src" OBJDIR="$CACHEDIR/obj" -OBJDIR2="$CACHEDIR/obj2" VERSIONFILE="$CACHEDIR/version" TEMPDIR= APPLIEDPATCHFILE="kpatch.patch" @@ -80,7 +79,6 @@ cleanup() { clean_cache() { [[ -z $USERSRCDIR ]] && rm -rf "$SRCDIR" - rm -rf "$OBJDIR" "$OBJDIR2" "$VERSIONFILE" mkdir -p "$OBJDIR" } @@ -388,7 +386,7 @@ cd "$SRCDIR" || die patch -N -p1 --dry-run < "$PATCHFILE" || die "source patch file failed to apply" cp "$PATCHFILE" "$APPLIEDPATCHFILE" || die cp -LR "$DATADIR/patch" "$TEMPDIR" || die -export KCFLAGS="-I$DATADIR/patch" # for kpatch-macros.h +export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections" echo "Building original kernel" make mrproper >> "$LOGFILE" 2>&1 || die @@ -418,25 +416,21 @@ done < "$TEMPDIR/patched_build.log" [[ ! -s "$TEMPDIR/changed_objs" ]] && die "no changed objects were detected" -echo "Rebuilding changed objects" -rm -rf "$OBJDIR2" -mkdir -p "$OBJDIR2" -cp "$OBJDIR/.config" "$OBJDIR2" || die +echo "Copying changed objects" mkdir "$TEMPDIR/patched" -export KCFLAGS="$KCFLAGS -ffunction-sections -fdata-sections" for i in $(cat $TEMPDIR/changed_objs); do - make "$i" "O=$OBJDIR2" >> "$LOGFILE" 2>&1 || die mkdir -p "$TEMPDIR/patched/$(dirname $i)" - cp -f "$OBJDIR2/$i" "$TEMPDIR/patched/$i" || die + cp -f "$OBJDIR/$i" "$TEMPDIR/patched/$i" || die done + +echo "Rebuilding original objects" patch -R -p1 < "$APPLIEDPATCHFILE" >> "$LOGFILE" 2>&1 rm -f "$APPLIEDPATCHFILE" +make "-j$CPUS" $TARGETS "O=$OBJDIR" >> "$LOGFILE" 2>&1 || die mkdir "$TEMPDIR/orig" for i in $(cat $TEMPDIR/changed_objs); do - rm -f "$i" - make "$i" "O=$OBJDIR2" >> "$LOGFILE" 2>&1 || die mkdir -p "$TEMPDIR/orig/$(dirname $i)" - cp -f "$OBJDIR2/$i" "$TEMPDIR/orig/$i" || die + cp -f "$OBJDIR/$i" "$TEMPDIR/orig/$i" || die done echo "Extracting new and modified ELF sections" From 5321b21aa0e847776d9634e871343e0afb1a6d81 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Wed, 23 Jul 2014 11:24:02 -0500 Subject: [PATCH 2/2] fixup review comments Signed-off-by: Seth Jennings --- kpatch-build/kpatch-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 3f3851c..3929035 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -79,6 +79,7 @@ cleanup() { clean_cache() { [[ -z $USERSRCDIR ]] && rm -rf "$SRCDIR" + rm -rf "$OBJDIR" "$VERSIONFILE" mkdir -p "$OBJDIR" } @@ -416,7 +417,6 @@ done < "$TEMPDIR/patched_build.log" [[ ! -s "$TEMPDIR/changed_objs" ]] && die "no changed objects were detected" -echo "Copying changed objects" mkdir "$TEMPDIR/patched" for i in $(cat $TEMPDIR/changed_objs); do mkdir -p "$TEMPDIR/patched/$(dirname $i)"