Skip to content

Commit a3942c0

Browse files
rossburtonpevik
authored andcommitted
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. Link: https://lore.kernel.org/ltp/20250227124330.949015-1-ross.burton@arm.com/ Reviewed-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Ross Burton <ross.burton@arm.com>
1 parent 49607b4 commit a3942c0

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ AC_PROG_RANLIB
3030
AC_DEFUN([AC_PROG_STRIP], [AC_CHECK_TOOL(STRIP, strip, :)])
3131
AC_PROG_STRIP
3232
AC_PROG_YACC
33+
AC_CHECK_TOOL([OBJCOPY], [objcopy], [:])
3334

3435
m4_ifndef([PKG_CHECK_EXISTS],
3536
[m4_fatal([must install pkg-config or pkgconfig and pkg.m4 macro (usual dependency), see INSTALL])])

include/mk/config.mk.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AR := @AR@
1111
CC := @CC@
1212
LEX := @LEX@
1313
RANLIB := @RANLIB@
14+
OBJCOPY := @OBJCOPY@
1415
STRIP := @STRIP@
1516
YACC := @YACC@
1617

testcases/kernel/kvm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk
6060
%-payload.o: %.c lib_guest.o $(ARCH_OBJ)
6161
ifdef VERBOSE
6262
$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
63-
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
63+
$(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
6464
$(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
6565
else
6666
@$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS)
67-
@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
67+
@$(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
6868
@$(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin
6969
@echo KVM_CC $(target_rel_dir)$@
7070
endif

0 commit comments

Comments
 (0)