2014-08-07 20:33:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
TOOLCHAINCMD="$1"
|
|
|
|
shift
|
|
|
|
|
2016-07-22 13:30:11 +00:00
|
|
|
if [[ -z "$KPATCH_GCC_TEMPDIR" ]]; then
|
2014-08-07 20:33:31 +00:00
|
|
|
exec "$TOOLCHAINCMD" "$@"
|
|
|
|
fi
|
|
|
|
|
2014-09-15 03:55:29 +00:00
|
|
|
declare -a args=("$@")
|
2014-08-07 20:33:31 +00:00
|
|
|
|
2014-10-05 14:45:45 +00:00
|
|
|
if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
if [ "$1" = "-o" ]; then
|
|
|
|
obj=$2
|
2017-07-26 05:46:53 +00:00
|
|
|
# skip copying the original .o files, when .tmp_mc_*.o
|
|
|
|
# is passed from recordmcount.pl.
|
|
|
|
[[ $obj = */.tmp_mc_*.o ]] && break;
|
|
|
|
[[ $obj = */.tmp_*.o ]] && obj=${obj/.tmp_/}
|
2014-10-05 14:45:45 +00:00
|
|
|
case "$obj" in
|
|
|
|
*.mod.o|\
|
|
|
|
*built-in.o|\
|
|
|
|
vmlinux.o|\
|
|
|
|
.tmp_kallsyms1.o|\
|
|
|
|
.tmp_kallsyms2.o|\
|
|
|
|
init/version.o|\
|
|
|
|
arch/x86/boot/version.o|\
|
|
|
|
arch/x86/boot/compressed/eboot.o|\
|
|
|
|
arch/x86/boot/header.o|\
|
|
|
|
arch/x86/boot/compressed/efi_stub_64.o|\
|
|
|
|
arch/x86/boot/compressed/piggy.o|\
|
|
|
|
kernel/system_certificates.o|\
|
|
|
|
arch/x86/vdso/*|\
|
2015-10-28 16:26:08 +00:00
|
|
|
arch/x86/entry/vdso/*|\
|
2015-10-28 16:39:55 +00:00
|
|
|
drivers/firmware/efi/libstub/*|\
|
2017-07-26 05:46:53 +00:00
|
|
|
arch/powerpc/kernel/prom_init.o|\
|
2017-03-10 15:26:06 +00:00
|
|
|
*.*.o)
|
2014-10-05 14:45:45 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*.o)
|
2016-07-22 13:30:11 +00:00
|
|
|
mkdir -p "$KPATCH_GCC_TEMPDIR/orig/$(dirname $obj)"
|
|
|
|
[[ -e $obj ]] && cp -f "$obj" "$KPATCH_GCC_TEMPDIR/orig/$obj"
|
|
|
|
echo "$obj" >> "$KPATCH_GCC_TEMPDIR/changed_objs"
|
2014-10-05 14:45:45 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
elif [[ "$TOOLCHAINCMD" = "ld" ]] ; then
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
if [ "$1" = "-o" ]; then
|
|
|
|
obj=$2
|
|
|
|
case "$obj" in
|
|
|
|
*.ko)
|
2016-07-22 13:30:11 +00:00
|
|
|
mkdir -p "$KPATCH_GCC_TEMPDIR/module/$(dirname $obj)"
|
|
|
|
cp -f "$obj" "$KPATCH_GCC_TEMPDIR/module/$obj"
|
2014-10-05 14:45:45 +00:00
|
|
|
break
|
|
|
|
;;
|
2016-12-06 02:12:49 +00:00
|
|
|
.tmp_vmlinux*|vmlinux)
|
|
|
|
args+=(--warn-unresolved-symbols)
|
|
|
|
break
|
|
|
|
;;
|
2014-10-05 14:45:45 +00:00
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
fi
|
2014-08-07 20:33:31 +00:00
|
|
|
|
|
|
|
exec "$TOOLCHAINCMD" "${args[@]}"
|