(MAKE_DECL_ONE_ONLY): Define.
authorJason Merrill <merrill@gnu.org>
Wed, 18 Sep 1996 11:07:42 +0000 (11:07 +0000)
committerJason Merrill <merrill@gnu.org>
Wed, 18 Sep 1996 11:07:42 +0000 (11:07 +0000)
From-SVN: r12736

gcc/config/svr4.h

index 4332c0fecd1451439c92013295f099aa0ec255ef..f39dd15731af2e59f185c9e7f6eef1b34f27a099 100644 (file)
@@ -639,6 +639,37 @@ do {                                                                       \
     }                                                                  \
 } while (0)
 
+/* A C statement (sans semicolon) to mark DECL to be emitted as a
+   public symbol such that extra copies in multiple translation units will
+   be discarded by the linker.  */
+#define MAKE_DECL_ONE_ONLY(DECL)                               \
+do {                                                           \
+  int len;                                                     \
+  char *name, *string, *prefix;                                        \
+                                                               \
+  DECL_WEAK (DECL) = 1;                                                \
+                                                               \
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));      \
+                                                               \
+  if (DECL_ONE_ONLY (decl))                                    \
+    {                                                          \
+      if (TREE_CODE (decl) == FUNCTION_DECL)                   \
+       prefix = ".gnu.linkonce.t.";                            \
+      else if (TREE_READONLY (decl))                           \
+       prefix = ".gnu.linkonce.r.";                            \
+      else                                                     \
+       prefix = ".gnu.linkonce.d.";                            \
+    }                                                          \
+  else                                                         \
+    prefix = "";                                               \
+                                                               \
+  len = strlen (name) + strlen (prefix);                       \
+  string = alloca (len + 1);                                   \
+  sprintf (string, "%s%s", prefix, name);                      \
+                                                               \
+  DECL_SECTION_NAME (DECL) = build_string (len, string);       \
+} while (0)
+
 /* A C statement (sans semicolon) to output an element in the table of
    global constructors.  */
 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                              \