summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2014-04-08 12:04:51 -0700
committerDan Albert <danalbert@google.com>2014-04-11 14:22:23 -0700
commitfa2203904bdca85115bf2fcb9bd70150dffa9bbe (patch)
tree91d76be13b68750086dd3bcf5301a6ad11e23b6d
parent426b4a2074546a3be819110978876163a8f1704c (diff)
downloadlibcxxabi_35a-fa2203904bdca85115bf2fcb9bd70150dffa9bbe.tar.gz
Gets libcxxabi building for Android
Fixes a few configuration issues in libcxxabi and adds an Android makefile. Change-Id: I7b55f9ff0d7025cb316695fcb6c592db9ab7dd38
-rw-r--r--Android.mk80
-rw-r--r--include/unwind.h2
-rw-r--r--src/Unwind/AddressSpace.hpp2
-rw-r--r--src/Unwind/UnwindCursor.hpp3
-rw-r--r--src/Unwind/config.h14
-rw-r--r--src/cxa_exception.cpp6
-rw-r--r--src/cxa_personality.cpp2
7 files changed, 102 insertions, 7 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..ea13f37
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+LIBCXXABI_SRC_FILES := \
+ src/abort_message.cpp \
+ src/cxa_aux_runtime.cpp \
+ src/cxa_default_handlers.cpp \
+ src/cxa_demangle.cpp \
+ src/cxa_exception.cpp \
+ src/cxa_exception_storage.cpp \
+ src/cxa_guard.cpp \
+ src/cxa_handlers.cpp \
+ src/cxa_new_delete.cpp \
+ src/cxa_personality.cpp \
+ src/cxa_unexpected.cpp \
+ src/cxa_vector.cpp \
+ src/cxa_virtual.cpp \
+ src/exception.cpp \
+ src/fallback_malloc.ipp \
+ src/private_typeinfo.cpp \
+ src/stdexcept.cpp \
+ src/typeinfo.cpp \
+ src/Unwind/libunwind.cpp \
+ src/Unwind/Unwind-sjlj.c \
+ src/Unwind/UnwindLevel1-gcc-ext.c \
+ src/Unwind/UnwindLevel1.c \
+ src/Unwind/UnwindRegistersSave.S \
+
+ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
+LIBCXXABI_SRC_FILES += src/Unwind/UnwindRegistersRestore.S
+endif
+
+LIBCXXABI_CFLAGS := \
+ -I$(LOCAL_PATH)/include/ \
+
+LIBCXXABI_RTTI_FLAG := -frtti
+LIBCXXABI_CPPFLAGS := \
+ -Iexternal/libcxx/include /\
+ --std=c++11 \
+ -fexceptions \
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libcxxabi
+LOCAL_CLANG := true
+LOCAL_SRC_FILES := $(LIBCXXABI_SRC_FILES)
+LOCAL_CFLAGS := $(LIBCXXABI_CFLAGS)
+LOCAL_CPPFLAGS := $(LIBCXXABI_CPPFLAGS)
+LOCAL_RTTI_FLAG := $(LIBCXXABI_RTTI_FLAG)
+
+ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm arm64))
+LOCAL_SHARED_LIBRARIES := libdl
+endif
+
+LOCAL_SYSTEM_SHARED_LIBRARIES := libc
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libcxxabi
+LOCAL_CLANG := true
+LOCAL_SRC_FILES := $(LIBCXXABI_SRC_FILES)
+LOCAL_CFLAGS := $(LIBCXXABI_CFLAGS)
+LOCAL_CPPFLAGS := $(LIBCXXABI_CPPFLAGS)
+LOCAL_LDFLAGS := -lpthread
+LOCAL_RTTI_FLAG := $(LIBCXXABI_RTTI_FLAG)
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/include/unwind.h b/include/unwind.h
index c5acd93..50e2d4b 100644
--- a/include/unwind.h
+++ b/include/unwind.h
@@ -83,7 +83,7 @@ extern "C" {
//
// The following are the base functions documented by the C++ ABI
//
-#if __arm__
+#if _LIBUNWIND_BUILD_SJLJ_APIS
extern _Unwind_Reason_Code
_Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object);
extern void _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object);
diff --git a/src/Unwind/AddressSpace.hpp b/src/Unwind/AddressSpace.hpp
index fafee04..ff8c8b0 100644
--- a/src/Unwind/AddressSpace.hpp
+++ b/src/Unwind/AddressSpace.hpp
@@ -298,7 +298,7 @@ inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t &fde) {
inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
size_t bufLen,
unw_word_t *offset) {
- dl_info dyldInfo;
+ Dl_info dyldInfo;
if (dladdr((void *)addr, &dyldInfo)) {
if (dyldInfo.dli_sname != NULL) {
strlcpy(buf, dyldInfo.dli_sname, bufLen);
diff --git a/src/Unwind/UnwindCursor.hpp b/src/Unwind/UnwindCursor.hpp
index 235922f..035e471 100644
--- a/src/Unwind/UnwindCursor.hpp
+++ b/src/Unwind/UnwindCursor.hpp
@@ -151,10 +151,12 @@ void DwarfFDECache<A>::removeAllIn(pint_t mh) {
_LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock));
}
+#if __APPLE__
template <typename A>
void DwarfFDECache<A>::dyldUnloadHook(const struct mach_header *mh, intptr_t ) {
removeAllIn((pint_t) mh);
}
+#endif
template <typename A>
void DwarfFDECache<A>::iterateCacheEntries(void (*func)(
@@ -363,6 +365,7 @@ private:
class _LIBUNWIND_HIDDEN AbstractUnwindCursor {
public:
+ virtual ~AbstractUnwindCursor() {}
virtual bool validReg(int) = 0;
virtual unw_word_t getReg(int) = 0;
virtual void setReg(int, unw_word_t) = 0;
diff --git a/src/Unwind/config.h b/src/Unwind/config.h
index 7d7e6bf..5aaadaf 100644
--- a/src/Unwind/config.h
+++ b/src/Unwind/config.h
@@ -43,7 +43,7 @@
#define _LIBUNWIND_SUPPORT_FRAME_APIS (__i386__ || __x86_64__)
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
- #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
+ #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg, __VA_ARGS__)
#define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg)
#if FOR_DYLD
@@ -56,6 +56,18 @@
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
#endif
+#elif defined(__BIONIC__)
+ #define _LIBUNWIND_BUILD_ZERO_COST_APIS (__i386__ || __x86_64__ || __arm64__ || __arm__)
+ #define _LIBUNWIND_BUILD_SJLJ_APIS 0
+ #define _LIBUNWIND_SUPPORT_FRAME_APIS (__i386__ || __x86_64__)
+ #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
+ #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+ #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg, __VA_ARGS__)
+ #define _LIBUNWIND_ABORT(msg) __assert2(__FILE__, __LINE__, __func__, msg)
+
+ #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
+ #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+ #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
#else
// #define _LIBUNWIND_BUILD_ZERO_COST_APIS
// #define _LIBUNWIND_BUILD_SJLJ_APIS
diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
index 744dddd..787d8a8 100644
--- a/src/cxa_exception.cpp
+++ b/src/cxa_exception.cpp
@@ -232,7 +232,7 @@ __cxa_throw(void* thrown_object, std::type_info* tinfo, void (*dest)(void*))
globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
-#if __arm__
+#if _LIBUNWIND_BUILD_SJLJ_APIS
_Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
#else
_Unwind_RaiseException(&exception_header->unwindHeader);
@@ -465,7 +465,7 @@ __cxa_rethrow()
// nothing
globals->caughtExceptions = 0;
}
-#if __arm__
+#if _LIBUNWIND_BUILD_SJLJ_APIS
_Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
#else
_Unwind_RaiseException(&exception_header->unwindHeader);
@@ -594,7 +594,7 @@ __cxa_rethrow_primary_exception(void* thrown_object)
setDependentExceptionClass(&dep_exception_header->unwindHeader);
__cxa_get_globals()->uncaughtExceptions += 1;
dep_exception_header->unwindHeader.exception_cleanup = dependent_exception_cleanup;
-#if __arm__
+#if _LIBUNWIND_BUILD_SJLJ_APIS
_Unwind_SjLj_RaiseException(&dep_exception_header->unwindHeader);
#else
_Unwind_RaiseException(&dep_exception_header->unwindHeader);
diff --git a/src/cxa_personality.cpp b/src/cxa_personality.cpp
index 81104b8..32a3127 100644
--- a/src/cxa_personality.cpp
+++ b/src/cxa_personality.cpp
@@ -838,7 +838,7 @@ _UA_CLEANUP_PHASE
*/
_Unwind_Reason_Code
-#if __arm__
+#if _LIBUNWIND_BUILD_SJLJ_APIS
__gxx_personality_sj0
#else
__gxx_personality_v0