This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Weak functions on powerpc64-linux


	ASM_WEAKEN_DECL and ASM_OUTPUT_DEF_FROM_DECLS should be common in
rs6000.h depending on HAVE_GAS_WEAK.  See the current definition of
ASM_OUTPUT_DEF_FROM_DECLS. 

	Also, if we are going to start talking about this I should add my
patch to improve #pragma weak into the mix.  This adds the Solaris
compiler functionality distinguishing identifiers from strings.  When one
weaks a known identifier, GCC needs to weaken the DECL.

David

Index: c-pragma.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-pragma.c,v
retrieving revision 1.46
diff -c -p -r1.46 c-pragma.c
*** c-pragma.c	2001/11/13 03:20:58	1.46
--- c-pragma.c	2002/02/26 16:13:15
*************** Software Foundation, 59 Temple Place - S
*** 29,34 ****
--- 29,35 ----
  #include "flags.h"
  #include "toplev.h"
  #include "ggc.h"
+ #include "c-tree.h"
  #include "c-lex.h"
  #include "output.h"
  #include "tm_p.h"
*************** static void
*** 281,304 ****
  handle_pragma_weak (dummy)
       cpp_reader *dummy ATTRIBUTE_UNUSED;
  {
!   tree name, value, x;
!   enum cpp_ttype t;
  
    value = 0;
  
!   if (c_lex (&name) != CPP_NAME)
      GCC_BAD ("malformed #pragma weak, ignored");
!   t = c_lex (&x);
!   if (t == CPP_EQ)
      {
!       if (c_lex (&value) != CPP_NAME)
  	GCC_BAD ("malformed #pragma weak, ignored");
!       t = c_lex (&x);
      }
!   if (t != CPP_EOF)
      warning ("junk at end of #pragma weak");
  
!   add_weak (IDENTIFIER_POINTER (name), value ? IDENTIFIER_POINTER (value) : 0);
  }
  #endif
  
--- 282,333 ----
  handle_pragma_weak (dummy)
       cpp_reader *dummy ATTRIBUTE_UNUSED;
  {
!   tree name, value, x, v_decl=NULL;
!   enum cpp_ttype t_name, t_value, t_x;
  
    value = 0;
+   t_value = 0;
  
!   t_name = c_lex (&name);
! 
!   if (t_name != CPP_NAME && t_name != CPP_STRING)
      GCC_BAD ("malformed #pragma weak, ignored");
! 
!   t_x = c_lex (&x);
!   if (t_x == CPP_EQ)
      {
!       t_value = c_lex (&value);
!       /* Name and value must both be identifier or string.  */
!       if (t_value != CPP_NAME && t_value != CPP_STRING && t_value != t_name)
  	GCC_BAD ("malformed #pragma weak, ignored");
!       if (t_value == CPP_NAME
! 	  && (((v_decl = lookup_name (value)) == 0) || !DECL_P (v_decl)))
! 	GCC_BAD ("#pragma weak identifier not defined in compilation unit");
! 
!       t_x = c_lex (&x);
      }
!   if (t_x != CPP_EOF)
      warning ("junk at end of #pragma weak");
+ 
+   /* Create weak decl for alias identifier form.
+      It would be nice if declaring a symbol weak with the identifier
+      form would invoke declare_weak(), but the likely scenarios are
+      either the declaration does not yet exist or TREE_ASM_WRITTEN
+      is set.  */
+   if (t_value == CPP_NAME)
+     {
+       tree n_decl;
+ 
+       n_decl = copy_node (v_decl);
+       DECL_NAME (n_decl) = name;
  
!       add_weak (IDENTIFIER_POINTER (name), NULL);
!       DECL_WEAK (n_decl) = 1;
!       assemble_alias (n_decl, v_decl);
!     }
!   else
!     add_weak (IDENTIFIER_POINTER (name),
! 	      value ? IDENTIFIER_POINTER (value) : NULL);
  }
  #endif
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]