[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.9] x86/efi: move the logic to detect PE build support



commit 6000494136c9f269895605af519c6b2a7caec4a1
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Mon Oct 8 14:46:08 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Oct 8 14:46:08 2018 +0200

    x86/efi: move the logic to detect PE build support
    
    So that it can be used by other components apart from the efi specific
    code. By moving the detection code creating a dummy efi/disabled file
    can be avoided.
    
    This is required so that the conditional used to define the efi symbol
    in the linker script can be removed and instead the definition of the
    efi symbol can be guarded using the preprocessor.
    
    The motivation behind this change is to be able to build Xen using lld
    (the LLVM linker), that at least on version 6.0.0 doesn't work
    properly with a DEFINED being used in a conditional expression:
    
    ld    -melf_x86_64_fbsd  -T xen.lds -N prelink.o --build-id=sha1 \
        /root/src/xen/xen/common/symbols-dummy.o -o 
/root/src/xen/xen/.xen-syms.0
    ld: error: xen.lds:233: symbol not found: efi
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Tested-by: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
    master commit: 18cd4997d26b9df95dda87503e41c823279a07a0
    master date: 2018-07-31 10:24:22 +0200
---
 .gitignore                |  1 -
 xen/arch/x86/Makefile     |  9 +++++++--
 xen/arch/x86/efi/Makefile | 11 +++--------
 xen/arch/x86/xen.lds.S    |  4 +++-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index d6e0844b2f..5e82f5807f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -279,7 +279,6 @@ xen/arch/x86/boot/*.bin
 xen/arch/x86/boot/*.lnk
 xen/arch/x86/efi.lds
 xen/arch/x86/efi/check.efi
-xen/arch/x86/efi/disabled
 xen/arch/x86/efi/mkreloc
 xen/arch/*/efi/boot.c
 xen/arch/*/efi/compat.c
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 1ecf4baeb6..54ba8137ee 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -159,10 +159,15 @@ EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)
 EFI_LDFLAGS += --major-os-version=2 --minor-os-version=0
 EFI_LDFLAGS += --major-subsystem-version=2 --minor-subsystem-version=0
 
+# Check if the build system supports PE.
+XEN_BUILD_PE := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 
efi/check.c -o efi/check.o 2>/dev/null && echo y)
+export XEN_BUILD_PE := $(if $(XEN_BUILD_PE),$(shell $(LD) -mi386pep 
--subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y))
+CFLAGS-$(XEN_BUILD_PE) += -DXEN_BUILD_PE
+
 $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A 
VIRT_START$$,,p')
 $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A 
ALT_START$$,,p')
 # Don't use $(wildcard ...) here - at least make 3.80 expands this too early!
-$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)
+$(TARGET).efi: guard = $(if $(filter y,$(XEN_BUILD_PE)),,:)
 
 ifneq ($(build_id_linker),)
 ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
@@ -224,6 +229,6 @@ efi/mkreloc: efi/mkreloc.c
 clean::
        rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32
        rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d
-       rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/disabled efi/mkreloc
+       rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/mkreloc
        rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin
        rm -f note.o
diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
index 3edff1cf24..6adce38e50 100644
--- a/xen/arch/x86/efi/Makefile
+++ b/xen/arch/x86/efi/Makefile
@@ -1,16 +1,11 @@
 CFLAGS += -fshort-wchar
 
-efi := y$(shell rm -f disabled)
-efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 
check.c 2>disabled && echo y))
-efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o check.efi check.o 
2>disabled && echo y))
-efi := $(if $(efi),$(shell rm disabled)y)
-
 %.o: %.ihex
        $(OBJCOPY) -I ihex -O binary $< $@
 
 boot.init.o: buildid.o
 
 obj-y := stub.o
-obj-$(efi) := boot.init.o compat.o relocs-dummy.o runtime.o
-extra-$(efi) += buildid.o
-nogcov-$(efi) += stub.o
+obj-$(XEN_BUILD_PE) := boot.init.o compat.o relocs-dummy.o runtime.o
+extra-$(XEN_BUILD_PE) += buildid.o
+nogcov-$(XEN_BUILD_PE) += stub.o
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 48673c46aa..a9722615ca 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -279,7 +279,9 @@ SECTIONS
   } :text
 #endif
 
-  efi = DEFINED(efi) ? efi : .;
+#ifndef XEN_BUILD_PE
+  efi = .;
+#endif
 
   /* Sections to be discarded */
   /DISCARD/ : {
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.9

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.