Blob Blame History Raw
From 7861240f482aa41bfad41fbb57ac1990cd6b6960 Mon Sep 17 00:00:00 2001
From: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Wed, 17 Aug 2022 12:17:19 -0700
Subject: [PATCH 105/108] kpatch-build: Add find_kobj() short-circuit for OOT
 modules

When patching an OOT module, the parent object is always the OOT module.
Hard-code that to prevent the need for any further special casing in
find_kobj() (e.g., commit 9143e88f16a1 ("kpatch-build: fix
find_parent_obj")).

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 kpatch-build/kpatch-build | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 296fa48..5435a19 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -479,6 +479,12 @@ find_parent_obj() {
 
 find_kobj() {
 	arg="$1"
+
+	if [[ -n $OOT_MODULE ]]; then
+		KOBJFILE="$OOT_MODULE"
+		return
+	fi
+
 	KOBJFILE="$arg"
 	DEEP_FIND=0
 	ERROR_IF_DIFF=
@@ -1093,17 +1099,17 @@ for i in $FILES; do
 	find_kobj "$i"
 	cd "$TEMPDIR" || die
 	if [[ -e "orig/$i" ]]; then
-		if [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
-			KOBJFILE_NAME=vmlinux
-			KOBJFILE_PATH="$VMLINUX"
-			SYMTAB="${TEMPDIR}/${KOBJFILE_NAME}.symtab"
-			SYMVERS_FILE="$BUILDDIR/Module.symvers"
-		elif [[ "$(basename "$KOBJFILE")" = "$(basename "$OOT_MODULE")" ]]; then
+		if [[ -n $OOT_MODULE ]]; then
 			KOBJFILE_NAME="$(basename --suffix=.ko "$OOT_MODULE")"
 			KOBJFILE_NAME="${KOBJFILE_NAME//-/_}"
 			KOBJFILE_PATH="$OOT_MODULE"
 			SYMTAB="${TEMPDIR}/module/${KOBJFILE_NAME}.symtab"
 			SYMVERS_FILE="$TEMPDIR/Module.symvers"
+		elif [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
+			KOBJFILE_NAME=vmlinux
+			KOBJFILE_PATH="$VMLINUX"
+			SYMTAB="${TEMPDIR}/${KOBJFILE_NAME}.symtab"
+			SYMVERS_FILE="$BUILDDIR/Module.symvers"
 		else
 			KOBJFILE_NAME=$(basename "${KOBJFILE%.ko}")
 			KOBJFILE_NAME="${KOBJFILE_NAME//-/_}"
-- 
2.37.3