From e0b3e9d2cfe6a9a4c7ccb2cfd64290ede98efb57 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Sun, 7 Dec 2014 00:09:40 +1100 Subject: [PATCH] mesa: Ensure stack is realigned on x86 Nowadays GCC assumes stack pointer is 16-byte aligned even on 32-bits, but that is an assumption OpenGL drivers (or any dynamic library for that matter) can't afford to make as there are many closed- and open- source application binaries out there that only assume 4-byte stack alignment. https://bugs.freedesktop.org/show_bug.cgi?id=86788 --- configure.ac | 17 +++++++++++++++++ src/mesa/Makefile.am | 4 ++++ src/mesa/main/sse_minmax.c | 3 --- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b0df1bb..6bb43f8 100644 --- a/configure.ac +++ b/configure.ac @@ -474,6 +474,21 @@ fi dnl dnl Arch/platform-specific settings dnl +align_check_arch="" +if test "x$cross_compiling" = xno; then + case "$host_cpu" in + x86_64|amd64) + align_check_arch=x86_64 + ;; + esac +else + case "$host_cpu" in + i?86) + align_check_arch=x86_64 + ;; + esac +fi + AC_ARG_ENABLE([asm], [AS_HELP_STRING([--disable-asm], [disable assembly usage @<:@default=enabled on supported plaforms@:>@])], @@ -2087,6 +2102,8 @@ AM_CONDITIONAL(HAVE_X11_DRIVER, test "x$enable_xlib_glx" = xyes) AM_CONDITIONAL(HAVE_OSMESA, test "x$enable_osmesa" = xyes) AM_CONDITIONAL(HAVE_GALLIUM_OSMESA, test "x$enable_gallium_osmesa" = xyes) +AM_CONDITIONAL(HAVE_16BYTE_ALIGN, test "x$align_check_arch" = xx86_64) + AM_CONDITIONAL(HAVE_X86_ASM, test "x$asm_arch" = xx86 -o "x$asm_arch" = xx86_64) AM_CONDITIONAL(HAVE_X86_64_ASM, test "x$asm_arch" = xx86_64) AM_CONDITIONAL(HAVE_SPARC_ASM, test "x$asm_arch" = xsparc) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 932db4f..36d4223 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -153,7 +153,11 @@ libmesagallium_la_LIBADD = \ libmesa_sse41_la_SOURCES = \ main/streaming-load-memcpy.c \ main/sse_minmax.c +if HAVE_16BYTE_ALIGN libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1 +else +libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1 -mstackrealign +endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = gl.pc diff --git a/src/mesa/main/sse_minmax.c b/src/mesa/main/sse_minmax.c index 93cf2a6..222ac14 100644 --- a/src/mesa/main/sse_minmax.c +++ b/src/mesa/main/sse_minmax.c @@ -31,9 +31,6 @@ #include void -#if !defined(__x86_64__) - __attribute__((force_align_arg_pointer)) -#endif _mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index, unsigned *max_index, const unsigned count) { -- 1.9.3