Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame^] | 1 | From a8d41b7937a34904611011ca357f8db880d42270 Mon Sep 17 00:00:00 2001 |
| 2 | From: Martin Doucha <mdoucha@suse.cz> |
| 3 | Date: Mon, 25 Jul 2022 17:37:27 +0200 |
| 4 | Subject: [PATCH] Add KVM_LD Makefile variable for building KVM payload |
| 5 | binaries |
| 6 | |
| 7 | KVM linker needs to be configurable for cross-compiling but some |
| 8 | linkers don't support the linker script for wrapping arbitrary files |
| 9 | into linkable resource files. Allow KVM linker to be changed |
| 10 | independently of $LD via $KVM_LD. |
| 11 | |
| 12 | Signed-off-by: Martin Doucha <mdoucha@suse.cz> |
| 13 | Acked-by: Richard Palethorpe <rpalethorpe@suse.com> |
| 14 | |
| 15 | Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/5ef0b7892a17b64040e55e9ad62d36ebb75d33fd] |
| 16 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 17 | --- |
| 18 | doc/build-system-guide.txt | 5 +++++ |
| 19 | testcases/kernel/kvm/Makefile | 5 +++-- |
| 20 | 2 files changed, 8 insertions(+), 2 deletions(-) |
| 21 | |
| 22 | diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt |
| 23 | index 166f7fb92..b8d267b4b 100644 |
| 24 | --- a/doc/build-system-guide.txt |
| 25 | +++ b/doc/build-system-guide.txt |
| 26 | @@ -145,6 +145,11 @@ $(CPPFLAGS) : Preprocessor flags, e.g. -I arguments. |
| 27 | |
| 28 | $(DEBUG_CFLAGS) : Debug flags to pass to $(CC), -g, etc. |
| 29 | |
| 30 | +$(KVM_LD) : Special linker for wrapping KVM payload binaries |
| 31 | + into linkable object files. Defaults to $(LD). |
| 32 | + Change this variable if the KVM Makefile fails |
| 33 | + to build files named *-payload.o. |
| 34 | + |
| 35 | $(LD) : The system linker (typically $(CC), but not |
| 36 | necessarily). |
| 37 | |
| 38 | diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile |
| 39 | index d67230735..31f144c26 100644 |
| 40 | --- a/testcases/kernel/kvm/Makefile |
| 41 | +++ b/testcases/kernel/kvm/Makefile |
| 42 | @@ -11,6 +11,7 @@ GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD |
| 43 | GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse |
| 44 | GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none |
| 45 | GUEST_LDLIBS = |
| 46 | +KVM_LD ?= $(LD) |
| 47 | |
| 48 | FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86 |
| 49 | |
| 50 | @@ -50,11 +51,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk |
| 51 | ifdef VERBOSE |
| 52 | $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) |
| 53 | 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 |
| 54 | - $(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
| 55 | + $(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
| 56 | else |
| 57 | @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) |
| 58 | @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 |
| 59 | - @$(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
| 60 | + @$(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
| 61 | @echo KVM_CC $(target_rel_dir)$@ |
| 62 | endif |
| 63 | @rm $*-payload.elf $*-payload.bin |