[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH 4/8] lib/uklibparam: Add linker script for parameter
On 4/11/19 4:17 PM, Florian Schmidt wrote: On 3/15/19 6:06 PM, Sharan Santhanam wrote: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> --- Makefile | 2 ++ lib/uklibparam/libparam.lds.S | 23 +++++++++++++++++++++++ plat/kvm/Linker.uk | 2 +- plat/linuxu/Linker.uk | 3 ++- plat/xen/Linker.uk | 2 +- support/build/Makefile.rules | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 lib/uklibparam/libparam.lds.S diff --git a/Makefile b/Makefile index 8e81c64..e0fc145 100644 --- a/Makefile +++ b/Makefile @@ -198,6 +198,8 @@ UK_ALIBS:= UK_ALIBS-y:= UK_OLIBS:= UK_OLIBS-y:= +UK_LDS:= +UK_LDS-y:= UK_SRCS:= UK_SRCS-y:= UK_DEPS:=diff --git a/lib/uklibparam/libparam.lds.S b/lib/uklibparam/libparam.lds.Snew file mode 100644 index 0000000..3a9c920 --- /dev/null +++ b/lib/uklibparam/libparam.lds.S @@ -0,0 +1,23 @@ +#include <uk/config.h> +#include <uk/libparam.h> + +#define create_var(x,y) __STRINGCONCAT(x,y) +#ifdef UK_LIBPARAM_PREFIX +SECTIONS +{ + create_var(UK_LIBPARAM_PREFIX,__param_arg) : { + _SECTION_START( + _LIB_PARAM_SECTION_NAME(UK_LIBPARAM_PREFIX, + PARAM_SECTION_SUFFIX) + ) = .; + + KEEP (*(create_var(UK_LIBPARAM_PREFIX,PARAM_SECTION_SUFFIX))) + + _SECTION_STOP( + _LIB_PARAM_SECTION_NAME(UK_LIBPARAM_PREFIX, + PARAM_SECTION_SUFFIX) + ) = .; + } +} +INSERT AFTER .rodata +#endif /* UK_LIBPARAM_PREFIX */So, the thing I don't like about this is that it creates a lot of additional sections in the ELF file: one when libparam is activated, and then another 2 for each library that has parameters. My understanding is you don't really care about the section itself, but rather use it to group all your variables together into a contiguous memory space, and to set the START and STOP variables to find it. There should be some way to achieving that without having to carry around those extra section headers, merging those sections into .rodata or another appropriate standard section in the last linking step... I just am not sure yet how.I will remove the separate section for the library names. For the library and parameter metadata section I am not so sure. Maybe we could a create a single section separated by start and end variables within that section. But I would keep as such for this series and look to fix it in the next version. diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk index f696e25..4b8b167 100644 --- a/plat/kvm/Linker.uk +++ b/plat/kvm/Linker.uk@@ -15,7 +15,7 @@ EXTRA_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T,$(EXTRA_LD_SCRIPT-y))$(KVM_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \ $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) \ - $(KVM_LDSCRIPT) + $(UK_LDS) $(UK_LDS-y) $(call build_cmd,LD,,$@.ld.o,\ $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \ $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \ diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk index dbdf9d9..f4387fa 100644 --- a/plat/linuxu/Linker.uk +++ b/plat/linuxu/Linker.uk@@ -8,7 +8,8 @@ EXTRA_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T,$(EXTRA_LD_SCRIPT-y))$(LINUXU_IMAGE): $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \ $(LINUXU_OLIBS) $(LINUXU_OLIBS-y) \ - $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) + $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) \ + $(UK_LDS) $(UK_LDS-y) $(call build_cmd,LD,,$@,\ $(LD) $(LDFLAGS) $(LDFLAGS-y) \ $(LINUXU_LDFLAGS) $(LINUXU_LDFLAGS-y) \ diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk index 801f5e2..aea1089 100644 --- a/plat/xen/Linker.uk +++ b/plat/xen/Linker.uk@@ -22,7 +22,7 @@ EXTRA_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T,$(EXTRA_LD_SCRIPT-y))$(XEN_IMAGE): $(XEN_ALIBS) $(XEN_ALIBS-y) $(XEN_OLIBS) $(XEN_OLIBS-y) \ $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) \ - $(XEN_LDSCRIPT) + $(UK_LDS) $(UK_LDS-y) $(call build_cmd,LD,,$@.ld.o,\ $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \ $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) \ diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules index 04f2f0d..631fee3 100644 --- a/support/build/Makefile.rules +++ b/support/build/Makefile.rules @@ -157,6 +157,26 @@ $(call addlib,$(1)) endif endef +# add_paramprefix $name $libname +define add_paramprefix =+$(eval UK_LIB_PARAM_LDS:=$(CONFIG_UK_BASE)/lib/uklibparam/libparam.lds.S)+$(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))_LD_SCRIPT := $(call src2lds,$(2),$(UK_LIB_PARAM_LDS)))+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))))+$(eval EXTRA_LD_SCRIPT-$(CONFIG_LIBUKLIBPARAM) += $($(call uc,$(1))_LD_SCRIPT)) +$(eval $(call uc,$(1))_SRCS-$(CONFIG_LIBUKLIBPARAM) += $(UK_LIB_PARAM_LDS))+$(eval $(call uc,$(1))_CLEAN-$(CONFIG_LIBUKLIBPARAM) += \ + $($(call uc,$(1))_LD_SCRIPT)) +endef # addplatlib $platname,$libname define addplatlib = @@ -173,6 +193,20 @@ $(if $(filter y,$(3)),$(call addplatlib,$(1),$(2)),) endef +# addplatlib_paramprefix,$plat,$libname,$paramname(optional) +define addplatlib_paramprefix = +$(if $(3),\ +$(eval name:=$(3)),\ +$(eval name:=$(2))) +$(eval $(call add_paramprefix,$(name),$(2))) +$(eval $(call uc,$(1))_LD_SCRIPT-$(CONFIG_LIBUKLIBPARAM) +=\ + $($(call uc,$(2))_LD_SCRIPT)) +$(eval $(call uc,$(2))_SRCS-$(CONFIG_LIBUKLIBPARAM) += \ + $(UK_LIB_PARAM_LDS)) +$(eval $(call uc,$(2))_CLEAN-$(CONFIG_LIBUKLIBPARAM) +=\ + $($(call uc,$(2))_LD_SCRIPT)) +endef +################################################################################# # Command calling @@ -420,6 +454,7 @@ $(3): $(2) | prepare ) UK_SRCS-y += $(2) +UK_LDS-y += $(3) UK_DEPS-y += $(call out2dep,$(3))$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call out2dep,$(3)))endef _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |