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

[Minios-devel] [UNIKRAFT/LIBUNWIND PATCH 2/2] Initial port of Libunwind to Unikraft



This is our initial port of compiler-rt to Unikraft as external
library. Libc is requiered for it to work.

In the dependency list it should stay as follows:
...:$(UK_LIBS)/libunwind:$(UK_LIBS)/compiler-rt:
$(UK_LIBS)/libcxxabi:$(UK_LIBS)/libcxx:$(UK_LIBS)/newlib:...

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
 Config.uk                          |  5 ++
 Makefile.uk                        | 89 ++++++++++++++++++++++++++++++
 exportsyms.uk                      |  9 +++
 patches/0001-Updated-the-RIP.patch | 32 +++++++++++
 4 files changed, 135 insertions(+)
 create mode 100644 Config.uk
 create mode 100644 Makefile.uk
 create mode 100644 exportsyms.uk
 create mode 100644 patches/0001-Updated-the-RIP.patch

diff --git a/Config.uk b/Config.uk
new file mode 100644
index 0000000..320363a
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,5 @@
+menuconfig LIBUNWIND
+    bool "libunwind - unwinder"
+       select LIBNOLIBC if !HAVE_LIBC
+       select LIBCOMPILER_RT
+    default n
diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..9547852
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,89 @@
+#  libunwind Makefile.uk
+#
+#  Authors: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
+#
+#  Copyright (c) 2019, NEC Europe Ltd., NEC Corporation. All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. Neither the name of the copyright holder nor the names of its
+#     contributors may be used to endorse or promote products derived from
+#     this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+#
+#  THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+#
+
+
+################################################################################
+# Library registration
+################################################################################
+$(eval $(call addlib_s,libunwind,$(CONFIG_LIBUNWIND)))
+
+ifeq ($(CONFIG_LIBUNWIND),y)
+ifneq ($(CONFIG_LIBCOMPILER_RT),y)
+$(error Require libcompiler_rt)
+endif
+endif
+
+################################################################################
+# Sources
+################################################################################
+LIBUNWIND_VERSION=7.0.0
+LIBUNWIND_URL=http://releases.llvm.org/$(LIBUNWIND_VERSION)/libunwind-$(LIBUNWIND_VERSION).src.tar.xz
+LIBUNWIND_PATCHDIR=$(LIBUNWIND_BASE)/patches
+$(eval $(call fetch,libunwind,$(LIBUNWIND_URL)))
+$(eval $(call 
patch,libunwind,$(LIBUNWIND_PATCHDIR),libunwind-$(LIBUNWIND_VERSION).src))
+
+################################################################################
+# Helpers
+################################################################################
+LIBUNWIND_SUBDIR=libunwind-$(LIBUNWIND_VERSION).src
+LIBUNWIND_SRC=$(LIBUNWIND_ORIGIN)/$(LIBUNWIND_SUBDIR)
+
+################################################################################
+# Library includes
+################################################################################
+CINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/src
+CINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/include
+CXXINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/src
+CXXINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/include
+
+CXXINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_BASE)/include
+CINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_BASE)/include
+
+################################################################################
+# Global flags
+################################################################################
+CONFIG_FLAGS   += -D _LIBUNWIND_HAS_NO_THREADS  -D __ELF__  -D 
_LIBUNWIND_IS_NATIVE_ONLY  -D _LIBUNWIND_SUPPORT_DWARF_UNWIND -D 
_LIBUNWIND_IS_BAREMETAL -D _LIBUNWIND_BUILD_ZERO_COST_APIS -D 
_LIBUNWIND_TARGET_X86_64 -D __x86_64__
+LIBUNWIND_CFLAGS-y      +=  $(CONFIG_FLAGS)
+LIBUNWIND_CXXFLAGS-y    +=  $(CONFIG_FLAGS)
+
+################################################################################
+# Library sources
+################################################################################
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindLevel1.c
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/Unwind-sjlj.c
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindLevel1-gcc-ext.c
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/libunwind.cpp
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/Unwind-EHABI.cpp
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindRegistersRestore.S
+LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindRegistersSave.S
diff --git a/exportsyms.uk b/exportsyms.uk
new file mode 100644
index 0000000..bb95f63
--- /dev/null
+++ b/exportsyms.uk
@@ -0,0 +1,9 @@
+_Unwind_Resume
+_Unwind_RaiseException
+_Unwind_DeleteException
+_Unwind_SetGR
+_Unwind_SetIP
+_Unwind_GetIP
+_Unwind_GetRegionStart
+_Unwind_GetLanguageSpecificData
+
diff --git a/patches/0001-Updated-the-RIP.patch 
b/patches/0001-Updated-the-RIP.patch
new file mode 100644
index 0000000..8b6971e
--- /dev/null
+++ b/patches/0001-Updated-the-RIP.patch
@@ -0,0 +1,32 @@
+From 863cddb4f2f89b51b38785f49b6c7cf3fc9e3f2c Mon Sep 17 00:00:00 2001
+From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
+Date: Mon, 3 Dec 2018 18:59:59 +0200
+Subject: [PATCH] Updated the RIP
+
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
+---
+ UnwindRegistersSave.S | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/UnwindRegistersSave.S b/UnwindRegistersSave.S
+index 07db14b..8223ea1 100644
+--- a/src/UnwindRegistersSave.S
++++ b/src/UnwindRegistersSave.S
+@@ -88,7 +88,13 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+   movq  %r13,104(PTR)
+   movq  %r14,112(PTR)
+   movq  %r15,120(PTR)
+-  movq  (%rsp),TMP
++  push %rax 
++  movq %rbp, (%rax)
++  movq (%rax), %rax
++  addq $8, %rax
++  movq (%rax), %rax
++  movq  %rax, TMP
++  pop %rax 
+   movq  TMP,128(PTR) # store return address as rip
+   # skip rflags
+   # skip cs
+-- 
+2.19.2
+
-- 
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®.