Skip to content

Commit

Permalink
hack: run create-diff-object on vmlinux.o for LTO kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-song-6 committed Dec 9, 2022
1 parent db5d328 commit e7be2de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ declare -a PATCH_LIST
APPLIED_PATCHES=0
OOT_MODULE=
KLP_REPLACE=1
USE_LTO=0

GCC="${CROSS_COMPILE:-}gcc"
CLANG="${CROSS_COMPILE:-}clang"
Expand Down Expand Up @@ -629,6 +630,7 @@ find_kobj() {
*.ko)
return
;;
vmlinux.o|\
*/built-in.o|\
*/built-in.a|\
arch/x86/kernel/ebda.o|\
Expand All @@ -642,6 +644,9 @@ find_kobj() {
esac

find_parent_obj "$KOBJFILE"
if [[ "$USE_LTO" -eq 1 ]] ; then
PARENT=vmlinux.o
fi
[[ -z "$PARENT" ]] && die "invalid ancestor $KOBJFILE for $file"
KOBJFILE="$PARENT"
done
Expand Down Expand Up @@ -678,9 +683,10 @@ usage() {
echo " --skip-compiler-check Skip compiler version matching check" >&2
echo " (not recommended)" >&2
echo " -p, --profile-data specify profile data for PGO (clang only)" >&2
echo " -l, --lto kernel is compiled with LTO" >&2
}

options="$(getopt -o ha:r:s:c:v:j:t:n:o:dRp: -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace,profile-data" -- "$@")" || die "getopt failed"
options="$(getopt -o ha:r:s:c:v:j:t:n:o:dRp:l -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace,profile-data,lto" -- "$@")" || die "getopt failed"

eval set -- "$options"

Expand Down Expand Up @@ -766,6 +772,9 @@ while [[ $# -gt 0 ]]; do
PROFILE_DATA="$(readlink -f "$2")"
shift
;;
-l|--lto)
USE_LTO=1
;;
*)
[[ "$1" = "--" ]] && shift && continue
[[ ! -f "$1" ]] && die "patch file '$1' not found"
Expand Down
5 changes: 5 additions & 0 deletions kpatch-build/kpatch-cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ elif [[ "$TOOLCHAINCMD" =~ ^(.*-)?ld || "$TOOLCHAINCMD" =~ ^(.*-)?ld.lld ]] ; th
cp -f "$obj" "$KPATCH_GCC_TEMPDIR/module/$relobj"
break
;;
vmlinux.o)
cp -f "$obj" "$KPATCH_GCC_TEMPDIR/orig/$relobj"
echo "$relobj" >> "$KPATCH_GCC_TEMPDIR/changed_objs"
break
;;
.tmp_vmlinux*|vmlinux)
args+=(--warn-unresolved-symbols)
break
Expand Down

0 comments on commit e7be2de

Please sign in to comment.