diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-12-13 07:23:04 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-12-13 09:53:50 +0100 |
commit | 222cea83418ce74cdfcea8f5a0bf8754df930254 (patch) | |
tree | 68024ddaac2032e32bee9d7a00688a1f8eddcdb7 /bridges | |
parent | 115268087dea599d4248213b1085d07275c0a007 (diff) |
Fix getRTTI for Android x86
First, make sure existing compiler-generated RTTI from liblo-native-code.so is
found (so that catching bridge-synthesized exceptions in native code works with
libc++abi, which checks type equivalence by address instead of string
comparsion), by using the dlsym(RTLD_DEFAULT,...) mechanism as in the ANDROID
gcc3_linux_arm bridge case. And second, if that should fail, synthesize the
type_info even if the included cxxabi.h doesn't provide the relevant type
declarations, by using copies from the ABI specification, as also done on other
platforms.
Instead of always having getRTTI fail and raiseException throw a non-synthesized
css::uno::RuntimeException("no rtti for type ..."). Which explains the mystery
discussed in the commit message of 312eeeee42cb4a1e356943e17305555e41afc4ef
"Switch Android armeabi-v7a to libc++/libc++abi/libunwind too", why the observed
misbehavior on x86 was so different from that on armeabi-v7a.
Change-Id: I9308654c5c2b88b4d27e0e8e9edda1849133a161
Reviewed-on: https://gerrit.libreoffice.org/65070
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'bridges')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_intel/except.cxx | 18 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_intel/share.hxx | 27 |
2 files changed, 37 insertions, 8 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx index 1438312d90ff..3a8e5753b053 100644 --- a/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx @@ -90,7 +90,9 @@ class RTTI t_rtti_map m_rttis; t_rtti_map m_generatedRttis; +#if defined ANDROID void * m_hApp; +#endif public: RTTI(); @@ -100,13 +102,17 @@ public: }; RTTI::RTTI() +#if !defined ANDROID : m_hApp( dlopen(nullptr, RTLD_LAZY) ) +#endif { } RTTI::~RTTI() { +#if !defined ANDROID dlclose( m_hApp ); +#endif } @@ -135,7 +141,11 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) buf.append( 'E' ); OString symName( buf.makeStringAndClear() ); +#if !defined ANDROID rtti = static_cast<type_info *>(dlsym( m_hApp, symName.getStr() )); +#else + rtti = static_cast<type_info *>(dlsym( RTLD_DEFAULT, symName.getStr() )); +#endif if (rtti) { @@ -156,9 +166,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) #if OSL_DEBUG_LEVEL > 1 fprintf( stderr,"generated rtti for %s\n", rttiName ); #endif -// TODO: incompatible with llvm-c++ in ndk16 - no __si_class_type_info or __class_type_info -// either do as iOS one and inline thing or find another way -#if !defined(ANDROID) if (pTypeDescr->pBaseTypeDescription) { // ensure availability of base @@ -176,9 +183,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) pair< t_rtti_map::iterator, bool > insertion( m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); SAL_WARN_IF( !insertion.second, "bridges", "### inserting new generated rtti failed?!" ); -#else - (void) rttiName; // silence -Wunused-variable -#endif } else // taking already generated rtti { @@ -244,9 +248,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) static RTTI rtti_data; rtti = rtti_data.getRTTI(reinterpret_cast<typelib_CompoundTypeDescription*>(pTypeDescr)); TYPELIB_DANGER_RELEASE( pTypeDescr ); -#if !defined(ANDROID) // see TODO above assert(rtti && "### no rtti for throwing exception!"); -#endif if (! rtti) { throw RuntimeException( diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx b/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx index fb8f25353918..39325c84e7ea 100644 --- a/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx @@ -33,6 +33,33 @@ #include <uno/any2.h> #include <uno/mapping.h> +#if !HAVE_CXXABI_H_CLASS_TYPE_INFO +// <https://mentorembedded.github.io/cxx-abi/abi.html>, +// libstdc++-v3/libsupc++/cxxabi.h: +namespace __cxxabiv1 { +class __class_type_info: public std::type_info { +public: + explicit __class_type_info(char const * n): type_info(n) {} + ~__class_type_info() override; +}; +} +#endif + +#if !HAVE_CXXABI_H_SI_CLASS_TYPE_INFO +// <https://mentorembedded.github.io/cxx-abi/abi.html>, +// libstdc++-v3/libsupc++/cxxabi.h: +namespace __cxxabiv1 { +class __si_class_type_info: public __class_type_info { +public: + __class_type_info const * __base_type; + explicit __si_class_type_info( + char const * n, __class_type_info const *base): + __class_type_info(n), __base_type(base) {} + ~__si_class_type_info() override; +}; +} +#endif + namespace CPPU_CURRENT_NAMESPACE { |