diff gcc/config/sol2.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents a06113de4d67
children f6334be47118
line wrap: on
line diff
--- a/gcc/config/sol2.c	Fri Feb 12 23:41:23 2010 +0900
+++ b/gcc/config/sol2.c	Mon May 24 12:47:05 2010 +0900
@@ -1,5 +1,5 @@
 /* General Solaris system support.
-   Copyright (C) 2004, 2005 , 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 , 2007, 2010 Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC.
 
 This file is part of GCC.
@@ -22,6 +22,7 @@
 #include "system.h"
 #include "coretypes.h"
 #include "tree.h"
+#include "output.h"
 #include "tm.h"
 #include "rtl.h"
 #include "tm_p.h"
@@ -70,8 +71,8 @@
 	  {
 	    *attributes = tree_cons (get_identifier ("init"), NULL,
 				     *attributes);
-	    *attributes = tree_cons (get_identifier ("used"), NULL,
-				     *attributes);
+	    TREE_USED (decl) = 1;
+	    DECL_PRESERVE_P (decl) = 1;
 	    next = TREE_CHAIN (*x);
 	    ggc_free (*x);
 	    *x = next;
@@ -87,8 +88,8 @@
 	  {
 	    *attributes = tree_cons (get_identifier ("fini"), NULL,
 				     *attributes);
-	    *attributes = tree_cons (get_identifier ("used"), NULL,
-				     *attributes);
+	    TREE_USED (decl) = 1;
+	    DECL_PRESERVE_P (decl) = 1;
 	    next = TREE_CHAIN (*x);
 	    ggc_free (*x);
 	    *x = next;
@@ -104,16 +105,54 @@
 {
   if (lookup_attribute ("init", DECL_ATTRIBUTES (decl)))
     {
-      fprintf (file, "\t.pushsection\t\".init\"\n");
+      fprintf (file, PUSHSECTION_FORMAT, ".init");
       ASM_OUTPUT_CALL (file, decl);
       fprintf (file, "\t.popsection\n");
     }
 
   if (lookup_attribute ("fini", DECL_ATTRIBUTES (decl)))
     {
-      fprintf (file, "\t.pushsection\t\".fini\"\n");
+      fprintf (file, PUSHSECTION_FORMAT, ".fini");
       ASM_OUTPUT_CALL (file, decl);
       fprintf (file, "\t.popsection\n");
     }
 }
 
+/* Emit an assembler directive to set symbol for DECL visibility to
+   the visibility type VIS, which must not be VISIBILITY_DEFAULT.  */
+
+void
+solaris_assemble_visibility (tree decl ATTRIBUTE_UNUSED,
+			     int vis ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_GAS_HIDDEN
+  /* Sun as uses .symbolic for STV_PROTECTED.  STV_INTERNAL is marked as
+     `currently reserved', but the linker treats it like STV_HIDDEN.  Sun
+     Studio 12.1 cc emits .hidden instead.
+
+     There are 3 Sun extensions GCC doesn't yet know about: STV_EXPORTED,
+     STV_SINGLETON, and STV_ELIMINATE.
+
+     See Linker and Libraries Guide, Ch. 2, Link-Editor, Defining
+     Additional Symbols with a mapfile,
+     http://docs.sun.com/app/docs/doc/819-0690/gdzmc?a=view
+     and Ch. 7, Object-File Format, Symbol Table Section,
+     http://docs.sun.com/app/docs/doc/819-0690/chapter6-79797?a=view  */
+
+  static const char * const visibility_types[] = {
+    NULL, "symbolic", "hidden", "hidden"
+  };
+
+  const char *name, *type;
+
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  type = visibility_types[vis];
+
+  fprintf (asm_out_file, "\t.%s\t", type);
+  assemble_name (asm_out_file, name);
+  fprintf (asm_out_file, "\n");
+#else
+  warning (OPT_Wattributes, "visibility attribute not supported "
+	   "in this configuration; ignored");
+#endif
+}