OSDN Git Service

* config/elfos.h (ASM_DECLARE_OBJECT_NAME): Use gnu_unique_object
[pf3gnuchains/gcc-fork.git] / gcc / config / elfos.h
index 2d818d1..56d7b40 100644 (file)
@@ -289,24 +289,37 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 /* Write the extra assembler code needed to declare an object properly.  */
 
-#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)              \
-  do                                                           \
-    {                                                          \
-      HOST_WIDE_INT size;                                      \
-                                                               \
-      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                \
-                                                               \
-      size_directive_output = 0;                               \
-      if (!flag_inhibit_size_directive                         \
-         && (DECL) && DECL_SIZE (DECL))                        \
-       {                                                       \
-         size_directive_output = 1;                            \
-         size = int_size_in_bytes (TREE_TYPE (DECL));          \
-         ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);         \
-       }                                                       \
-                                                               \
-      ASM_OUTPUT_LABEL (FILE, NAME);                           \
-    }                                                          \
+#ifdef HAVE_GAS_GNU_UNIQUE_OBJECT
+#define USE_GNU_UNIQUE_OBJECT 1
+#else
+#define USE_GNU_UNIQUE_OBJECT 0
+#endif
+
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                      \
+  do                                                                   \
+    {                                                                  \
+      HOST_WIDE_INT size;                                              \
+                                                                       \
+      /* For template static data member instantiations or             \
+        inline fn local statics, use gnu_unique_object so that         \
+        they will be combined even under RTLD_LOCAL.  */               \
+      if (USE_GNU_UNIQUE_OBJECT                                                \
+         && !DECL_ARTIFICIAL (DECL) && DECL_ONE_ONLY (DECL))           \
+       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "gnu_unique_object");    \
+      else                                                             \
+       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");               \
+                                                                       \
+      size_directive_output = 0;                                       \
+      if (!flag_inhibit_size_directive                                 \
+         && (DECL) && DECL_SIZE (DECL))                                \
+       {                                                               \
+         size_directive_output = 1;                                    \
+         size = int_size_in_bytes (TREE_TYPE (DECL));                  \
+         ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);                 \
+       }                                                               \
+                                                                       \
+      ASM_OUTPUT_LABEL (FILE, NAME);                                   \
+    }                                                                  \
   while (0)
 
 /* Output the size directive for a decl in rest_of_decl_compilation