summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2010-08-29 11:27:19 +0000
committerkettenis <kettenis@openbsd.org>2010-08-29 11:27:19 +0000
commitc7c13d1a658600f1d9bbb932b6d4b48750da66d5 (patch)
tree313bdd14311031f52e30e6a635536edca34a519c
parentFix kernel compiling with disabled IPSEC and enabled GIF/MPLS (diff)
downloadwireguard-openbsd-c7c13d1a658600f1d9bbb932b6d4b48750da66d5.tar.xz
wireguard-openbsd-c7c13d1a658600f1d9bbb932b6d4b48750da66d5.zip
Make sure local arrays of chars are word-aligned on strict alignment
architectures, just like what is done for global ones. This isn't just an optiization. There is a long tradition of building packets in arrays of chars on the stack by using casts to types that require stricter alignment. Ignore the language lawyers say it isn't explicitly allowed by the C standard. Historically many (all?) C compilers have handled that just fine, so it is stupid to break this. Thanks to mikeb@ for finding the GCC bug report against upstream GCC 4.2.1. This fixes hppa/hppa64 and sparc/sparc64 as discuessed with miod@ (upstream only fixed sparc/sparc64). Other strict alignment architectures will need similar fixes. ok deraadt@, mikeb@, miod@
-rw-r--r--gnu/gcc/gcc/config/pa/pa.h3
-rw-r--r--gnu/gcc/gcc/config/sparc/sparc.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/gnu/gcc/gcc/config/pa/pa.h b/gnu/gcc/gcc/config/pa/pa.h
index 0a2b751a550..cf131746280 100644
--- a/gnu/gcc/gcc/config/pa/pa.h
+++ b/gnu/gcc/gcc/config/pa/pa.h
@@ -336,6 +336,9 @@ typedef struct machine_function GTY(())
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
+/* Make local arrays of chars word-aligned for the same reasons. */
+#define LOCAL_ALIGNMENT(TYPE, ALIGN) DATA_ALIGNMENT (TYPE, ALIGN)
+
/* Set this nonzero if move instructions will actually fail to work
when given unaligned data. */
#define STRICT_ALIGNMENT 1
diff --git a/gnu/gcc/gcc/config/sparc/sparc.h b/gnu/gcc/gcc/config/sparc/sparc.h
index 8a2121cf27c..fcbdddcb910 100644
--- a/gnu/gcc/gcc/config/sparc/sparc.h
+++ b/gnu/gcc/gcc/config/sparc/sparc.h
@@ -690,6 +690,9 @@ if (TARGET_ARCH64 \
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
+/* Make local arrays of chars word-aligned for the same reasons. */
+#define LOCAL_ALIGNMENT(TYPE, ALIGN) DATA_ALIGNMENT (TYPE, ALIGN)
+
/* Set this nonzero if move instructions will actually fail to work
when given unaligned data. */
#define STRICT_ALIGNMENT 1