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