Mesa (master): mesa: Ensure stack is realigned on x86.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Fri Dec 5 15:17:49 UTC 2014


Module: Mesa
Branch: master
Commit: a1fc6a91e5c6ab098fa8576e63b3a070852aa2a7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1fc6a91e5c6ab098fa8576e63b3a070852aa2a7

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Dec  2 20:20:43 2014 +0000

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.

This fix uses force_align_arg_pointer GCC attribute, and is only a
stop-gap measure.

The right fix would be to pass -mstackrealign or
-mincoming-stack-boundary=2 to all source fails that use any -msse*
option, as there is no way to guarantee if/when GCC will decide to spill
SSE registers to the stack.

https://bugs.freedesktop.org/show_bug.cgi?id=86788

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/sse_minmax.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/sse_minmax.c b/src/mesa/main/sse_minmax.c
index 222ac14..93cf2a6 100644
--- a/src/mesa/main/sse_minmax.c
+++ b/src/mesa/main/sse_minmax.c
@@ -31,6 +31,9 @@
 #include <stdint.h>
 
 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)
 {




More information about the mesa-commit mailing list