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

[Minios-devel] [UNIKRAFT PATCH RFC] build: isolate symbols inside libraries



The aim is to avoid symbol name conflicts between different
libraries.

Every lib have to have a file 'export.syms', which is simply a flat
file, with one symbol name per line. All symbols not listed there will
become local to the library.

This patch is RFC, and covers only symbols needed to build a
hello-world application for xen platform.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
 lib/nolibc/export.syms        | 12 ++++++++++++
 lib/ukalloc/export.syms       |  8 ++++++++
 lib/ukallocbbuddy/export.syms |  1 +
 lib/ukargparse/export.syms    |  1 +
 lib/ukboot/export.syms        |  2 ++
 lib/ukdebug/export.syms       |  3 +++
 plat/xen/export.syms          | 11 +++++++++++
 support/build/Makefile.rules  |  7 +++++--
 8 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 lib/nolibc/export.syms
 create mode 100644 lib/ukalloc/export.syms
 create mode 100644 lib/ukallocbbuddy/export.syms
 create mode 100644 lib/ukargparse/export.syms
 create mode 100644 lib/ukboot/export.syms
 create mode 100644 lib/ukdebug/export.syms
 create mode 100644 plat/xen/export.syms

diff --git a/lib/nolibc/export.syms b/lib/nolibc/export.syms
new file mode 100644
index 0000000..53816e0
--- /dev/null
+++ b/lib/nolibc/export.syms
@@ -0,0 +1,12 @@
+strncpy
+strlen
+strnlen
+printf
+vsnprintf
+vfprintf
+snprintf
+memchr
+memcmp
+memcpy
+memset
+_nolibc_errno
diff --git a/lib/ukalloc/export.syms b/lib/ukalloc/export.syms
new file mode 100644
index 0000000..66a9948
--- /dev/null
+++ b/lib/ukalloc/export.syms
@@ -0,0 +1,8 @@
+uk_alloc_get_default
+uk_malloc_ifpages
+uk_calloc_compat
+uk_realloc_ifpages
+uk_posix_memalign_ifpages
+uk_memalign_compat
+uk_free_ifpages
+uk_alloc_register
diff --git a/lib/ukallocbbuddy/export.syms b/lib/ukallocbbuddy/export.syms
new file mode 100644
index 0000000..6c871e3
--- /dev/null
+++ b/lib/ukallocbbuddy/export.syms
@@ -0,0 +1 @@
+uk_allocbbuddy_init
diff --git a/lib/ukargparse/export.syms b/lib/ukargparse/export.syms
new file mode 100644
index 0000000..8995cb1
--- /dev/null
+++ b/lib/ukargparse/export.syms
@@ -0,0 +1 @@
+uk_argnparse
diff --git a/lib/ukboot/export.syms b/lib/ukboot/export.syms
new file mode 100644
index 0000000..08b8999
--- /dev/null
+++ b/lib/ukboot/export.syms
@@ -0,0 +1,2 @@
+ukplat_entry_argp
+main
diff --git a/lib/ukdebug/export.syms b/lib/ukdebug/export.syms
new file mode 100644
index 0000000..4f8faba
--- /dev/null
+++ b/lib/ukdebug/export.syms
@@ -0,0 +1,3 @@
+_uk_printd
+_uk_printk
+uk_printk
diff --git a/plat/xen/export.syms b/plat/xen/export.syms
new file mode 100644
index 0000000..7da37fd
--- /dev/null
+++ b/plat/xen/export.syms
@@ -0,0 +1,11 @@
+_libxenplat_start
+_libxenplat_x86entry
+ukplat_coutk
+ukplat_coutd
+ukplat_time_init
+ukplat_memregion_count
+ukplat_memregion_get
+ukplat_irq_init
+ukplat_terminate
+ukplat_lcpu_enable_irq
+ukplat_monotonic_clock
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index feb1455..7e2f7bd 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -49,6 +49,8 @@ libname2olib = $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(1)))
 
 libname2preolib = $(addprefix $(BUILD_DIR)/,$(addsuffix .ld.o,$(1)))
 
+libname2exports = $($(call vprefix_lib,$1,BASE))/export.syms
+
 # converts a list of sources to paths pointing to their corresponding object 
file
 # src2obj $libname,$source(s),$variant(optional)
 define src2obj =
@@ -411,11 +413,12 @@ $(call libname2preolib,$(1)): $($(call 
vprefix_lib,$(1),OBJS)) $($(call vprefix_
                      $($(call vprefix_lib,$(1),OBJS)) $($(call 
vprefix_lib,$(1),OBJS-y)) \
                      -o $(call libname2preolib,$(1)))
 
-$(call libname2olib,$(1)): $(call libname2preolib,$(1))
+$(call libname2olib,$(1)): $(call libname2preolib,$(1)) $(call 
libname2exports,$1)
        $(call build_cmd,OBJCOPY,,$(call libname2olib,$(1)),\
                $(OBJCOPY) $(OBJCFLAGS) $(OBJCFLAGS-y) \
                           $($(call vprefix_lib,$(1),OBJCFLAGS)) $($(call 
vprefix_lib,$(1),OBJCFLAGS-y)) \
-                          $(call libname2preolib,$(1)) $(call 
libname2olib,$(1)))
+                          $(call libname2preolib,$(1)) $(call 
libname2olib,$(1))) \
+                          --keep-global-symbols=$(call libname2exports,$1)
 
 $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(call 
libname2preolib,$(1))))
 $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(call 
libname2olib,$(1))))
-- 
2.17.0


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