mirror of https://github.com/dynup/kpatch
fix compiler warnings, add -o flag
This commit is contained in:
parent
e9e4563a80
commit
fc12020ae3
|
@ -144,7 +144,6 @@ int kpatch_register(struct module *mod, void *kpatch_relas,
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int ret2;
|
int ret2;
|
||||||
struct kpatch_func *f, *g;
|
|
||||||
int num_relas;
|
int num_relas;
|
||||||
struct kpatch_rela *relas;
|
struct kpatch_rela *relas;
|
||||||
int i;
|
int i;
|
||||||
|
@ -179,7 +178,7 @@ int kpatch_register(struct module *mod, void *kpatch_relas,
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
printk("%p <- %lx\n", loc, val);
|
//printk("%p <- %lx\n", loc, val);
|
||||||
//printk("%lx\n", (unsigned long)__va(__pa((unsigned long)loc)));
|
//printk("%lx\n", (unsigned long)__va(__pa((unsigned long)loc)));
|
||||||
//loc = __va(__pa((unsigned long)loc));
|
//loc = __va(__pa((unsigned long)loc));
|
||||||
set_memory_rw((unsigned long)loc & PAGE_MASK, 1);
|
set_memory_rw((unsigned long)loc & PAGE_MASK, 1);
|
||||||
|
@ -290,6 +289,7 @@ out:
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(kpatch_register);
|
EXPORT_SYMBOL(kpatch_register);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Called from stop_machine */
|
/* Called from stop_machine */
|
||||||
static int kpatch_remove_patch(void *data)
|
static int kpatch_remove_patch(void *data)
|
||||||
{
|
{
|
||||||
|
@ -321,13 +321,14 @@ static int kpatch_remove_patch(void *data)
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int kpatch_unregister(struct module *mod)
|
int kpatch_unregister(struct module *mod)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
#if 0
|
||||||
struct kpatch_func *f;
|
struct kpatch_func *f;
|
||||||
|
|
||||||
#if 0
|
|
||||||
ret = stop_machine(kpatch_remove_patch, funcs, NULL);
|
ret = stop_machine(kpatch_remove_patch, funcs, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -350,9 +351,9 @@ int kpatch_unregister(struct module *mod)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(kpatch_unregister);
|
EXPORT_SYMBOL(kpatch_unregister);
|
||||||
|
|
|
@ -4,6 +4,8 @@ set -o nounset
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# TODO: log output to a file instead of /dev/null
|
||||||
|
|
||||||
CUR_DIR="$PWD"
|
CUR_DIR="$PWD"
|
||||||
SCRIPT="`basename $BASH_SOURCE`"
|
SCRIPT="`basename $BASH_SOURCE`"
|
||||||
SCRIPT_DIR="`dirname $BASH_SOURCE`"
|
SCRIPT_DIR="`dirname $BASH_SOURCE`"
|
||||||
|
@ -24,6 +26,13 @@ PROGRESS_FILE="kpatch-in-progress"
|
||||||
PATCHED=
|
PATCHED=
|
||||||
PATCH=
|
PATCH=
|
||||||
KERNEL_DIR=
|
KERNEL_DIR=
|
||||||
|
OUTPUT_DIR=
|
||||||
|
|
||||||
|
usage ()
|
||||||
|
{
|
||||||
|
echo "usage: $SCRIPT -p [PATCH] -k [KERNEL DIR] -o [OUTPUT DIR]" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
scriptecho ()
|
scriptecho ()
|
||||||
|
@ -45,12 +54,12 @@ cleanup ()
|
||||||
cleanup_objs
|
cleanup_objs
|
||||||
if [ $PATCHED ]; then
|
if [ $PATCHED ]; then
|
||||||
cd "$KERNEL_DIR"
|
cd "$KERNEL_DIR"
|
||||||
patch -p1 -R < "$PATCH"
|
patch -p1 -R < "$PATCH" > /dev/null
|
||||||
export CROSS_COMPILE="$KPATCHGCC "
|
export CROSS_COMPILE="$KPATCHGCC "
|
||||||
$MAKE_CMD > /dev/null
|
$MAKE_CMD > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#rm -rf "$TMPDIR"
|
rm -rf "$TMPDIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
die ()
|
die ()
|
||||||
|
@ -59,27 +68,24 @@ die ()
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
usage ()
|
while getopts "p:k:o:" arg; do
|
||||||
{
|
|
||||||
echo "usage: $SCRIPT -p [patch] -k [KERNEL_DIR]" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts "p:k:" arg; do
|
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
p) PATCH="$OPTARG" ;;
|
p) PATCH="$OPTARG" ;;
|
||||||
k) KERNEL_DIR="$OPTARG" ;;
|
k) KERNEL_DIR="$OPTARG" ;;
|
||||||
|
o) OUTPUT_DIR="$OPTARG" ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[ ! "$PATCH" ] || [ ! "$KERNEL_DIR" ] && usage
|
[ ! "$PATCH" ] || [ ! "$KERNEL_DIR" ] || [ ! "$OUTPUT_DIR" ] && usage
|
||||||
|
|
||||||
[ ! -f "$PATCH" ] && die "$PATCH doesn't exist"
|
[ ! -f "$PATCH" ] && die "$PATCH doesn't exist"
|
||||||
[ ! -d "$KERNEL_DIR" ] && die "$KERNEL_DIR doesn't exist"
|
[ ! -d "$KERNEL_DIR" ] && die "$KERNEL_DIR doesn't exist"
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
PATCH="`readlink -f \"$PATCH\"`"
|
PATCH="`readlink -f \"$PATCH\"`"
|
||||||
KERNEL_DIR="`readlink -f \"$KERNEL_DIR\"`"
|
KERNEL_DIR="`readlink -f \"$KERNEL_DIR\"`"
|
||||||
|
OUTPUT_DIR="`readlink -f \"$OUTPUT_DIR\"`"
|
||||||
|
|
||||||
TMPDIR="`mktemp -d`"
|
TMPDIR="`mktemp -d`"
|
||||||
trap cleanup exit
|
trap cleanup exit
|
||||||
|
@ -92,7 +98,7 @@ $MAKE_CMD > /dev/null
|
||||||
cp vmlinux vmlinux.orig_kpatch
|
cp vmlinux vmlinux.orig_kpatch
|
||||||
|
|
||||||
scriptecho "patching kernel"
|
scriptecho "patching kernel"
|
||||||
patch -p1 < "$PATCH"
|
patch -p1 < "$PATCH" > /dev/null
|
||||||
PATCHED=1
|
PATCHED=1
|
||||||
|
|
||||||
scriptecho "compiling patched kernel"
|
scriptecho "compiling patched kernel"
|
||||||
|
@ -115,12 +121,14 @@ done
|
||||||
unset CROSS_COMPILE
|
unset CROSS_COMPILE
|
||||||
cp -a "$KMOD_DIR" "$TMPDIR/kmod"
|
cp -a "$KMOD_DIR" "$TMPDIR/kmod"
|
||||||
|
|
||||||
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch-patch-hook.o
|
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch-patch-hook.o > /dev/null
|
||||||
|
|
||||||
cd $TMPDIR/kmod
|
cd $TMPDIR/kmod
|
||||||
find "$KERNEL_DIR" -name "*.kpatch_gen" -exec ld -m elf_x86_64 -r -o kpatch-patch-foo.o kpatch-patch-hook.o kpatch.lds {} +
|
find "$KERNEL_DIR" -name "*.kpatch_gen" -exec ld -m elf_x86_64 -r -o kpatch-patch-foo.o kpatch-patch-hook.o kpatch.lds {} +
|
||||||
|
|
||||||
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch.ko
|
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch.ko > /dev/null
|
||||||
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch-patch.ko
|
make -C "$KERNEL_DIR" M="$TMPDIR/kmod" kpatch-patch.ko > /dev/null
|
||||||
|
|
||||||
scriptecho success
|
cp kpatch.ko kpatch-patch.ko "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
scriptecho Success!
|
||||||
|
|
Loading…
Reference in New Issue