This is the mail archive of the 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]

Fix g++.old-deja/g++.abi/vtable2.C for MIPS o32 abicalls

g++.old-deja/g++.abi/vtable2.C was failing for -mabi=32 -mabicalls
because we were accessing a weakref symbol using local rather than
global GOT accesses.  The problem is that the decl itself is
!TREE_PUBLIC (suggesting an STB_LOCAL symbol), but the target
symbol will either be STB_GLOBAL or STB_WEAK.

The patch below tests for DECL_WEAK as well as TREE_PUBLIC.
Tested on mips64-linux-gnu (all 3 ABIs) and applied to trunk.


	* 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	(revision 118100)
+++ gcc/config/mips/mips.c	(working copy)
@@ -1198,6 +1198,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)
@@ -1229,7 +1231,8 @@ mips_classify_symbol (rtx x)
-      if (SYMBOL_REF_DECL (x) == 0)
+      decl = SYMBOL_REF_DECL (x);
+      if (decl == 0)
 	  if (!SYMBOL_REF_LOCAL_P (x))
 	    return SYMBOL_GOT_GLOBAL;
@@ -1257,11 +1260,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))
-		   && 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]