summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-02-11 15:46:45 +0100
committerJan Holesovsky <kendy@collabora.com>2020-08-04 13:43:00 +0200
commit8b1a1036f254dc8c68a4a067ec368abea5b27e83 (patch)
tree2b1ce3ee57bb1ddf78c3b9b6425a057db008fc3c
parent666fb8d3c6f5af94450d1f1b2249293fec0fe722 (diff)
Hack to dynamically adapt to __cxa_exceptiom in LLVM 5.0 libcxxabi
...for Linux aarch64, similar to 7a9dd3d482deeeb3ed1d50074e56adbd3f928296 "Hack to dynamically adapt to __cxa_exceptiom in LLVM 5.0 libcxxabi" for macOS x86-64. But unlike on macOS (which is known to always use libcxxabi), be careful to only execute the hack in builds targeting libcxxabi. Change-Id: I5417fde425d2d6bac9400592193a9fe5d2bfe175 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88458 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100013 Tested-by: Jan Holesovsky <kendy@collabora.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx
index 462efc7b41d1..02d7bcd9aa9d 100644
--- a/bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx
@@ -136,6 +136,28 @@ std::type_info * getRtti(typelib_TypeDescription const & type) {
extern "C" void _GLIBCXX_CDTOR_CALLABI deleteException(void * exception) {
__cxxabiv1::__cxa_exception * header =
static_cast<__cxxabiv1::__cxa_exception *>(exception) - 1;
+#if defined _LIBCPPABI_VERSION // detect libc++abi
+ // The libcxxabi commit
+ // <http://llvm.org/viewvc/llvm-project?view=revision&revision=303175>
+ // "[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<char const *>(header) - 8);
+ assert(header->exceptionDestructor == &deleteException);
+ }
+#endif
OUString unoName(toUnoName(header->exceptionType->name()));
typelib_TypeDescription * td = 0;
typelib_typedescription_getByName(&td, unoName.pData);