From 764a57b1756dffba9bf7c990f752dbd739ea149f Mon Sep 17 00:00:00 2001
From: Song Liu <song@kernel.org>
Date: Mon, 6 Mar 2023 22:43:43 -0800
Subject: [PATCH 106/107] kpatch-build: Run objtool on thinlto files
In this way, CDO should generate patches with required sections, such as
the .orc sections.
Signed-off-by: Song Liu <song@kernel.org>
---
kpatch-build/kpatch-build | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index fc9f92b..938e88f 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -1212,6 +1212,9 @@ fi
if [[ -n "$CONFIG_LTO_CLANG" ]]; then
DIFF_OBJS="$TEMPDIR/thinlto_objs"
+
+ # Get the objtool command line, so we can run it on the thinlto files
+ OBJTOOL_CMD=$(grep -o -e "/tools/objtool/objtool .*" "$BUILDDIR"/.vmlinux.o.cmd | sed 's/vmlinux.o//')
else
DIFF_OBJS="$TEMPDIR/changed_objs"
fi
@@ -1314,6 +1317,13 @@ for i in $FILES; do
# skip .thinlto file without any functions
num_func=$("$READELF" --symbols "orig/$i" | grep -c FUNC)
[[ $num_func -eq 0 ]] && continue
+ if [[ $i = vmlinux.o.* ]] ; then
+ eval "$BUILDDIR/$OBJTOOL_CMD orig/$i"
+ eval "$BUILDDIR/$OBJTOOL_CMD patched/$i"
+ else
+ eval "$BUILDDIR/$OBJTOOL_CMD --module orig/$i"
+ eval "$BUILDDIR/$OBJTOOL_CMD --module patched/$i"
+ fi
fi
# create-diff-object orig.o patched.o parent-name parent-symtab
--
2.37.3