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

[Minios-devel] [UNIKRAFT PATCH v3 8/8] build: Add *.ld files as source to library



Instead of adding the linker to special linker variable, we add the
linker script as a source to library and the necessary variables are
automatically populated. This is an extension on the scheme used for
linker script source file.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 doc/guides/developers-app.rst |  7 +------
 lib/ukdebug/Makefile.uk       |  2 +-
 lib/vfscore/Makefile.uk       |  2 +-
 support/build/Makefile.rules  | 18 +++++++++++++++++-
 4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/doc/guides/developers-app.rst b/doc/guides/developers-app.rst
index 8e1698b1..29db81d7 100644
--- a/doc/guides/developers-app.rst
+++ b/doc/guides/developers-app.rst
@@ -302,12 +302,7 @@ extra.ld
 If your library/application needs a section in the final elf, edit
 your Makefile.uk to add ::
 
-    EXTRA_LD_SCRIPT-$(CONFIG_LIBYOURAPPNAME) += $(LIBYOURAPPNAME_BASE)/extra.ld
-
-If your library is specific to a platform, edit your Makefile.uk to add ::
-
-       [PLATFORM]_LD_SCRIPT-$(CONFIG_LIBYOURAPPNAME) += 
$(LIBYOURAPPNAME_BASE)/extra.ld
-
+    LIBYOURAPPNAME_SRCS-$(CONFIG_LIBYOURAPPNAME) += 
$(LIBYOURAPPNAME_BASE)/extra.ld
 
 An example context of extra.ld: ::
 
diff --git a/lib/ukdebug/Makefile.uk b/lib/ukdebug/Makefile.uk
index 663ac6de..d82cacad 100644
--- a/lib/ukdebug/Makefile.uk
+++ b/lib/ukdebug/Makefile.uk
@@ -9,6 +9,6 @@ LIBUKDEBUG_CXXFLAGS-y += -D__IN_LIBUKDEBUG__
 LIBUKDEBUG_SRCS-y += $(LIBUKDEBUG_BASE)/print.c
 LIBUKDEBUG_SRCS-y += $(LIBUKDEBUG_BASE)/hexdump.c
 LIBUKDEBUG_SRCS-$(CONFIG_LIBUKDEBUG_TRACEPOINTS) += $(LIBUKDEBUG_BASE)/trace.c
+LIBUKDEBUG_SRCS-$(CONFIG_LIBVFSCORE) += $(LIBUKDEBUG_BASE)/extra.ld
 
-EXTRA_LD_SCRIPT-$(CONFIG_LIBVFSCORE) += $(LIBUKDEBUG_BASE)/extra.ld
 STRIP_SECTIONS_FLAGS-$(CONFIG_LIBUKDEBUG_TRACEPOINTS) += -R 
.uk_tracepoints_list -R .uk_trace_keyvals
diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 0166e612..79878f26 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -14,7 +14,7 @@ LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/task.c
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/lookup.c
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/fops.c
 LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/subr_uio.c
+LIBVFSCORE_SRCS-y += $(LIBVFSCORE_BASE)/extra.ld
 
-EXTRA_LD_SCRIPT-$(CONFIG_LIBVFSCORE) += $(LIBVFSCORE_BASE)/extra.ld
 
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += writev-3
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index 235b109b..361390b9 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -450,12 +450,28 @@ $(if $(strip $($(call uc,$(1))_PLATS)),\
 )
 endef
 
+## Add the linker file to the common variable used for linker script
+define buildrule_ld  =
+$(2): | prepare
+
+$(eval $(call vprefix_lib,$(1),LDS-y) += $(2))
+
+$(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 := $(2)),\
+                       $(call add_lds_to_plat,$(2),$(p)))),\
+               $(call add_lds_to_lib,$(2))\
+ )
+endef
+
 # wrapper for buildrule_*,
 # selects appropriate buildrule depending on file extension
 #
 # buildrule $libname,$source,$target,$extraflags(optional)
 define buildrule =
 $(if $(filter %.lds.S,$(2)),$(call buildrule_lds,$(1),$(2),$(3),$(4)),\
+$(if $(filter %.ld   ,$(2)),$(call buildrule_ld ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.S,    $(2)),$(call buildrule_S  ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.sx,   $(2)),$(call buildrule_S  ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.s,    $(2)),$(call buildrule_s  ,$(1),$(2),$(3),$(4)),\
@@ -468,7 +484,7 @@ $(if $(filter %.CPP,  $(2)),$(call buildrule_cc 
,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.c++,  $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.C,    $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
 $(error $(3): missing build rule for source type $(suffix $(2))) \
-))))))))))))
+)))))))))))))
 endef
 
 
-- 
2.20.1


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