Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editors/openoffice-4: make robust against __cxa_exception ABI changes
Patch openoffice to replace __cxa_get_globals()->caughtExceptions, which is a pointer to the start of a struct __cxa_exception, with __cxa_current_primary_exception(), which is a pointer to the end. This allows struct __cxa_exception to be extended at the start as was recently done in FreeBSD main and stable/13 on 64-bit architectures. Recently on FreeBSD main and stable/13 __attribute__((__aligned__)) was added to struct _Unwind_Exception which changes its size on 32-bit architectures, and that of __cxa_exception as well. Patch openoffice to detect this so packages built on 13.0 still work on 13.1. Add a build dependency on a recent version of devel/libunwind so we always build with an unwind.h that has the right definition of _Unwind_Exception. (cherry picked from commit 88045c0)
- Loading branch information
1 parent
a53915e
commit d86952d
Showing
6 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__intel_except.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx.orig 2019-09-17 22:55:10 UTC | ||
+++ bridges/source/cpp_uno/gcc3_freebsd_intel/except.cxx | ||
@@ -220,6 +220,12 @@ static void deleteException( void * pExc ) | ||
static void deleteException( void * pExc ) | ||
{ | ||
__cxa_exception const * header = ((__cxa_exception const *)pExc - 1); | ||
+ if (header->exceptionDestructor != &deleteException) { | ||
+ // _Unwind_Exception was made __aligned__ which | ||
+ // increased its size by 12 bytes | ||
+ header = reinterpret_cast<__cxa_exception const *>( | ||
+ reinterpret_cast<char const *>( header ) - 12 ); | ||
+ } | ||
typelib_TypeDescription * pTD = 0; | ||
OUString unoName( toUNOname( header->exceptionType->name() ) ); | ||
::typelib_typedescription_getByName( &pTD, unoName.pData ); |
49 changes: 49 additions & 0 deletions
49
editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__intel_uno2cpp.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx.orig 2019-09-17 22:55:10 UTC | ||
+++ bridges/source/cpp_uno/gcc3_freebsd_intel/uno2cpp.cxx | ||
@@ -44,9 +44,12 @@ using namespace ::com::sun::star::uno; | ||
using namespace ::rtl; | ||
using namespace ::com::sun::star::uno; | ||
#ifdef __GLIBCXX__ | ||
+using CPPU_CURRENT_NAMESPACE::__cxa_exception; | ||
using CPPU_CURRENT_NAMESPACE::__cxa_get_globals; | ||
#else | ||
-using __cxxabiv1::__cxa_get_globals; | ||
+using __cxxabiv1::__cxa_exception; | ||
+using __cxxabiv1::__cxa_current_primary_exception; | ||
+using __cxxabiv1::__cxa_decrement_exception_refcount; | ||
#endif | ||
|
||
namespace | ||
@@ -313,8 +316,31 @@ static void cpp_call( | ||
} | ||
catch (...) | ||
{ | ||
+ __cxa_exception *header; | ||
+#ifdef __GLIBCXX__ | ||
+ header = __cxa_get_globals()->caughtExceptions; | ||
+#else | ||
+ header = reinterpret_cast<__cxa_exception *>( __cxa_current_primary_exception() ); | ||
+ if (header) { | ||
+ __cxa_decrement_exception_refcount( header ); | ||
+ header--; | ||
+ uint64_t exc_class = header->unwindHeader.exception_class | ||
+ & 0xffffffffffffff00; | ||
+ if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) { | ||
+ // _Unwind_Exception was made __aligned__ which | ||
+ // increased its size by 12 bytes. | ||
+ header = reinterpret_cast<__cxa_exception *>( | ||
+ reinterpret_cast<char *>( header ) - 12 ); | ||
+ exc_class = header->unwindHeader.exception_class | ||
+ & 0xffffffffffffff00; | ||
+ if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) { | ||
+ header = nullptr; | ||
+ } | ||
+ } | ||
+ } | ||
+#endif | ||
// fill uno exception | ||
- CPPU_CURRENT_NAMESPACE::fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
+ CPPU_CURRENT_NAMESPACE::fillUnoException( header, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
|
||
// temporary params | ||
for ( ; nTempIndizes--; ) |
43 changes: 43 additions & 0 deletions
43
editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_share.hxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx.orig 2019-09-17 22:55:10 UTC | ||
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx | ||
@@ -35,6 +35,7 @@ namespace CPPU_CURRENT_NAMESPACE | ||
|
||
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h | ||
|
||
+#ifdef __GLIBCXX__ | ||
struct _Unwind_Exception | ||
{ | ||
unsigned exception_class __attribute__((__mode__(__DI__))); | ||
@@ -63,18 +64,21 @@ struct __cxa_exception | ||
|
||
_Unwind_Exception unwindHeader; | ||
}; | ||
+#endif /* __GLIBCXX__ */ | ||
|
||
extern "C" void *__cxa_allocate_exception( | ||
std::size_t thrown_size ) throw(); | ||
extern "C" void __cxa_throw ( | ||
void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); | ||
|
||
+#ifdef __GLIBCXX__ | ||
struct __cxa_eh_globals | ||
{ | ||
__cxa_exception *caughtExceptions; | ||
unsigned int uncaughtExceptions; | ||
}; | ||
extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); | ||
+#endif /* __GLIBCXX__ */ | ||
|
||
// ----- | ||
|
||
@@ -82,6 +86,10 @@ void raiseException( | ||
void raiseException( | ||
uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); | ||
//================================================================================================== | ||
+#ifndef __GLIBCXX__ | ||
+using __cxxabiv1:: __cxa_exception; | ||
+#endif /* __GLIBCXX__ */ | ||
+ | ||
void fillUnoException( | ||
__cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); | ||
} |
38 changes: 38 additions & 0 deletions
38
...ors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx.orig 2019-09-17 22:55:10 UTC | ||
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx | ||
@@ -42,6 +42,14 @@ using namespace ::com::sun::star::uno; | ||
|
||
using namespace ::rtl; | ||
using namespace ::com::sun::star::uno; | ||
+#ifdef __GLIBCXX__ | ||
+using CPPU_CURRENT_NAMESPACE::__cxa_exception; | ||
+using CPPU_CURRENT_NAMESPACE::__cxa_get_globals; | ||
+#else | ||
+using __cxxabiv1::__cxa_exception; | ||
+using __cxxabiv1::__cxa_current_primary_exception; | ||
+using __cxxabiv1::__cxa_decrement_exception_refcount; | ||
+#endif | ||
|
||
void MapReturn(long r3, double dret, typelib_TypeClass eTypeClass, void *pRegisterReturn) | ||
{ | ||
@@ -448,9 +456,18 @@ static void cpp_call( | ||
} | ||
catch (...) | ||
{ | ||
+ __cxa_exception *header; | ||
+#ifdef __GLIBCXX__ | ||
+ header = __cxa_get_globals()->caughtExceptions; | ||
+#else | ||
+ header = reinterpret_cast<__cxa_exception *>( __cxa_current_primary_exception() ); | ||
+ if (header) { | ||
+ __cxa_decrement_exception_refcount( header ); | ||
+ header--; | ||
+ } | ||
+#endif | ||
// fill uno exception | ||
- fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, | ||
- *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
+ CPPU_CURRENT_NAMESPACE::fillUnoException( header, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
|
||
// temporary params | ||
for ( ; nTempIndizes--; ) |
36 changes: 36 additions & 0 deletions
36
editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__x86-64_uno2cpp.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx.orig 2019-09-17 22:55:10 UTC | ||
+++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx | ||
@@ -50,9 +50,12 @@ using namespace ::com::sun::star::uno; | ||
using namespace ::rtl; | ||
using namespace ::com::sun::star::uno; | ||
#ifdef __GLIBCXX__ | ||
+using CPPU_CURRENT_NAMESPACE::__cxa_exception; | ||
using CPPU_CURRENT_NAMESPACE::__cxa_get_globals; | ||
#else | ||
-using __cxxabiv1::__cxa_get_globals; | ||
+using __cxxabiv1::__cxa_exception; | ||
+using __cxxabiv1::__cxa_current_primary_exception; | ||
+using __cxxabiv1::__cxa_decrement_exception_refcount; | ||
#endif | ||
|
||
//================================================================================================== | ||
@@ -452,8 +455,18 @@ static void cpp_call( | ||
} | ||
catch (...) | ||
{ | ||
+ __cxa_exception *header; | ||
+#ifdef __GLIBCXX__ | ||
+ header = __cxa_get_globals()->caughtExceptions; | ||
+#else | ||
+ header = reinterpret_cast<__cxa_exception *>( __cxa_current_primary_exception() ); | ||
+ if (header) { | ||
+ __cxa_decrement_exception_refcount( header ); | ||
+ header--; | ||
+ } | ||
+#endif | ||
// fill uno exception | ||
- CPPU_CURRENT_NAMESPACE::fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
+ CPPU_CURRENT_NAMESPACE::fillUnoException( header, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); | ||
|
||
// temporary params | ||
for ( ; nTempIndizes--; ) |