From 7a9dd3d482deeeb3ed1d50074e56adbd3f928296 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 19 Jun 2017 21:48:12 +0200 Subject: Hack to dynamically adapt to __cxa_exceptiom in LLVM 5.0 libcxxabi Change-Id: Ibf6379425d312b2cc2c9d663a65d0e02209f74e4 Reviewed-on: https://gerrit.libreoffice.org/38981 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- bridges/source/cpp_uno/gcc3_macosx_x86-64/except.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'bridges') diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/except.cxx index 53fb3c8cabc0..1d1eeccd97ae 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/except.cxx @@ -256,6 +256,26 @@ std::type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) static void deleteException( void * pExc ) { __cxa_exception const * header = static_cast<__cxa_exception const *>(pExc) - 1; + // The libcxxabi commit + // + // "[libcxxabi] Align unwindHeader on a double-word boundary" towards + // LLVM 5.0 changed the size of __cxa_exception by adding + // + // __attribute__((aligned)) + // + // to the final member unwindHeader, on x86-64 effectively adding a hole of + // size 8 in front of that member (changing its offset from 88 to 96, + // sizeof(__cxa_exception) from 120 to 128, and alignof(__cxa_exception) + // from 8 to 16); a hack to dynamically determine whether we run against a + // new libcxxabi is to look at the exceptionDestructor member, which must + // point to this function (the use of __cxa_exception in fillUnoException is + // unaffected, as it only accesses members towards the start of the struct, + // through a pointer known to actually point at the start): + if (header->exceptionDestructor != &deleteException) { + header = reinterpret_cast<__cxa_exception const *>( + reinterpret_cast(header) - 8); + assert(header->exceptionDestructor == &deleteException); + } typelib_TypeDescription * pTD = nullptr; OUString unoName( toUNOname( header->exceptionType->name() ) ); ::typelib_typedescription_getByName( &pTD, unoName.pData ); -- cgit