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

Re: [Minios-devel] [UNIKRAFT PATCH v3 1/4] build: make all linker scripts preprocessable



I was at first a bit unsure of this solution (why use preprocessor macros instead of the linker's built-in INCLUDE directives?), but I came around and now kinda like the flexibility that this gives to you. For example, I experimented already with replacing some of the alignment "magic numbers" by defines such as __PAGE_SIZE, and those will become part of a patch series I'll send out later.

The only thing I'm missing from this patch is support for linuxu, but linuxu is a bit special and would need other handling, so we could fix that at a later point.

Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>

On 5/15/19 3:53 PM, Yuri Volchkov wrote:
This will allow to apply some code de-duplication, and makes build
system a little bit homogeneous against linker scripts

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
  plat/kvm/Linker.uk                        |  4 ++--
  plat/kvm/Makefile.uk                      |  3 ++-
  plat/kvm/x86/{link64.lds => link64.lds.S} |  0
  plat/xen/Linker.uk                        | 13 ++-----------
  plat/xen/Makefile.uk                      |  3 +++
  plat/xen/arm/{link32.lds => link32.lds.S} |  0
  plat/xen/x86/{link64.lds => link64.lds.S} |  0
  7 files changed, 9 insertions(+), 14 deletions(-)
  rename plat/kvm/x86/{link64.lds => link64.lds.S} (100%)
  rename plat/xen/arm/{link32.lds => link32.lds.S} (100%)
  rename plat/xen/x86/{link64.lds => link64.lds.S} (100%)

diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
index 52ae61b9..8ed25260 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker.uk
@@ -1,11 +1,11 @@
  ifeq (x86_64,$(CONFIG_UK_ARCH))
-KVM_LDSCRIPT  := $(CONFIG_UK_BASE)/plat/kvm/x86/link64.lds
  KVM_LDFLAGS-y += -Wl,-m,elf_x86_64
  else ifeq (arm64,$(CONFIG_UK_ARCH))
  KVM_LDFLAGS-y  += -Wl,-m,aarch64elf
-KVM_LDSCRIPT     := $(call src2lds,libkvmplat,$(KVM_LDSCRIPT_SRC))
  endif
+KVM_LDSCRIPT := $(call src2lds,libkvmplat,$(KVM_LDSCRIPT_SRC-y))
+
  ##
  ## Link image
  ##
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index b9a93a11..633348ab 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -26,6 +26,7 @@ LIBKVMPLAT_CXXFLAGS            += -DKVMPLAT
  ##
  ## Architecture library definitions for x86_64
  ##
+KVM_LDSCRIPT_SRC-$(CONFIG_ARCH_X86_64) := 
$(CONFIG_UK_BASE)/plat/kvm/x86/link64.lds.S
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/trace.c|common
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/traps.c|common
  LIBKVMPLAT_TRAPS_COMMON_FLAGS += $(NO_X86_EXTREGS_FLAGS)
@@ -59,7 +60,6 @@ KVM_LDSCRIPT_SRC := 
$(CONFIG_UK_BASE)/plat/kvm/arm/link64.lds.S
  ifeq ($(findstring y,$(CONFIG_KVM_KERNEL_SERIAL_CONSOLE) 
$(CONFIG_KVM_DEBUG_SERIAL_CONSOLE)),y)
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += 
$(UK_PLAT_COMMON_BASE)/arm/pl011.c|common
  endif
-LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(KVM_LDSCRIPT_SRC)
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += 
$(UK_PLAT_COMMON_BASE)/arm/cpu_native.c|common
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += 
$(UK_PLAT_COMMON_BASE)/arm/cache64.S|common
  LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += 
$(UK_PLAT_COMMON_BASE)/arm/psci_arm64.S|common
@@ -78,6 +78,7 @@ LIBKVMPLAT_SRCS-y              += $(LIBKVMPLAT_BASE)/irq.c
  LIBKVMPLAT_SRCS-y              += $(LIBKVMPLAT_BASE)/io.c
  LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
  LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
+LIBKVMPLAT_SRCS-y              += $(KVM_LDSCRIPT_SRC-y)
##
  ## PCI library definitions
diff --git a/plat/kvm/x86/link64.lds b/plat/kvm/x86/link64.lds.S
similarity index 100%
rename from plat/kvm/x86/link64.lds
rename to plat/kvm/x86/link64.lds.S
diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk
index 5f39de1a..bcbdc00f 100644
--- a/plat/xen/Linker.uk
+++ b/plat/xen/Linker.uk
@@ -1,17 +1,8 @@
  ifeq (x86_64,$(CONFIG_UK_ARCH))
-XEN_LDSCRIPT  := $(CONFIG_UK_BASE)/plat/xen/x86/link64.lds
  XEN_LDFLAGS-y += -Wl,-m,elf_x86_64
  endif
-ifeq (x86_32,$(CONFIG_UK_ARCH))
-XEN_LDSCRIPT  := $(CONFIG_UK_BASE)/plat/xen/x86/link32.lds
-XEN_LDFLAGS-y += -Wl,-m,elf_x86_32
-endif
-ifeq (arm_64,$(CONFIG_UK_ARCH))
-XEN_LDSCRIPT  := $(CONFIG_UK_BASE)/plat/xen/arm/link64.lds
-endif
-ifeq (arm,$(CONFIG_UK_ARCH))
-XEN_LDSCRIPT  := $(CONFIG_UK_BASE)/plat/xen/arm/link32.lds
-endif
+
+XEN_LDSCRIPT     := $(call src2lds,libxenplat,$(XEN_LDSCRIPT_SRC-y))
##
  ## Link image
diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
index 3642c5b2..69b10efc 100644
--- a/plat/xen/Makefile.uk
+++ b/plat/xen/Makefile.uk
@@ -31,6 +31,7 @@ LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/io.c
  LIBXENPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
  LIBXENPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
+XEN_LDSCRIPT_SRC-$(CONFIG_ARCH_X86_64) := $(CONFIG_UK_BASE)/plat/xen/x86/link64.lds.S
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/trace.c|common
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/traps.c|common
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/cpu_features.c|common
@@ -55,6 +56,7 @@ LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/cpu_native.c
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_ARM_32) += 
$(UK_PLAT_COMMON_BASE)/arm/cpu_native.c
  endif
