2014-08-07 20:33:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-11-16 12:38:22 +00:00
|
|
|
if [[ ${KPATCH_GCC_DEBUG:-0} -ne 0 ]]; then
|
|
|
|
set -o xtrace
|
|
|
|
fi
|
2014-08-07 20:33:31 +00:00
|
|
|
|
|
|
|
TOOLCHAINCMD="$1"
|
|
|
|
shift
|
|
|
|
|
2016-07-22 13:30:11 +00:00
|
|
|
if [[ -z "$KPATCH_GCC_TEMPDIR" ]]; then
|
2017-11-08 16:42:38 +00:00
|
|
|
exec "$TOOLCHAINCMD" "$@"
|
2014-08-07 20:33:31 +00:00
|
|
|
fi
|
|
|
|
|
2014-09-15 03:55:29 +00:00
|
|
|
declare -a args=("$@")
|
2014-08-07 20:33:31 +00:00
|
|
|
|
2021-01-27 10:41:49 +00:00
|
|
|
if [[ "$TOOLCHAINCMD" =~ ^(.*-)?gcc$ || "$TOOLCHAINCMD" =~ ^(.*-)?clang$ ]] ; then
|
2014-10-05 14:45:45 +00:00
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
if [ "$1" = "-o" ]; then
|
2017-09-21 18:46:20 +00:00
|
|
|
obj="$2"
|
2017-07-25 16:38:48 +00:00
|
|
|
|
|
|
|
# skip copying the temporary .o files created by
|
|
|
|
# recordmcount.pl
|
2017-09-21 18:46:20 +00:00
|
|
|
[[ "$obj" = */.tmp_mc_*.o ]] && break;
|
2017-07-25 16:38:48 +00:00
|
|
|
|
2017-09-21 18:46:20 +00:00
|
|
|
[[ "$obj" = */.tmp_*.o ]] && obj="${obj/.tmp_/}"
|
2022-12-01 03:04:23 +00:00
|
|
|
relobj=${obj##"$KPATCH_GCC_SRCDIR"/}
|
2019-02-14 20:03:20 +00:00
|
|
|
case "$relobj" in
|
2014-10-05 14:45:45 +00:00
|
|
|
*.mod.o|\
|
|
|
|
*built-in.o|\
|
2018-03-20 09:46:50 +00:00
|
|
|
*built-in.a|\
|
2014-10-05 14:45:45 +00:00
|
|
|
vmlinux.o|\
|
|
|
|
.tmp_kallsyms1.o|\
|
|
|
|
.tmp_kallsyms2.o|\
|
2022-08-17 19:10:39 +00:00
|
|
|
arch/x86/boot/*|\
|
2015-10-28 16:26:08 +00:00
|
|
|
arch/x86/entry/vdso/*|\
|
2022-08-17 19:10:39 +00:00
|
|
|
arch/x86/purgatory/*|\
|
|
|
|
arch/x86/realmode/*|\
|
|
|
|
arch/x86/tools/*|\
|
|
|
|
arch/x86/vdso/*|\
|
2017-07-26 05:46:53 +00:00
|
|
|
arch/powerpc/kernel/prom_init.o|\
|
2021-01-20 05:56:48 +00:00
|
|
|
arch/powerpc/kernel/vdso64/*|\
|
2022-03-29 08:20:41 +00:00
|
|
|
arch/s390/boot/*|\
|
|
|
|
arch/s390/purgatory/*|\
|
|
|
|
arch/s390/kernel/vdso64/*|\
|
2022-08-17 19:10:39 +00:00
|
|
|
drivers/firmware/efi/libstub/*|\
|
|
|
|
init/version.o|\
|
2023-01-16 14:33:55 +00:00
|
|
|
init/version-timestamp.o|\
|
2022-08-17 19:10:39 +00:00
|
|
|
kernel/system_certificates.o|\
|
2018-06-11 15:38:31 +00:00
|
|
|
lib/*|\
|
2022-08-17 19:10:39 +00:00
|
|
|
tools/*|\
|
2017-09-13 07:08:45 +00:00
|
|
|
.*.o|\
|
|
|
|
*/.lib_exports.o)
|
2014-10-05 14:45:45 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*.o)
|
2018-10-23 21:25:19 +00:00
|
|
|
mkdir -p "$KPATCH_GCC_TEMPDIR/orig/$(dirname "$relobj")"
|
|
|
|
[[ -e "$obj" ]] && cp -f "$obj" "$KPATCH_GCC_TEMPDIR/orig/$relobj"
|
|
|
|
echo "$relobj" >> "$KPATCH_GCC_TEMPDIR/changed_objs"
|
2014-10-05 14:45:45 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
2021-01-27 10:41:49 +00:00
|
|
|
elif [[ "$TOOLCHAINCMD" =~ ^(.*-)?ld || "$TOOLCHAINCMD" =~ ^(.*-)?ld.lld ]] ; then
|
2014-10-05 14:45:45 +00:00
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
if [ "$1" = "-o" ]; then
|
2017-09-21 18:46:20 +00:00
|
|
|
obj="$2"
|
2018-10-23 21:25:19 +00:00
|
|
|
relobj=${obj//$KPATCH_GCC_SRCDIR\//}
|
2014-10-05 14:45:45 +00:00
|
|
|
case "$obj" in
|
|
|
|
*.ko)
|
2018-10-23 21:25:19 +00:00
|
|
|
mkdir -p "$KPATCH_GCC_TEMPDIR/module/$(dirname "$relobj")"
|
|
|
|
cp -f "$obj" "$KPATCH_GCC_TEMPDIR/module/$relobj"
|
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[@]}"
|