Patchwork [4.6] Fix PR libgcc/48076

login
register
mail settings
Submitter Richard Henderson
Date Nov. 29, 2012, 9:12 p.m.
Message ID <50B7CFBC.5010109@redhat.com>
Download mbox | patch
Permalink /patch/202826/
State New
Headers show

Comments

Richard Henderson - Nov. 29, 2012, 9:12 p.m.
A different fix is required for 4.6, because the __atomic
functions don't exist yet.


r~
PR libgcc/48076
        * emutls.c (__emutls_get_address): Add memory barrier before
        referencing emutls_key.

Patch

diff --git a/gcc/emutls.c b/gcc/emutls.c
index b7ee3bd..fcf6eb5 100644
--- a/gcc/emutls.c
+++ b/gcc/emutls.c
@@ -151,6 +151,9 @@  __emutls_get_address (struct __emutls_object *obj)
       __gthread_mutex_unlock (&emutls_mutex);
     }
 
+  /* Do not allow emutls_key to be loaded before offset.  */
+  __sync_synchronize();
+
   struct __emutls_array *arr = __gthread_getspecific (emutls_key);
   if (__builtin_expect (arr == NULL, 0))
     {