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]

Re: mips tls with -mlong64/-mgp32

> > check whether the offset is within the alignment of the SYMBOL_REF_DECL.

Like this?

Index: mips.c
--- mips.c	(revision 124810)
+++ mips.c	(working copy)
@@ -1413,20 +1413,39 @@ mips_symbolic_constant_p (rtx x, enum mi
 	 address, and we will apply a 16-bit offset after loading it.
 	 If the symbol is local, the linker should provide enough local
 	 GOT entries for a 16-bit offset, but larger offsets may lead
 	 to GOT overflow.  */
       return SMALL_INT (offset);
+    case SYMBOL_TPREL:
+    case SYMBOL_DTPREL:
+      {
+	/* If for some reason we can't get the alignment for the
+	   symbol, initializing this to zero means we won't accept any
+	   offset.  */
+	HOST_WIDE_INT align = 0;
+	tree t;
+	/* Get the alignment of the symbol we're referring to.  */
+	t = SYMBOL_REF_DECL (XVECEXP (x, 0, 0));
+	if (t)
+	  align = DECL_ALIGN_UNIT (t);
+	/* We accept offsets within the symbol's alignment, but not
+	   beyond, because the linker can't handle TPREL hi/lo relocs
+	   that involve carries.  */
+	if (GET_CODE (offset) == CONST_INT
+	    && INTVAL (offset) < align)
+	  return true;
+      }
     case SYMBOL_GOT_DISP:
     case SYMBOL_TLSGD:
     case SYMBOL_TLSLDM:
-    case SYMBOL_DTPREL:
-    case SYMBOL_TPREL:
     case SYMBOL_TLS:
     case SYMBOL_HALF:
       return false;
   gcc_unreachable ();

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