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]

[committed] Fix PR target/33169


PR target/33169 is about gcc using local rather than global GOT accesses
for weakref symbols.  This was fixed on mainline with the patch below,
which I've backported to the 4.2 branch after regression-testing on
mips-linux-gnu.  It fixes g++.old-deja/g++.abi/vtable2.C.

Richard

gcc/
	PR target/33169
	Backport from mainline:

	2006-10-29  Richard Sandiford  <richard@codesourcery.com>

	* config/mips/mips.c (mips_classify_symbol): Test DECL_WEAK as well
	as TREE_PUBLIC when deciding whether to return SYMBOL_GOT_GLOBAL.

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2007-10-21 12:50:12.000000000 +0100
+++ gcc/config/mips/mips.c	2007-10-21 12:50:18.000000000 +0100
@@ -1195,6 +1195,8 @@ struct gcc_target targetm = TARGET_INITI
 static enum mips_symbol_type
 mips_classify_symbol (rtx x)
 {
+  tree decl;
+
   if (GET_CODE (x) == LABEL_REF)
     {
       if (TARGET_MIPS16)
@@ -1226,7 +1228,8 @@ mips_classify_symbol (rtx x)
 
   if (TARGET_ABICALLS)
     {
-      if (SYMBOL_REF_DECL (x) == 0)
+      decl = SYMBOL_REF_DECL (x);
+      if (decl == 0)
 	{
 	  if (!SYMBOL_REF_LOCAL_P (x))
 	    return SYMBOL_GOT_GLOBAL;
@@ -1254,11 +1257,15 @@ mips_classify_symbol (rtx x)
 
 	     In the third case we have more freedom since both forms of
 	     access will work for any kind of symbol.  However, there seems
-	     little point in doing things differently.  */
-	  if (DECL_P (SYMBOL_REF_DECL (x))
-	      && TREE_PUBLIC (SYMBOL_REF_DECL (x))
-	      && !(TARGET_ABSOLUTE_ABICALLS
-		   && targetm.binds_local_p (SYMBOL_REF_DECL (x))))
+	     little point in doing things differently.
+
+	     Note that weakref symbols are not TREE_PUBLIC, but their
+	     targets are global or weak symbols.  Relocations in the
+	     object file will be against the target symbol, so it's
+	     that symbol's binding that matters here.  */
+	  if (DECL_P (decl)
+	      && (TREE_PUBLIC (decl) || DECL_WEAK (decl))
+	      && !(TARGET_ABSOLUTE_ABICALLS && targetm.binds_local_p (decl)))
 	    return SYMBOL_GOT_GLOBAL;
 	}
 


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