kpatch-gcc: for module patches, copy module to temp dir

For patches involving modules, copy the original module(s) to
TEMPDIR so that create-diff-object can create the correct lookup
tables
This commit is contained in:
Jessica Yu 2014-10-05 07:45:45 -07:00
parent 6175658196
commit 09c39932b1
2 changed files with 55 additions and 36 deletions

View File

@ -475,7 +475,7 @@ for i in $FILES; do
if [[ $KOBJFILE = vmlinux ]]; then if [[ $KOBJFILE = vmlinux ]]; then
KOBJFILE=$VMLINUX KOBJFILE=$VMLINUX
else else
KOBJFILE="$(readlink -f $KOBJFILE)" KOBJFILE="$TEMPDIR/module/$KOBJFILE"
fi fi
cd $TEMPDIR cd $TEMPDIR
debugopt= debugopt=

View File

@ -5,45 +5,64 @@ set -x
TOOLCHAINCMD="$1" TOOLCHAINCMD="$1"
shift shift
if [[ "$TOOLCHAINCMD" != "gcc" ]] || [[ -z "$TEMPDIR" ]]; then if [[ -z "$TEMPDIR" ]]; then
exec "$TOOLCHAINCMD" "$@" exec "$TOOLCHAINCMD" "$@"
fi fi
declare -a args=("$@") declare -a args=("$@")
while [ "$#" -gt 0 ]; do if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then
if [ "$1" = "-o" ]; then while [ "$#" -gt 0 ]; do
obj=$2 if [ "$1" = "-o" ]; then
[[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/} obj=$2
case "$obj" in [[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/}
*.mod.o|\ case "$obj" in
*built-in.o|\ *.mod.o|\
vmlinux.o|\ *built-in.o|\
.tmp_kallsyms1.o|\ vmlinux.o|\
.tmp_kallsyms2.o|\ .tmp_kallsyms1.o|\
init/version.o|\ .tmp_kallsyms2.o|\
arch/x86/boot/version.o|\ init/version.o|\
arch/x86/boot/compressed/eboot.o|\ arch/x86/boot/version.o|\
arch/x86/boot/header.o|\ arch/x86/boot/compressed/eboot.o|\
arch/x86/boot/compressed/efi_stub_64.o|\ arch/x86/boot/header.o|\
arch/x86/boot/compressed/piggy.o|\ arch/x86/boot/compressed/efi_stub_64.o|\
kernel/system_certificates.o|\ arch/x86/boot/compressed/piggy.o|\
arch/x86/vdso/*|\ kernel/system_certificates.o|\
.*.o) arch/x86/vdso/*|\
break .*.o)
;; break
*.o) ;;
mkdir -p "$TEMPDIR/orig/$(dirname $obj)" *.o)
cp -f "$obj" "$TEMPDIR/orig/$obj" mkdir -p "$TEMPDIR/orig/$(dirname $obj)"
echo "$obj" >> "$TEMPDIR/changed_objs" cp -f "$obj" "$TEMPDIR/orig/$obj"
break echo "$obj" >> "$TEMPDIR/changed_objs"
;; break
*) ;;
break *)
;; break
esac ;;
fi esac
shift fi
done shift
done
elif [[ "$TOOLCHAINCMD" = "ld" ]] ; then
while [ "$#" -gt 0 ]; do
if [ "$1" = "-o" ]; then
obj=$2
case "$obj" in
*.ko)
mkdir -p "$TEMPDIR/module/$(dirname $obj)"
cp -f "$obj" "$TEMPDIR/module/$obj"
break
;;
*)
break
;;
esac
fi
shift
done
fi
exec "$TOOLCHAINCMD" "${args[@]}" exec "$TOOLCHAINCMD" "${args[@]}"