From 76c54d099708e56b9c81985a8e9d995b9fc5316e Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Sat, 3 Feb 2007 02:02:23 +0000 Subject: [PATCH] Stefan Fiedler: gcc41: always use 16 byte stack boundary, even with -Os; this avoids unaligned access in programs and hence segfaults in many places. E.g. most programs from procps fail without this patch when compiled with gcc41. Also fixes mysql50 with gcc41, since it requires procps to build. [2006113015183422507] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8203 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- .../gcc-4.1.1-16byte-stack-alignment.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 package/base/gcc/gcc41/gcc-4.1.1-16byte-stack-alignment.patch diff --git a/package/base/gcc/gcc41/gcc-4.1.1-16byte-stack-alignment.patch b/package/base/gcc/gcc41/gcc-4.1.1-16byte-stack-alignment.patch new file mode 100644 index 000000000..b4a229649 --- /dev/null +++ b/package/base/gcc/gcc41/gcc-4.1.1-16byte-stack-alignment.patch @@ -0,0 +1,70 @@ +see +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685 +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28621 +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27537 + +Index: gcc-4.1.1/gcc/testsuite/gcc.target/i386/pr13685.c +=================================================================== +--- gcc-4.1.1/gcc/testsuite/gcc.target/i386/pr13685.c (Revision 0) ++++ gcc-4.1.1/gcc/testsuite/gcc.target/i386/pr13685.c (Revision 116870) +@@ -0,0 +1,39 @@ ++/* PR target/13685 */ ++/* { dg-do run } */ ++/* { dg-options "-Os -msse" } */ ++#include ++#include ++#include ++#include "../../gcc.dg/i386-cpuid.h" ++ ++void foo (__m128 *, __m64 *, int); ++ ++__m128 xmm0 = { 0 }; ++__m64 mm0 = { 0 }; ++ ++int ++main () ++{ ++ unsigned long cpu_facilities = i386_cpuid (); ++ ++ if ((cpu_facilities & (bit_MMX | bit_SSE | bit_CMOV)) ++ != (bit_MMX | bit_SSE | bit_CMOV)) ++ /* If host has no SSE support, pass. */ ++ return 0; ++ ++ foo (&xmm0, &mm0, 4); ++ return 0; ++} ++ ++void ++foo (__m128 *dst, __m64 *src, int n) ++{ ++ __m128 xmm0 = { 0 }; ++ while (n > 64) ++ { ++ puts (""); ++ xmm0 = _mm_cvtpi32_ps (xmm0, *src); ++ *dst = xmm0; ++ n--; ++ } ++} +Index: gcc-4.1.1/gcc/config/i386/i386.c +=================================================================== +--- gcc-4.1.1/gcc/config/i386/i386.c (Revision 116859) ++++ gcc-4.1.1/gcc/config/i386/i386.c (Revision 116870) +@@ -1899,12 +1899,10 @@ + } + + /* Validate -mpreferred-stack-boundary= value, or provide default. +- The default of 128 bits is for Pentium III's SSE __m128, but we +- don't want additional code to keep the stack aligned when +- optimizing for code size. */ +- ix86_preferred_stack_boundary = (optimize_size +- ? TARGET_64BIT ? 128 : 32 +- : 128); ++ The default of 128 bits is for Pentium III's SSE __m128. We can't ++ change it because of optimize_size. Otherwise, we can't mix object ++ files compiled with -Os and -On. */ ++ ix86_preferred_stack_boundary = 128; + if (ix86_preferred_stack_boundary_string) + { + i = atoi (ix86_preferred_stack_boundary_string);