From 86560e6a675ea409c1f8408c38facfdfb904be72 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 13 Dec 2018 07:23:04 +0100 Subject: 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 --- bridges/source/cpp_uno/gcc3_linux_intel/except.cxx | 10 ++++++++ bridges/source/cpp_uno/gcc3_linux_intel/share.hxx | 27 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx index 6bbcfb2565c1..d5567ed6216c 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(dlsym( m_hApp, symName.getStr() )); +#else + rtti = static_cast(dlsym( RTLD_DEFAULT, symName.getStr() )); +#endif if (rtti) { diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx b/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx index d167bf25c584..5b9792405462 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 #include "uno/mapping.h" +#if !HAVE_CXXABI_H_CLASS_TYPE_INFO +// , +// 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 +// , +// 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 { -- cgit v1.2.3