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

[Minios-devel] [UNIKRAFT PATCH v4 7/8] build: Use linker script source to add the LDFLAGS



Remove additional variables needed between the Makefile.uk and
Linker.uk to prepare the linker flags. With this patch, the user needs
to add linker script to library source and while compiling the library
the variables needed to populate the linker flags are automatically
generated.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>
---
 plat/kvm/Linker.uk           |  3 +--
 plat/kvm/Makefile.uk         |  2 --
 plat/linuxu/Linker.uk        |  3 +--
 plat/linuxu/Makefile.uk      |  8 ++++----
 plat/xen/Linker.uk           |  3 +--
 plat/xen/Makefile.uk         |  3 +--
 support/build/Makefile.rules | 16 ++++++++++++++++
 7 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
index ccdd743..5e42193 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker.uk
@@ -4,7 +4,6 @@ else ifeq (arm64,$(CONFIG_UK_ARCH))
 KVM_LDFLAGS-y   += -Wl,-m,aarch64elf
 endif
 
-KVM_LDSCRIPT     := $(call src2lds,libkvmplat,$(UK_PLAT_KVM_DEF_LDS))
 
 ##
 ## Link image
@@ -13,7 +12,7 @@ KVM_IMAGE := 
$(BUILD_DIR)/$(CONFIG_UK_NAME)_kvm-$(CONFIG_UK_ARCH)
 KVM_DEBUG_IMAGE := $(KVM_IMAGE).dbg
 
 KVM_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
-                        $(KVM_LDSCRIPT))
+                        $(UK_PLAT_KVM_DEF_LDS))
 KVM_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
                        $(KVM_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
 
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index f52bd4e..cef753d 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -38,7 +38,6 @@ endif
 ##
 ## 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)
@@ -68,7 +67,6 @@ endif
 ##
 ## Architecture library definitions for arm64
 ##
-KVM_LDSCRIPT_SRC-$(CONFIG_ARCH_ARM_64) := 
$(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
diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk
index d8b380e..9e310a9 100644
--- a/plat/linuxu/Linker.uk
+++ b/plat/linuxu/Linker.uk
@@ -5,9 +5,8 @@ LINUXU_LDFLAGS-y += -Wl,-e,_liblinuxuplat_start
 ##
 LINUXU_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_linuxu-$(CONFIG_UK_ARCH)
 LINUXU_DEBUG_IMAGE := $(LINUXU_IMAGE).dbg
-LINUXU_LDSCRIPT := $(call src2lds,liblinuxuplat,$(LINUXU_LDSCRIPT_SRC-y))
 LINUXU_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T$(comma),\
-                           $(LINUXU_LDSCRIPT) $(EXTRA_LD_SCRIPT-y))
+                           $(LINUXU_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
 
 $(LINUXU_DEBUG_IMAGE): $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
                       $(LINUXU_OLIBS) $(LINUXU_OLIBS-y) \
diff --git a/plat/linuxu/Makefile.uk b/plat/linuxu/Makefile.uk
index ee3a7ea..512a494 100644
--- a/plat/linuxu/Makefile.uk
+++ b/plat/linuxu/Makefile.uk
@@ -20,9 +20,6 @@ LIBLINUXUPLAT_ASFLAGS             += -DLINUXUPLAT
 LIBLINUXUPLAT_CFLAGS              += -DLINUXUPLAT
 LIBLINUXUPLAT_CXXFLAGS            += -DLINUXUPLAT
 
-LINUXU_LDSCRIPT_SRC-$(CONFIG_ARCH_X86_64) += 
$(LIBLINUXUPLAT_BASE)/x86/link64.lds.S
-LINUXU_LDSCRIPT_SRC-$(CONFIG_ARCH_ARM_32) += 
$(LIBLINUXUPLAT_BASE)/arm/link.lds.S
-
 LIBLINUXUPLAT_SRCS-$(CONFIG_ARCH_X86_64) += 
$(UK_PLAT_COMMON_BASE)/x86/cpu_features.c|common
 LIBLINUXUPLAT_SRCS-$(CONFIG_ARCH_X86_32) += $(LIBLINUXUPLAT_BASE)/x86/entry32.S
 LIBLINUXUPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBLINUXUPLAT_BASE)/x86/entry64.S
@@ -43,4 +40,7 @@ LIBLINUXUPLAT_SRCS-y              += 
$(LIBLINUXUPLAT_BASE)/time.c
 LIBLINUXUPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
 LIBLINUXUPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
 LIBLINUXUPLAT_SRCS-y              += $(LIBLINUXUPLAT_BASE)/io.c
-LIBLINUXUPLAT_SRCS-y              += $(LINUXU_LDSCRIPT_SRC-y)
+LIBLINUXUPLAT_SRCS-$(CONFIG_ARCH_X86_64) += \
+                       $(LIBLINUXUPLAT_BASE)/x86/link64.lds.S
+LIBLINUXUPLAT_SRCS-$(CONFIG_ARCH_ARM_32) += \
+                       $(LIBLINUXUPLAT_BASE)/arm/link.lds.S
diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk
index 0cc1fdc..416f8b2 100644
--- a/plat/xen/Linker.uk
+++ b/plat/xen/Linker.uk
@@ -2,7 +2,6 @@ ifeq (x86_64,$(CONFIG_UK_ARCH))
 XEN_LDFLAGS-y += -Wl,-m,elf_x86_64
 endif
 
-XEN_LDSCRIPT     := $(call src2lds,libxenplat,$(UK_PLAT_XEN_DEF_LDS))
 ##
 ## Link image
 ##
@@ -15,7 +14,7 @@ endif
 XEN_DEBUG_IMAGE := $(XEN_IMAGE).dbg
 
 XEN_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
-                        $(XEN_LDSCRIPT))
+                        $(UK_PLAT_XEN_DEF_LDS))
 XEN_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
                         $(XEN_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
 
diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
index eb4074e..c776eea 100644
--- a/plat/xen/Makefile.uk
+++ b/plat/xen/Makefile.uk
@@ -43,7 +43,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
@@ -68,7 +68,6 @@ 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
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index d10cf10..235b109 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -417,6 +417,14 @@ $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
 $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
out2dep,$(3)))
 endef
 
+define add_lds_to_plat =
+$(eval $(call uc,$(2))_LD_SCRIPT-y += $(1))
+endef
+
+define add_lds_to_lib =
+$(eval EXTRA_LD_SCRIPT-y += $(1))
+endef
+
 define buildrule_lds =
 $(3): $(2) | prepare
        $(call build_cmd_fixdep,LDS,$(1),$(3),\
@@ -432,6 +440,14 @@ UK_SRCS-y += $(2)
 UK_DEPS-y += $(call out2dep,$(3))
 $(eval $(call vprefix_lib,$(1),LDS-y) += $(3))
 $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
out2dep,$(3)))
+
+$(if $(strip $($(call uc,$(1))_PLATS)),\
+       $(foreach p,$($(call uc,$(1))_PLATS),\
+               $(if $(filter $(UK_PLAT_$(p)_DEF_LDS),$(2)),\
+                       $(eval UK_PLAT_$(p)_DEF_LDS := $(3)),\
+                       $(call add_lds_to_plat,$(3),$(p)))),\
+               $(call add_lds_to_lib,$(3))\
+)
 endef
 
 # wrapper for buildrule_*,
-- 
2.7.4


_______________________________________________
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®.