ARM: explicitly specify the 8-byte alignment
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 23 Aug 2017 16:50:27 +0000 (16:50 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 23 Aug 2017 16:50:27 +0000 (16:50 +0000)
It seems that GCC interprets `__attribute__((__aligned__))` as 8-byte
alignment on ARM, but clang does not.  Explicitly specify the
double-word alignment value to ensure that the structure is properly
aligned.

llvm-svn: 311574

libunwind/include/unwind.h
libunwind/test/alignment.pass.cpp

index a1a84e9..58dc3d9 100644 (file)
@@ -100,7 +100,7 @@ struct _Unwind_Control_Block {
   } pr_cache;
 
   long long int :0; /* Enforce the 8-byte alignment */
-} __attribute__((__aligned__));
+} __attribute__((__aligned__(8)));
 
 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
       (_Unwind_State state,
index 5ab5584..1a3ca5a 100644 (file)
 
 #include <unwind.h>
 
-struct MaxAligned {} __attribute__((aligned));
-static_assert(alignof(_Unwind_Exception) == alignof(MaxAligned), "");
+// EHABI  : 8-byte aligned
+// itanium: largest supported alignment for the system
+#if defined(_LIBUNWIND_ARM_EHABI)
+static_assert(alignof(_Unwind_Control_Block) == 8,
+              "_Unwind_Control_Block must be double-word aligned");
+#else
+struct MaxAligned {} __attribute__((__aligned__));
+static_assert(alignof(_Unwind_Exception) == alignof(MaxAligned),
+              "_Unwind_Exception must be maximally aligned");
+#endif
 
 int main()
 {