Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 745813 | Differences between
and this patch

Collapse All | Expand All

(-)libreoffice-6.4.7.2.orig/bridges/source/cpp_uno/gcc3_linux_aarch64/abi.cxx (+53 lines)
Lines 137-142 Link Here
137
extern "C" void _GLIBCXX_CDTOR_CALLABI deleteException(void * exception) {
137
extern "C" void _GLIBCXX_CDTOR_CALLABI deleteException(void * exception) {
138
    abi_aarch64::__cxa_exception * header =
138
    abi_aarch64::__cxa_exception * header =
139
        static_cast<abi_aarch64::__cxa_exception *>(exception) - 1;
139
        static_cast<abi_aarch64::__cxa_exception *>(exception) - 1;
140
#if !defined MACOSX && defined _LIBCPPABI_VERSION // detect libc++abi
141
    // First, the libcxxabi commit
142
    // <http://llvm.org/viewvc/llvm-project?view=revision&revision=303175>
143
    // "[libcxxabi] Align unwindHeader on a double-word boundary" towards
144
    // LLVM 5.0 changed the size of __cxa_exception by adding
145
    //
146
    //   __attribute__((aligned))
147
    //
148
    // to the final member unwindHeader, on x86-64 effectively adding a hole of
149
    // size 8 in front of that member (changing its offset from 88 to 96,
150
    // sizeof(__cxa_exception) from 120 to 128, and alignof(__cxa_exception)
151
    // from 8 to 16); the "header1" hack below to dynamically determine whether we run against a
152
    // LLVM 5 libcxxabi is to look at the exceptionDestructor member, which must
153
    // point to this function (the use of __cxa_exception in mapException is
154
    // unaffected, as it only accesses members towards the start of the struct,
155
    // through a pointer known to actually point at the start).  The libcxxabi commit
156
    // <https://github.com/llvm/llvm-project/commit/9ef1daa46edb80c47d0486148c0afc4e0d83ddcf>
157
    // "Insert padding before the __cxa_exception header to ensure the thrown" in LLVM 6
158
    // removes the need for this hack, so the "header1" hack can be removed again once we can be
159
    // sure that we only run against libcxxabi from LLVM >= 6.
160
    //
161
    // Second, the libcxxabi commit
162
    // <https://github.com/llvm/llvm-project/commit/674ec1eb16678b8addc02a4b0534ab383d22fa77>
163
    // "[libcxxabi] Insert padding in __cxa_exception struct for compatibility" in LLVM 10 changed
164
    // the layout of the start of __cxa_exception to
165
    //
166
    //  [8 byte  void *reserve]
167
    //   8 byte  size_t referenceCount
168
    //
169
    // so the "header2" hack below to dynamically determine whether we run against a LLVM >= 10
170
    // libcxxabi is to look whether the exceptionDestructor (with its known value) has increased its
171
    // offset by 8.  As described in the definition of __cxa_exception
172
    // (bridges/source/cpp_uno/gcc3_linux_aarch64/abi.hxx), the "header2" hack (together with the
173
    // "#ifdef MACOSX" in the definition of __cxa_exception and the corresponding hack in call in
174
    // bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx) can be dropped once we can be sure
175
    // that we only run against new libcxxabi that has the reserve member.
176
    if (header->exceptionDestructor != &deleteException) {
177
        auto const header1 = reinterpret_cast<__cxxabiv1::__cxa_exception *>(
178
            reinterpret_cast<char *>(header) - 8);
179
        if (header1->exceptionDestructor == &deleteException) {
180
            header = header1;
181
        } else {
182
            auto const header2 = reinterpret_cast<__cxxabiv1::__cxa_exception *>(
183
            reinterpret_cast<char *>(header) + 8);
184
            if (header2->exceptionDestructor == &deleteException) {
185
                header = header2;
186
            } else {
187
                assert(false);
188
            }
189
        }
190
    }
191
#endif
192
    assert(header->exceptionDestructor == &deleteException);
140
    OUString unoName(toUnoName(header->exceptionType->name()));
193
    OUString unoName(toUnoName(header->exceptionType->name()));
141
    typelib_TypeDescription * td = 0;
194
    typelib_TypeDescription * td = 0;
142
    typelib_typedescription_getByName(&td, unoName.pData);
195
    typelib_typedescription_getByName(&td, unoName.pData);
(-)a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx (+53 lines)
Lines 82-87 extern "C" { Link Here
82
static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc )
82
static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc )
83
{
83
{
84
    __cxxabiv1::__cxa_exception const * header = static_cast<__cxxabiv1::__cxa_exception const *>(pExc) - 1;
84
    __cxxabiv1::__cxa_exception const * header = static_cast<__cxxabiv1::__cxa_exception const *>(pExc) - 1;
85
#if defined _LIBCPPABI_VERSION // detect libc++abi
86
    // First, the libcxxabi commit
87
    // <http://llvm.org/viewvc/llvm-project?view=revision&revision=303175>
88
    // "[libcxxabi] Align unwindHeader on a double-word boundary" towards
89
    // LLVM 5.0 changed the size of __cxa_exception by adding
90
    //
91
    //   __attribute__((aligned))
92
    //
93
    // to the final member unwindHeader, on x86-64 effectively adding a hole of
94
    // size 8 in front of that member (changing its offset from 88 to 96,
95
    // sizeof(__cxa_exception) from 120 to 128, and alignof(__cxa_exception)
96
    // from 8 to 16); the "header1" hack below to dynamically determine whether we run against a
97
    // LLVM 5 libcxxabi is to look at the exceptionDestructor member, which must
98
    // point to this function (the use of __cxa_exception in fillUnoException is
99
    // unaffected, as it only accesses members towards the start of the struct,
100
    // through a pointer known to actually point at the start).  The libcxxabi commit
101
    // <https://github.com/llvm/llvm-project/commit/9ef1daa46edb80c47d0486148c0afc4e0d83ddcf>
102
    // "Insert padding before the __cxa_exception header to ensure the thrown" in LLVM 6
103
    // removes the need for this hack, so the "header1" hack can be removed again once we can be
104
    // sure that we only run against libcxxabi from LLVM >= 6.
105
    //
106
    // Second, the libcxxabi commit
107
    // <https://github.com/llvm/llvm-project/commit/674ec1eb16678b8addc02a4b0534ab383d22fa77>
108
    // "[libcxxabi] Insert padding in __cxa_exception struct for compatibility" in LLVM 10 changed
109
    // the layout of the start of __cxa_exception to
110
    //
111
    //  [8 byte  void *reserve]
112
    //   8 byte  size_t referenceCount
113
    //
114
    // so the "header2" hack below to dynamically determine whether we run against a LLVM >= 10
115
    // libcxxabi is to look whether the exceptionDestructor (with its known value) has increased its
116
    // offset by 8.  As described in the definition of __cxa_exception
117
    // (bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx), the "header2" hack (together with the
118
    // "#if 0" in the definition of __cxa_exception and the corresponding hack in fillUnoException)
119
    // can be dropped once we can be sure that we only run against new libcxxabi that has the
120
    // reserve member.
121
    if (header->exceptionDestructor != &deleteException) {
122
        auto const header1 = reinterpret_cast<__cxa_exception const *>(
123
            reinterpret_cast<char const *>(header) - 8);
124
        if (header1->exceptionDestructor == &deleteException) {
125
            header = header1;
126
        } else {
127
            auto const header2 = reinterpret_cast<__cxa_exception const *>(
128
                reinterpret_cast<char const *>(header) + 8);
129
            if (header2->exceptionDestructor == &deleteException) {
130
                header = header2;
131
            } else {
132
                assert(false);
133
            }
134
        }
135
    }
136
#endif
137
    assert(header->exceptionDestructor == &deleteException);
85
    typelib_TypeDescription * pTD = nullptr;
138
    typelib_TypeDescription * pTD = nullptr;
86
    OUString unoName( toUNOname( header->exceptionType->name() ) );
139
    OUString unoName( toUNOname( header->exceptionType->name() ) );
87
    ::typelib_typedescription_getByName( &pTD, unoName.pData );
140
    ::typelib_typedescription_getByName( &pTD, unoName.pData );

Return to bug 745813