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

Re: [Minios-devel] [UNIKRAFT PATCHv5 16/46] plat/kvm: Generate linker scripts from source code



Hey Wei,

I am currently thinking of a nicer solution for linker scripts that have to be pre-processed. I think also other platforms could benefit from something like this. The build system should provide you an easy way to let you do this. Let me come up with a patch tomorrow to achieve this. You could then just use this one.

On 10.08.2018 09:08, Wei Chen wrote:
Sometimes, using a macro in linker script will be easier for people
to see what is done. This means we will share macros with source code.
So, generate linker script from a .S will help linker script to share
macros with source code.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
  plat/kvm/Linker.uk                       | 7 +++++--
  plat/kvm/x86/{link64.ld => link64.lds.S} | 0
  2 files changed, 5 insertions(+), 2 deletions(-)
  rename plat/kvm/x86/{link64.ld => link64.lds.S} (100%)

diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
index 2292b03..fbadde2 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker.uk
@@ -1,5 +1,6 @@
  ifeq (x86_64,$(CONFIG_UK_ARCH))
-KVM_LDSCRIPT  := -Wl,-T,$(CONFIG_UK_BASE)/plat/kvm/x86/link64.ld
+KVM_LDSCRIPT  := -Wl,-T,$(CONFIG_UK_BASE)/plat/kvm/x86/link64.lds
+KVM_LDSCRIPT_FLAGS := -Wl,-T,$(KVM_LDSCRIPT)
  KVM_LDFLAGS-y += -Wl,-m,elf_x86_64
  endif
@@ -14,8 +15,10 @@ $(KVM_IMAGE): $(KVM_LINK) $(KVM_LINK-y) $(UK_LINK) $(UK_LINK-y)
        $(call build_cmd,OBJCOPY,,$@.o,\
               $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry $@.ld.o $@.o)
  ifeq (x86_64,$(CONFIG_UK_ARCH))
+       $(call build_cmd,CC,,link64.lds.o,\
+              $(CC) -E $(ASINCLUDES) $(ASFLAGS) $(ASFLAGS-y) -P 
$(KVM_LDSCRIPT).S -o $(KVM_LDSCRIPT))

This rule says that the generated linker script is not saved to the build directory. We should definitely avoid this since multiple projects may use the same unikraft source base. Project configurations may result in different linker scripts. Because of this, each project has its own build directory.

        $(call build_cmd,LD,,$@,\
-              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) 
$(KVM_LDSCRIPT) $@.o -o $@)
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) 
$(KVM_LDSCRIPT_FLAGS) $@.o -o $@)
  ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
        $(call build_cmd,OBJCOPY,,$@.dbg,\
               $(OBJCOPY) --only-keep-debug $@ $@.dbg)
diff --git a/plat/kvm/x86/link64.ld b/plat/kvm/x86/link64.lds.S
similarity index 100%
rename from plat/kvm/x86/link64.ld
rename to plat/kvm/x86/link64.lds.S


Thanks,

Simon

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