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

[Minios-devel] [UNIKRAFT PATCH v3 5/8] lib/uklibparam: Add linker script for parameter



This patch introduces a linker script to create linker
section to place the library arguments meta-data.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>
---
 lib/uklibparam/Makefile.rules | 15 +++++++++++++++
 lib/uklibparam/libparam.lds.S | 32 ++++++++++++++++++++++++++++++++
 support/build/Makefile.rules  |  2 +-
 3 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 lib/uklibparam/Makefile.rules
 create mode 100644 lib/uklibparam/libparam.lds.S

diff --git a/lib/uklibparam/Makefile.rules b/lib/uklibparam/Makefile.rules
new file mode 100644
index 00000000..3f7af4a2
--- /dev/null
+++ b/lib/uklibparam/Makefile.rules
@@ -0,0 +1,15 @@
+# add_paramprefix $name $libname
+define _add_paramprefix =
+$(eval $(call uc,$(2))_CFLAGS += -DUK_LIBPARAM_PREFIX=$(1))
+$(eval $(call uc,$(2))_CXXFLAGS += -DUK_LIBPARAM_PREFIX=$(1))
+$(eval $(call uc,$(2))_ASFLAGS += -DUK_LIBPARAM_PREFIX=$(1))
+$(eval $(call uc,$(2))_SRCS-$(CONFIG_LIBUKLIBPARAM) += 
$$(LIBUKLIBPARAM_BASE)/libparam.lds.S)
+endef
+
+# addlib_paramprefix $libname,$paramname(optional)
+define addlib_paramprefix =
+$(if $(2),\
+$(eval name := $(2)),\
+$(eval name := $(1)))
+$(eval $(call _add_paramprefix,$(name),$(1),$(call uc,$(1))))
+endef
diff --git a/lib/uklibparam/libparam.lds.S b/lib/uklibparam/libparam.lds.S
new file mode 100644
index 00000000..bec69789
--- /dev/null
+++ b/lib/uklibparam/libparam.lds.S
@@ -0,0 +1,32 @@
+#include <uk/config.h>
+#include <uk/libparam.h>
+
+#define create_var(x,y) __STRINGCONCAT(x,y)
+#ifdef UK_LIBPARAM_PREFIX
+SECTIONS
+{
+       /**
+        * creates a variable name = LOADADDR(section_name);
+        */
+       _SECTION_START(
+                       _LIB_PARAM_SECTION_NAME(UK_LIBPARAM_PREFIX,
+                                               PARAM_SECTION_SUFFIX)
+                         ) = LOADADDR(
+                               create_var(UK_LIBPARAM_PREFIX,__param_arg));
+
+       create_var(UK_LIBPARAM_PREFIX,__param_arg) : {
+               KEEP (*(create_var(UK_LIBPARAM_PREFIX,PARAM_SECTION_SUFFIX)))
+       }
+       /**
+        * creates a variable name = LOADADDR(section_name);
+        */
+       _SECTION_STOP(
+                       _LIB_PARAM_SECTION_NAME(UK_LIBPARAM_PREFIX,
+                                               PARAM_SECTION_SUFFIX)
+                         ) = LOADADDR(
+                               create_var(UK_LIBPARAM_PREFIX,__param_arg)) +
+                             SIZEOF(
+                               create_var(UK_LIBPARAM_PREFIX,__param_arg));
+}
+INSERT AFTER .rodata
+#endif /* UK_LIBPARAM_PREFIX */
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index 361390b9..2a1d20a6 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -165,7 +165,6 @@ $(call addlib,$(1))
 endif
 endef
 
-
 # addplatlib $platname,$libname
 define addplatlib =
 $(call mk_sub_build_dir,$(2))
@@ -437,6 +436,7 @@ $(3): $(2) | prepare
        )
 
 UK_SRCS-y += $(2)
+UK_LDS-y += $(3)
 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)))
-- 
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®.