kpatch/kpatch-build/kpatch-gcc
Josh Poimboeuf 7b4ee86197 kpatch-gcc: fix for .tmp_* objects on RHEL 7
On RHEL 7 I see the following error when trying to patch meminfo.o:

    cp: cannot stat ‘/home/user/.kpatch/obj/fs/proc/.tmp_meminfo.o’: No such file or directory

It turns out that on RHEL 7, a given object foo.o is compiled as
.tmp_foo.o before then being linked as foo.o.  I have no idea why.  The
fix is to record .tmp_foo.o as foo.o in the changed_objs file.
2014-08-12 21:21:53 -05:00

49 lines
852 B
Bash
Executable File

#!/bin/bash
set -x
TOOLCHAINCMD="$1"
shift
if [[ "$TOOLCHAINCMD" != "gcc" ]] || [[ -z "$TEMPDIR" ]]; then
exec "$TOOLCHAINCMD" "$@"
fi
declare -a args=($@)
while [ "$#" -gt 0 ]; do
if [ "$1" = "-o" ]; then
obj=$2
[[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/}
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|\
.*.o)
break
;;
*.o)
mkdir -p "$TEMPDIR/orig/$(dirname $obj)"
cp -f "$obj" "$TEMPDIR/orig/$obj"
echo "$obj" >> "$TEMPDIR/changed_objs"
break
;;
*)
break
;;
esac
fi
shift
done
exec "$TOOLCHAINCMD" "${args[@]}"