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

Re: [Minios-devel] [UNIKRAFT PATCH] build: add functionality to alternate linker script



Since this is just a change in grammar we could apply it while upstreaming

Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>

Sharan

On 1/30/19 2:10 PM, Sharan Santhanam wrote:
Hello Yuri,

Please find a minor comments inline.

I think the rest of it fine.


Thanks & Regards
Sharan

On 1/28/19 11:02 AM, Yuri Volchkov wrote:
With this patch libraries can amend the master linker script by
registering the extra script in EXTRA_LD_SCRIPT-y variable.

See doc/guides/developers-app.rst for details.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
  doc/guides/developers-app.rst | 26 ++++++++++++++++++++++++++
  plat/kvm/Linker.uk            |  5 ++++-
  plat/linuxu/Linker.uk         |  2 ++
  plat/xen/Linker.uk            |  8 ++++++--
  4 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/doc/guides/developers-app.rst b/doc/guides/developers-app.rst
index 97ed2451..5919ab73 100644
--- a/doc/guides/developers-app.rst
+++ b/doc/guides/developers-app.rst
@@ -31,6 +31,9 @@ you need to provide at least the following four files:
     usually contains only `main` for an application that is developed/ported
     as a single library to Unikraft.
+ * **extra.ld**: Optional. Contains an amendment to the main linker
+   script
+
  The Makefile is generally short and simple and might remind you to
  Linux kernel modules that are built off-tree. For most applications
  the Makefile should contain no more than the following: ::
@@ -293,6 +296,29 @@ is part of a remotely fetched archive). You can override it by defining the   with ``$(APPNAME_BASE)`` to the base directory of your application sources) or
  relative to the Unikraft sources directory.
+============================
+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
+
+
+An example context of extra.ld: ::
+
+    SECTIONS
+    {
+        .uk_fs_list : {
+             PROVIDE(uk_fslist_start = .);
+             KEEP (*(.uk_fs_list))
+             PROVIDE(uk_fslist_end = .);
+        }
+    }
+    INSERT AFTER .text;
+
+This will add section .uk_fs_list after the .text
I think this should be "add the section".

+
  ============================
  Make Targets
diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
index e0a56774..4587daf7 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker.uk
@@ -13,6 +13,8 @@ endif
  ##
  KVM_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvm-$(CONFIG_UK_ARCH)
+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)
@@ -32,7 +34,8 @@ ifneq ($(filter x86_64 arm64,$(CONFIG_UK_ARCH)),)
      $(call build_cmd,LD,,$@,\
             $(LD) $(LDFLAGS) $(LDFLAGS-y) \
               $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \
-             -Wl$(comma)-T$(comma)$(call strip,$(KVM_LDSCRIPT)) \
+             -Wl$(comma)-dT$(comma)$(call strip,$(KVM_LDSCRIPT)) \
+             $(EXTRA_LD_SCRIPT_FLAGS) \
               $@.o -o $@)
  ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
      $(call build_cmd,OBJCOPY,,$@.dbg,\
diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk
index 9e4b2a9d..dbdf9d96 100644
--- a/plat/linuxu/Linker.uk
+++ b/plat/linuxu/Linker.uk
@@ -4,6 +4,7 @@ LINUXU_LDFLAGS-y += -Wl,-e,_liblinuxuplat_start
  ## Link image
  ##
  LINUXU_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_linuxu-$(CONFIG_UK_ARCH)
+EXTRA_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T,$(EXTRA_LD_SCRIPT-y))
  $(LINUXU_IMAGE): $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
           $(LINUXU_OLIBS) $(LINUXU_OLIBS-y) \
@@ -17,6 +18,7 @@ $(LINUXU_IMAGE): $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
               $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
               $(UK_ALIBS) $(UK_ALIBS-y) \
               -Wl$(comma)--end-group \
+             $(EXTRA_LD_SCRIPT_FLAGS) \
               -o $@)
  ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
      $(call build_cmd,OBJCOPY,,$@.dbg,\
diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk
index df84c20f..801f5e2e 100644
--- a/plat/xen/Linker.uk
+++ b/plat/xen/Linker.uk
@@ -18,6 +18,8 @@ endif
  ##
  XEN_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_xen-$(CONFIG_UK_ARCH)
+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)
@@ -36,7 +38,8 @@ $(XEN_IMAGE): $(XEN_ALIBS) $(XEN_ALIBS-y) $(XEN_OLIBS) $(XEN_OLIBS-y) \
  ifeq (arm,$(CONFIG_UK_ARCH))
      $(call build_cmd,LD,,$@.elf,\
             $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) \
-             -Wl$(comma)-T$(comma)$(call strip,$(XEN_LDSCRIPT)) \
+             -Wl$(comma)-dT$(comma)$(call strip,$(XEN_LDSCRIPT)) \
+             $(EXTRA_LD_SCRIPT_FLAGS) \
               $@.o -o $@.elf)
  ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
      $(call build_cmd,OBJCOPY,,$@.dbg,\
@@ -57,7 +60,8 @@ endif
  else
      $(call build_cmd,LD,,$@,\
             $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) \
-             -Wl$(comma)-T$(comma)$(call strip,$(XEN_LDSCRIPT)) \
+             -Wl$(comma)-dT$(comma)$(call strip,$(XEN_LDSCRIPT)) \
+             $(EXTRA_LD_SCRIPT_FLAGS) \
               $@.o -o $@)
  ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
      $(call build_cmd,OBJCOPY,,$@.dbg,\


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

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