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,13 +5,14 @@ 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
while [ "$#" -gt 0 ]; do
if [ "$1" = "-o" ]; then if [ "$1" = "-o" ]; then
obj=$2 obj=$2
[[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/} [[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/}
@ -44,6 +45,24 @@ while [ "$#" -gt 0 ]; do
esac esac
fi fi
shift shift
done 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[@]}"