summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-05-11 05:58:52 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-05-11 05:58:52 +0000
commite8b16fa9d547942f8d68af852fb1b25aae85f2a5 (patch)
tree5ec9c3a14068040626ded062db68ccae97906a87 /test
parent97146e2a61d690531be6441da3a482e6603832ad (diff)
[libcxxabi] Align unwindHeader on a double-word boundary.
r276215 made a change to annotate _Unwind_Exception with attribute "aligned" so that an exception object following field __cxa_exception is sufficiently aligned. This fix hasn't been incorporated to unwind.h on Darwin since it is an ABI breaking change. Instead of annotating struct _Unwind_Exception with the attribute, this commit annotates field unwindHeader of __cxa_exception. This ensures the exception object is sufficiently aligned without breaking the ABI. rdar://problem/25364625 Differential Revision: https://reviews.llvm.org/D33030 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@302763 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/exception_object_alignment.sh.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/exception_object_alignment.sh.cpp b/test/exception_object_alignment.sh.cpp
new file mode 100644
index 0000000..076f45c
--- /dev/null
+++ b/test/exception_object_alignment.sh.cpp
@@ -0,0 +1,46 @@
+//===---------------- exception_object_alignment.sh.cpp -------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcxxabi-no-exceptions
+
+// RUN: %cxx %flags %compile_flags -O1 %s -o %t.exe
+// RUN: %exec %t.exe
+
+// This test used to segfault on Darwin because field unwindHeader of struct
+// __cxa_exception was not 16B aligned.
+
+namespace {
+
+struct S {
+ int a;
+ int __attribute__((aligned(16))) b;
+};
+
+class base1 {
+protected:
+ virtual ~base1() throw() {}
+};
+
+class derived: public base1 {
+public:
+ derived() : member() {}
+private:
+ S member;
+};
+
+}
+
+int main() {
+ try {
+ throw derived();
+ }
+ catch(...) {
+ }
+ return 0;
+}