[4.6] Fix PR libgcc/48076

Submitted by Richard Henderson on Nov. 29, 2012, 9:12 p.m.

Details

Message ID 50B7CFBC.5010109@redhat.com
State New
Headers show

Commit Message

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 hide | download patch | download mbox

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))
     {