Nios II Linux had a bad TLS relocation generated, exposed by the
test case for PR 65771. A fix for this in nios2_legitimize_address() was
tested and applied.

Chung-Lin

2015-09-22  Chung-Lin Tang  <clt...@codesourcery.com>

        * config/nios2/nios2.c (nios2_legitimize_address): When handling
        'reg + reloc' cases, allow first operand to be non-REG, and use
        force_reg() to enforce address pattern.
Index: nios2.c
===================================================================
--- nios2.c	(revision 227931)
+++ nios2.c	(working copy)
@@ -2265,15 +2265,15 @@
 
      Which will be output as '%tls_le(var+48)(r23)' in assembly.  */
   if (GET_CODE (x) == PLUS
-      && GET_CODE (XEXP (x, 0)) == REG
       && GET_CODE (XEXP (x, 1)) == CONST)
     {
-      rtx unspec, offset, reg = XEXP (x, 0);
+      rtx unspec, offset;
       split_const (XEXP (x, 1), &unspec, &offset);
       if (GET_CODE (unspec) == UNSPEC
 	  && !nios2_large_offset_p (XINT (unspec, 1))
 	  && offset != const0_rtx)
 	{
+	  rtx reg = force_reg (Pmode, XEXP (x, 0));
 	  unspec = copy_rtx (unspec);
 	  XVECEXP (unspec, 0, 0)
 	    = plus_constant (Pmode, XVECEXP (unspec, 0, 0), INTVAL (offset));

Reply via email to