The kernel/kvm test uses the host objcopy when building a payload, but the host objcopy might not know how to deal with target binaries:
CC testcases/kernel/kvm/lib_host.o objcopy: Unable to recognise the format of the input file `kvm_svm03-payload.elf' make[3]: *** [ltp/testcases/kernel/kvm/Makefile:67: kvm_svm03-payload.o] Error 1 Solve this by using the host-prefixed objcopy binary. Signed-off-by: Ross Burton <ross.bur...@arm.com> --- ...01-kernel-kvm-don-t-hardcode-objcopy.patch | 69 +++++++++++++++++++ meta/recipes-extended/ltp/ltp_20240930.bb | 1 + 2 files changed, 70 insertions(+) create mode 100644 meta/recipes-extended/ltp/ltp/0001-kernel-kvm-don-t-hardcode-objcopy.patch diff --git a/meta/recipes-extended/ltp/ltp/0001-kernel-kvm-don-t-hardcode-objcopy.patch b/meta/recipes-extended/ltp/ltp/0001-kernel-kvm-don-t-hardcode-objcopy.patch new file mode 100644 index 00000000000..256c8eaa341 --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0001-kernel-kvm-don-t-hardcode-objcopy.patch @@ -0,0 +1,69 @@ +From 0a42a8ee0ae8c6f1e603c1836b7c9c7fab0ca3a8 Mon Sep 17 00:00:00 2001 +From: Ross Burton <ross.bur...@arm.com> +Date: Thu, 27 Feb 2025 12:38:50 +0000 +Subject: [PATCH] kernel/kvm: don't hardcode objcopy + +testcases/kernel/kvm uses objcopy to contruct a payload binary, but in +cross builds the host objcopy may not know how to handle target +binaries: + + CC testcases/kernel/kvm/lib_host.o + objcopy: Unable to recognise the format of the input file `kvm_svm03-payload.elf' + make[3]: *** [ltp/testcases/kernel/kvm/Makefile:67: kvm_svm03-payload.o] Error 1 + +This is trivially fixed by searching for an objcopy tool (so +host-prefixed in cross builds) and using that instead. + +Upstream-Status: Backport [a3942c0a5f9b4463e8320e80cd8522a2e008bfd2] +Signed-off-by: Ross Burton <ross.bur...@arm.com> +--- + configure.ac | 1 + + include/mk/config.mk.in | 1 + + testcases/kernel/kvm/Makefile | 4 ++-- + 3 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 344b2ae2c..0f2b6f332 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -30,6 +30,7 @@ AC_PROG_RANLIB + AC_DEFUN([AC_PROG_STRIP], [AC_CHECK_TOOL(STRIP, strip, :)]) + AC_PROG_STRIP + AC_PROG_YACC ++AC_CHECK_TOOL([OBJCOPY], [objcopy], [:]) + + m4_ifndef([PKG_CHECK_EXISTS], + [m4_fatal([must install pkg-config or pkgconfig and pkg.m4 macro (usual dependency), see INSTALL])]) +diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in +index 2b7c8a071..4c3da304f 100644 +--- a/include/mk/config.mk.in ++++ b/include/mk/config.mk.in +@@ -11,6 +11,7 @@ AR := @AR@ + CC := @CC@ + LEX := @LEX@ + RANLIB := @RANLIB@ ++OBJCOPY := @OBJCOPY@ + STRIP := @STRIP@ + YACC := @YACC@ + +diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile +index 07bdd9705..e93528a33 100644 +--- a/testcases/kernel/kvm/Makefile ++++ b/testcases/kernel/kvm/Makefile +@@ -60,11 +60,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk + %-payload.o: %.c lib_guest.o $(ARCH_OBJ) + ifdef VERBOSE + $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) +- objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin ++ $(OBJCOPY) -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin + $(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin + else + @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) +- @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin ++ @$(OBJCOPY) -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin + @$(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin + @echo KVM_CC $(target_rel_dir)$@ + endif +-- +2.43.0 + diff --git a/meta/recipes-extended/ltp/ltp_20240930.bb b/meta/recipes-extended/ltp/ltp_20240930.bb index 0760170c7b0..c1cd157328f 100644 --- a/meta/recipes-extended/ltp/ltp_20240930.bb +++ b/meta/recipes-extended/ltp/ltp_20240930.bb @@ -30,6 +30,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=ht file://0001-Remove-OOM-tests-from-runtest-mm.patch \ file://0001-Add-__clear_cache-declaration-for-clang.patch \ file://0001-sched_attr-Do-not-define-for-glibc-2.41.patch \ + file://0001-kernel-kvm-don-t-hardcode-objcopy.patch \ " S = "${WORKDIR}/git" -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#212018): https://lists.openembedded.org/g/openembedded-core/message/212018 Mute This Topic: https://lists.openembedded.org/mt/111416872/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-