crtstuff: adjust tm clones for no attribute hidden
authorRichard Henderson <rth@redhat.com>
Sat, 26 Nov 2011 21:16:49 +0000 (13:16 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sat, 26 Nov 2011 21:16:49 +0000 (13:16 -0800)
        * crtstuff.c (__TMC_LIST__): Mark used not unused.
        (__TMC_END__): Only declare if hidden is available; in the definition,
        if hidden is unavailable add a null record.
        (deregister_tm_clones, register_tm_clones): New.
        (__do_global_dtors_aux, frame_dummy): Use them.
        (__do_global_dtors, __do_global_ctors_1): Likewise.

From-SVN: r181744

libgcc/ChangeLog
libgcc/crtstuff.c

index 305e8ad3c3c3fa25e800b865837c15cd696956a6..93c58707ce40c9c061e2d7949d8d4895e56d9f9e 100644 (file)
@@ -1,3 +1,12 @@
+2011-11-26  Richard Henderson  <rth@redhat.com>
+
+       * crtstuff.c (__TMC_LIST__): Mark used not unused.
+       (__TMC_END__): Only declare if hidden is available; in the definition,
+       if hidden is unavailable add a null record.
+       (deregister_tm_clones, register_tm_clones): New.
+       (__do_global_dtors_aux, frame_dummy): Use them.
+       (__do_global_dtors, __do_global_ctors_1): Likewise.
+
 2011-11-22  Iain Sandoe  <iains@gcc.gnu.org>
 
        * config/darwin-crt-tm.c: New file.
index 6f06b6296020c13e71153058e76d1a53a711cf70..77b8d4201cdd4f0f29fe8fd57c9f30d49d3a7763 100644 (file)
@@ -252,9 +252,51 @@ STATIC void *__JCR_LIST__[]
 
 #if USE_TM_CLONE_REGISTRY
 STATIC func_ptr __TMC_LIST__[]
-  __attribute__((unused, section(".tm_clone_table"), aligned(sizeof(void*))))
+  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void*))))
   = { };
+# ifdef HAVE_GAS_HIDDEN
 extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden")));
+# endif
+
+static inline void
+deregister_tm_clones (void)
+{
+  void (*fn) (void *);
+
+#ifdef HAVE_GAS_HIDDEN
+  if (__TMC_END__ - __TMC_LIST__ == 0)
+    return;
+#else
+  if (__TMC_LIST__[0] == NULL)
+    return;
+#endif
+
+  fn = _ITM_deregisterTMCloneTable;
+  __asm ("" : "+r" (fn));
+  if (fn)
+    fn (__TMC_LIST__);
+}
+
+static inline void
+register_tm_clones (void)
+{
+  void (*fn) (void *, size_t);
+  size_t size;
+
+#ifdef HAVE_GAS_HIDDEN
+  size = (__TMC_END__ - __TMC_LIST__) / 2;
+#else
+  for (size = 0; __TMC_LIST__[size * 2] != NULL; size++)
+    continue;
+#endif
+  if (size == 0)
+    return;
+
+  fn = _ITM_registerTMCloneTable;
+  __asm ("" : "+r" (fn));
+  if (fn)
+    fn (__TMC_LIST__, size);
+}
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)
@@ -347,13 +389,7 @@ __do_global_dtors_aux (void)
 #endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-    {
-      void (*deregister_clones) (void *) = _ITM_deregisterTMCloneTable;
-      __asm ("" : "+r" (deregister_clones));
-      if (deregister_clones)
-       deregister_clones (__TMC_LIST__);
-    }
+  deregister_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef USE_EH_FRAME_REGISTRY
@@ -422,16 +458,7 @@ frame_dummy (void)
 #endif /* JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-    {
-      void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
-      __asm ("" : "+r" (register_clones));
-      if (register_clones)
-       {
-         size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
-         _ITM_registerTMCloneTable (__TMC_LIST__, size);
-       }
-    }
+  register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
 
@@ -500,13 +527,7 @@ __do_global_dtors (void)
     f ();
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-    {
-      void (*deregister_clones) (void *) = _ITM_deregisterTMCloneTable;
-      __asm ("" : "+r" (deregister_clones));
-      if (deregister_clones)
-       deregister_clones (__TMC_LIST__);
-    }
+  deregister_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef USE_EH_FRAME_REGISTRY
@@ -542,16 +563,7 @@ __do_global_ctors_1(void)
 #endif
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-    {
-      void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
-      __asm ("" : "+r" (register_clones));
-      if (register_clones)
-       {
-         size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
-         register_clones (__TMC_LIST__, size);
-       }
-    }
+  register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
 #endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME || USE_TM_CLONE_REGISTRY */
@@ -639,10 +651,16 @@ STATIC void *__JCR_END__[1]
 #endif /* JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
+# ifndef HAVE_GAS_HIDDEN
+static
+# endif
 func_ptr __TMC_END__[]
-  __attribute__((unused, section(".tm_clone_table"), aligned(sizeof(void *)),
-                __visibility__ ("hidden")))
-  = { };
+  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void *))))
+# ifdef HAVE_GAS_HIDDEN
+  __attribute__((__visibility__ ("hidden"))) = { };
+# else
+  = { 0, 0 };
+# endif
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef INIT_ARRAY_SECTION_ASM_OP