| From a8d41b7937a34904611011ca357f8db880d42270 Mon Sep 17 00:00:00 2001 |
| From: Martin Doucha <mdoucha@suse.cz> |
| Date: Mon, 25 Jul 2022 17:37:27 +0200 |
| Subject: [PATCH] Add KVM_LD Makefile variable for building KVM payload |
| binaries |
| |
| 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> |
| Acked-by: Richard Palethorpe <rpalethorpe@suse.com> |
| |
| Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/5ef0b7892a17b64040e55e9ad62d36ebb75d33fd] |
| Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| --- |
| 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 d67230735..31f144c26 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 |
| GUEST_LDLIBS = |
| +KVM_LD ?= $(LD) |
| |
| FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86 |
| |
| @@ -50,11 +51,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 |