diff options
author | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2017-04-04 14:03:54 +0000 |
---|---|---|
committer | Asiri Rathnayake <asiri.rathnayake@arm.com> | 2017-04-04 14:03:54 +0000 |
commit | 0a3a1a8a5ca5ef69e0f6b7d5b9d13e63e6fd2c19 (patch) | |
tree | 4eba99dfb042196bbb549089395675de62996905 /test/test_exception_address_alignment.pass.cpp | |
parent | 66db5e3ea75d0f8a9c4f6e7f4672bc219c326ab8 (diff) |
Fix exception address alignment test for EHABI
This test fails on ARM bare-metal targets because it assumes the Itanium ABI,
whereas EHABI requires the exception address to be 8-byte aligned.
I was a bit puzzled at first because this should've failed on the public
arm-linux builder too. I think the reason it passes there is because we don't
include libunwind headers in the include path when running the libcxxabi tests,
so the system unwind.h gets picked up.
Reviewers: rengolin, EricWF
Differential revision: https://reviews.llvm.org/D31178
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@299435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/test_exception_address_alignment.pass.cpp')
-rw-r--r-- | test/test_exception_address_alignment.pass.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test/test_exception_address_alignment.pass.cpp b/test/test_exception_address_alignment.pass.cpp index 8a41f0c..138fb4d 100644 --- a/test/test_exception_address_alignment.pass.cpp +++ b/test/test_exception_address_alignment.pass.cpp @@ -15,8 +15,8 @@ // working around this failure. // XFAIL: darwin && libcxxabi-has-system-unwinder -// Test that the address of the exception object is properly aligned to the -// largest supported alignment for the system. +// Test that the address of the exception object is properly aligned as required +// by the relevant ABI #include <cstdint> #include <cassert> @@ -24,7 +24,16 @@ #include <unwind.h> struct __attribute__((aligned)) AlignedType {}; -static_assert(alignof(AlignedType) == alignof(_Unwind_Exception), + +// EHABI : 8-byte aligned +// Itanium: Largest supported alignment for the system +#if defined(_LIBUNWIND_ARM_EHABI) +# define EXPECTED_ALIGNMENT 8 +#else +# define EXPECTED_ALIGNMENT alignof(AlignedType) +#endif + +static_assert(alignof(_Unwind_Exception) == EXPECTED_ALIGNMENT, "_Unwind_Exception is incorrectly aligned. This test is expected to fail"); struct MinAligned { }; @@ -35,7 +44,7 @@ int main() { try { throw MinAligned{}; } catch (MinAligned const& ref) { - assert(reinterpret_cast<uintptr_t>(&ref) % alignof(AlignedType) == 0); + assert(reinterpret_cast<uintptr_t>(&ref) % EXPECTED_ALIGNMENT == 0); } } } |