aboutsummaryrefslogtreecommitdiff
path: root/contrib/libcxxrt
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-03-13 13:54:24 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-03-13 13:54:24 +0000
commit9097e3cbcac455eb0dedd097d8d5548c72568d0a (patch)
tree902c6a466fef8a19046a9f310d6b71fcf45cbeea /contrib/libcxxrt
parent653ed678c70376b15cdc42daafa7b4554570cea2 (diff)
downloadsrc-9097e3cbcac455eb0dedd097d8d5548c72568d0a.tar.gz
src-9097e3cbcac455eb0dedd097d8d5548c72568d0a.zip
Diffstat (limited to 'contrib/libcxxrt')
-rw-r--r--contrib/libcxxrt/exception.cc30
-rw-r--r--contrib/libcxxrt/unwind-arm.h2
-rw-r--r--contrib/libcxxrt/unwind-itanium.h9
3 files changed, 28 insertions, 13 deletions
diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc
index 0fb26ddb4ed2..0de878e9e6db 100644
--- a/contrib/libcxxrt/exception.cc
+++ b/contrib/libcxxrt/exception.cc
@@ -572,6 +572,19 @@ static void free_exception(char *e)
}
}
+#ifdef __LP64__
+/**
+ * There's an ABI bug in __cxa_exception: unwindHeader requires 16-byte
+ * alignment but it was broken by the addition of the referenceCount.
+ * The unwindHeader is at offset 0x58 in __cxa_exception. In order to keep
+ * compatibility with consumers of the broken __cxa_exception, explicitly add
+ * padding on allocation (and account for it on free).
+ */
+static const int exception_alignment_padding = 8;
+#else
+static const int exception_alignment_padding = 0;
+#endif
+
/**
* Allocates an exception structure. Returns a pointer to the space that can
* be used to store an object of thrown_size bytes. This function will use an
@@ -580,16 +593,19 @@ static void free_exception(char *e)
*/
extern "C" void *__cxa_allocate_exception(size_t thrown_size)
{
- size_t size = thrown_size + sizeof(__cxa_exception);
+ size_t size = exception_alignment_padding + sizeof(__cxa_exception) +
+ thrown_size;
char *buffer = alloc_or_die(size);
- return buffer+sizeof(__cxa_exception);
+ return buffer + exception_alignment_padding + sizeof(__cxa_exception);
}
extern "C" void *__cxa_allocate_dependent_exception(void)
{
- size_t size = sizeof(__cxa_dependent_exception);
+ size_t size = exception_alignment_padding +
+ sizeof(__cxa_dependent_exception);
char *buffer = alloc_or_die(size);
- return buffer+sizeof(__cxa_dependent_exception);
+ return buffer + exception_alignment_padding +
+ sizeof(__cxa_dependent_exception);
}
/**
@@ -617,7 +633,8 @@ extern "C" void __cxa_free_exception(void *thrown_exception)
}
}
- free_exception(reinterpret_cast<char*>(ex));
+ free_exception(reinterpret_cast<char*>(ex) -
+ exception_alignment_padding);
}
static void releaseException(__cxa_exception *exception)
@@ -644,7 +661,8 @@ void __cxa_free_dependent_exception(void *thrown_exception)
{
releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
}
- free_exception(reinterpret_cast<char*>(ex));
+ free_exception(reinterpret_cast<char*>(ex) -
+ exception_alignment_padding);
}
/**
diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h
index ec81237e573b..6eb9d9e45981 100644
--- a/contrib/libcxxrt/unwind-arm.h
+++ b/contrib/libcxxrt/unwind-arm.h
@@ -97,7 +97,7 @@ struct _Unwind_Exception
} pr_cache;
/** Force alignment of next item to 8-byte boundary */
long long int :0;
-} __attribute__((__aligned__(8)));
+};
/* Unwinding functions */
_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *ucbp);
diff --git a/contrib/libcxxrt/unwind-itanium.h b/contrib/libcxxrt/unwind-itanium.h
index 199d91de283d..1ee0cf0e81c4 100644
--- a/contrib/libcxxrt/unwind-itanium.h
+++ b/contrib/libcxxrt/unwind-itanium.h
@@ -79,12 +79,9 @@ struct _Unwind_Exception
{
uint64_t exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
- uintptr_t private_1;
- uintptr_t private_2;
-#if __SIZEOF_POINTER__ == 4
- uint32_t reserved[3];
-#endif
- } __attribute__((__aligned__));
+ unsigned long private_1;
+ unsigned long private_2;
+ } ;
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,