diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-08-29 11:27:20 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-08-29 11:27:20 +0000 |
commit | a2f6202b3d1c0e3154a953f5e7036f99ef66913e (patch) | |
tree | 657550b6f09d975a89f8cd323d1a5cec44f29d1b /gnu/gcc | |
parent | 9d743a281bc55e074c18751f515fc56475bff0f2 (diff) |
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@
Diffstat (limited to 'gnu/gcc')
-rw-r--r-- | gnu/gcc/gcc/config/pa/pa.h | 3 | ||||
-rw-r--r-- | gnu/gcc/gcc/config/sparc/sparc.h | 3 |
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 |