+XEN_LDSCRIPT_SRC-$(CONFIG_ARCH_ARM_32) := $(CONFIG_UK_BASE)/plat/xen/arm/link32.lds.S
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_ARM_32) += $(LIBXENPLAT_BASE)/arm/setup.c
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_ARM_32) += $(LIBXENPLAT_BASE)/arm/traps.c
  LIBXENPLAT_SRCS-$(CONFIG_ARCH_ARM_32) += $(LIBXENPLAT_BASE)/arm/entry32.S
@@ -79,6 +81,7 @@ LIBXENPLAT_SRCS-y              += 
$(LIBXENPLAT_BASE)/emg_console.c
  endif
  LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/shutdown.c
  LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/events.c
+LIBXENPLAT_SRCS-y              += $(XEN_LDSCRIPT_SRC-y)
ifeq ($(CONFIG_XEN_GNTTAB),y)
  LIBXENPLAT_SRCS-y              += $(LIBXENPLAT_BASE)/gnttab.c
diff --git a/plat/xen/arm/link32.lds b/plat/xen/arm/link32.lds.S
similarity index 100%
rename from plat/xen/arm/link32.lds
rename to plat/xen/arm/link32.lds.S
diff --git a/plat/xen/x86/link64.lds b/plat/xen/x86/link64.lds.S
similarity index 100%
rename from plat/xen/x86/link64.lds
rename to plat/xen/x86/link64.lds.S


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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