Skip to content

Commit 78c268f

Browse files
committed
livepatch/klp-build: Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL
When building a patch to a single-file kernel module with CONFIG_MODULE_SRCVERSION_ALL enabled, the klp-build module link fails in modpost: Diffing objects drivers/md/raid0.o: changed function: raid0_run Building patch module: livepatch-0001-patch-raid0_run.ko drivers/md/raid0.c: No such file or directory ... The problem here is that klp-build copied drivers/md/.raid0.o.cmd to the module build directory, but it didn't also copy over the input source file listed in the .cmd file: source_drivers/md/raid0.o := drivers/md/raid0.c So modpost dies due to the missing .c file which is needed for calculating checksums for CONFIG_MODULE_SRCVERSION_ALL. Instead of copying the original .cmd file, just create an empty one. Modpost only requires that it exists. The original object's build dependencies are irrelevant for the frankenobjects used by klp-build. Fixes: 24ebfcd ("livepatch/klp-build: Introduce klp-build script for generating livepatch modules") Reported-by: Song Liu <song@kernel.org> Tested-by: Song Liu <song@kernel.org> Link: https://patch.msgid.link/c41b6629e02775e4c1015259aa36065b3fe2f0f3.1769471792.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
1 parent f2dba60 commit 78c268f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

scripts/livepatch/klp-build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,11 @@ copy_orig_objects() {
555555
local file_dir="$(dirname "$file")"
556556
local orig_file="$ORIG_DIR/$rel_file"
557557
local orig_dir="$(dirname "$orig_file")"
558-
local cmd_file="$file_dir/.$(basename "$file").cmd"
559558

560559
[[ ! -f "$file" ]] && die "missing $(basename "$file") for $_file"
561560

562561
mkdir -p "$orig_dir"
563562
cp -f "$file" "$orig_dir"
564-
[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$orig_dir"
565563
done
566564
xtrace_restore
567565

@@ -740,15 +738,17 @@ build_patch_module() {
740738
local orig_dir="$(dirname "$orig_file")"
741739
local kmod_file="$KMOD_DIR/$rel_file"
742740
local kmod_dir="$(dirname "$kmod_file")"
743-
local cmd_file="$orig_dir/.$(basename "$file").cmd"
741+
local cmd_file="$kmod_dir/.$(basename "$file").cmd"
744742

745743
mkdir -p "$kmod_dir"
746744
cp -f "$file" "$kmod_dir"
747-
[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$kmod_dir"
748745

749746
# Tell kbuild this is a prebuilt object
750747
cp -f "$file" "${kmod_file}_shipped"
751748

749+
# Make modpost happy
750+
touch "$cmd_file"
751+
752752
echo -n " $rel_file" >> "$makefile"
753753
done
754754

0 commit comments

Comments
 (0)