[LTP] [PATCH] Add KVM_LD Makefile variable for building KVM payload binaries

Richard Palethorpe rpalethorpe@suse.de
Tue Jul 26 11:30:50 CEST 2022


Hello,

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>

Martin Doucha <mdoucha@suse.cz> writes:

> KVM linker needs to be configurable for cross-compiling but some
> linkers don't support the linker script for wrapping arbitrary files
> into linkable resource files. Allow KVM linker to be changed
> independently of $LD via $KVM_LD.
>
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
>
> This should solve the issues with
> https://github.com/linux-test-project/ltp/pull/948
>
>  doc/build-system-guide.txt    | 5 +++++
>  testcases/kernel/kvm/Makefile | 5 +++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt
> index 166f7fb92..b8d267b4b 100644
> --- a/doc/build-system-guide.txt
> +++ b/doc/build-system-guide.txt
> @@ -145,6 +145,11 @@ $(CPPFLAGS)		: Preprocessor flags, e.g. -I arguments.
>  
>  $(DEBUG_CFLAGS)		: Debug flags to pass to $(CC), -g, etc.
>  
> +$(KVM_LD)		: Special linker for wrapping KVM payload binaries
> +			  into linkable object files. Defaults to $(LD).
> +			  Change this variable if the KVM Makefile fails
> +			  to build files named *-payload.o.
> +
>  $(LD)			: The system linker (typically $(CC), but not
>  			  necessarily).
>  
> diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
> index 22a840da6..6986844be 100644
> --- a/testcases/kernel/kvm/Makefile
> +++ b/testcases/kernel/kvm/Makefile
> @@ -11,6 +11,7 @@ GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD
>  GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse
>  GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -fno-stack-protector
>  GUEST_LDLIBS =
> +KVM_LD ?= $(LD)
>  
>  FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
>  
> @@ -53,11 +54,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk
>  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
> -	$(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-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
> -	@$(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-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
>  	@rm $*-payload.elf $*-payload.bin
> -- 
> 2.36.1


-- 
Thank you,
Richard.


More information about the ltp mailing list